Class: Hackademic::Setup
- Inherits:
-
Thor
- Object
- Thor
- Hackademic::Setup
- Includes:
- Thor::Actions
- Defined in:
- lib/hackademic/setup.rb
Constant Summary collapse
- HACKADEMIC_DIRECTORY =
File.open("#{ENV['HOME']}/.hackademic", "r").read.chomp
Instance Method Summary collapse
- #folder(root_directory) ⇒ Object
- #install_pandoc_templates(args = nil) ⇒ Object
- #update_pandoc(args = nil) ⇒ Object
Instance Method Details
#folder(root_directory) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/hackademic/setup.rb', line 35 def folder(root_directory) say "--------------------------------------------------------------", :cyan say "Hackademic Setup:", :green say "⫸⫸⫸ Setting up main Hackademic folder structure:", :yellow directory = "#{root_directory}/Hackademic" empty_directory(directory) File.open("#{ENV['HOME']}/.hackademic", "w+"){|config| config << directory } empty_directory "#{directory}/Libraries" empty_directory "#{directory}/Libraries/My-Library" create_file "#{directory}/Libraries/My-Library/References.bib" empty_directory "#{directory}/Meta" if system("which brew") run "brew update" else run 'ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"' end invoke :update_pandoc invoke :install_pandoc_templates say "⫸⫸⫸ Initializing version control (git) for Notes database:", :yellow empty_directory "#{directory}/Notes" create_file "#{directory}/Notes/SampleNote.md" unless File.exists? "#{directory}/Notes/.git" inside "#{directory}/Notes" do run "git init ." run "git add ." run "git commit -m 'Initial commit of Notes Database'" end end empty_directory "#{directory}/Projects" say "»»»»» Done!", :green say "--------------------------------------------------------------", :cyan end |
#install_pandoc_templates(args = nil) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/hackademic/setup.rb', line 23 def install_pandoc_templates(args=nil) if !Dir.exists?(ENV["HOME"]+"/.pandoc/templates") empty_directory ENV["HOME"]+"/.pandoc" empty_directory ENV["HOME"]+"/.pandoc/templates" end template "../../templates/project/Resources/templates/default.asciidoc", ENV["HOME"] + "/.pandoc/templates/default.asciidoc" template "../../templates/project/Resources/templates/default.html5", ENV["HOME"] + "/.pandoc/templates/default.html5" template "../../templates/project/Resources/templates/default.latex", ENV["HOME"] + "/.pandoc/templates/default.latex" template "../../templates/project/Resources/templates/default.odt", ENV["HOME"] + "/.pandoc/templates/default.odt" end |
#update_pandoc(args = nil) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/hackademic/setup.rb', line 11 def update_pandoc(args=nil) if !pandoc_is_current run "brew unlink pandoc" run "brew install pandoc" run "brew link pandoc" run "brew unlink pandoc-citeproc" run "brew install pandoc-citeproc" run "brew link pandoc-citeproc" end end |