Class: HackademicCLI
- Inherits:
-
Thor
- Object
- Thor
- HackademicCLI
- Includes:
- Thor::Actions
- Defined in:
- lib/hackademic.rb
Overview
TODO: Un-spaghetti-fy this project TODO: Handle missing Config.yml variables nicely
Constant Summary collapse
- HACKADEMIC_DIRECTORY =
File.open("#{ENV['HOME']}/.hackademic", "r").read.chomp
Instance Method Summary collapse
- #install_templates(args) ⇒ Object
- #list ⇒ Object
- #setup(root_directory) ⇒ Object
- #update_pandoc(args) ⇒ Object
Instance Method Details
#install_templates(args) ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/hackademic.rb', line 49 def install_templates(args) if !Dir.exists?(ENV["HOME"]+"/.pandoc/templates") empty_directory ENV["HOME"]+"/.pandoc" empty_directory ENV["HOME"]+"/.pandoc/templates" end template "../templates/default.asciidoc", ENV["HOME"] + "/.pandoc/templates/default.asciidoc" template "../templates/default.html5", ENV["HOME"] + "/.pandoc/templates/default.html5" template "../templates/default.latex", ENV["HOME"] + "/.pandoc/templates/default.latex" template "../templates/default.odt", ENV["HOME"] + "/.pandoc/templates/default.odt" end |
#list ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/hackademic.rb', line 27 def list say "" say " ❡ hackademic ➤➤➤", :magenta say "" say " Listing projects found in #{HACKADEMIC_DIRECTORY}/Projects/", :cyan say "" say " " + %x[ls -1 #{HACKADEMIC_DIRECTORY}/Projects].gsub!("\n","\n "), :blue end |
#setup(root_directory) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/hackademic.rb', line 61 def setup(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_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 |
#update_pandoc(args) ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/hackademic.rb', line 37 def update_pandoc(args) 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 |