hackademic 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6b9dc2e329f95c94dce330f01ec5f4bcebdd23ed
4
- data.tar.gz: 7aed02ebdfe1f94e1ed93a685d31700a6b53abd1
3
+ metadata.gz: 9797fad4827578428d909f7ade74e838a60585ff
4
+ data.tar.gz: b6d5c4c2039641a685177411fec2320489d0e673
5
5
  SHA512:
6
- metadata.gz: 2d1b3c3b9e987bf8ddb5558e130030d98c70a3aeb1dcc2726836b4537faf61ff95b0dc2579d527d1c02f7a58c2361ad272f5bbe36493fab244c53d3777668edd
7
- data.tar.gz: e50b1368db7426679b6108482b899468bb7eb66cce13d98805bc5a4c29953be37f30f6521cedb1af5edde16b03e712bee15630ec1bf7de0112df6f6289dd124b
6
+ metadata.gz: f3a696e53aa11382118190b829e5d883b0ab3d4088f5796c9ffc3aabfbefdec5401917f0768bfee56f111a84b6100b6e3db96c2f3e1c02e84ab2b02da1dc72f3
7
+ data.tar.gz: e06041fb2b62df207c54df0559a03eec0d6373d5857aea1f107a1c781bec11b153b488c8debad68d57ac6390568a8fa474da6ebaf7ddea3386d11ac935ac1d12
data/bin/hackademic CHANGED
@@ -1,4 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
  require_relative '../lib/hackademic'
3
3
 
4
- HackademicCLI.start
4
+ if ARGV.first == "--version"
5
+ print "0.3.1"
6
+ else
7
+ HackademicCLI.start
8
+ end
data/hackademic.gemspec CHANGED
@@ -1,6 +1,8 @@
1
+ require_relative "lib/hackademic/version"
2
+
1
3
  Gem::Specification.new do |s|
2
4
  s.name = 'hackademic'
3
- s.version = '0.3.1'
5
+ s.version = Hackademic::VERSION
4
6
  s.date = '2016-02-28'
5
7
  s.summary = "Create and manage your academic workflow"
6
8
  s.description = "Hackademic manages your plain-text academic workflow."
data/lib/hackademic.rb CHANGED
@@ -5,7 +5,8 @@ require 'active_support'
5
5
  require_relative 'hackademic/config'
6
6
  require_relative 'hackademic/sync'
7
7
  require_relative 'hackademic/compile'
8
- require_relative 'hackademic/new'
8
+ require_relative 'hackademic/project'
9
+ require_relative 'hackademic/setup'
9
10
 
10
11
  # TODO: Un-spaghetti-fy this project
11
12
  # TODO: Handle missing Config.yml variables nicely
@@ -17,127 +18,11 @@ class HackademicCLI < Thor
17
18
  HACKADEMIC_DIRECTORY = File.open("#{ENV['HOME']}/.hackademic", "r").read.chomp
18
19
  source_root "#{Pathname.new(__FILE__).dirname}"
19
20
 
20
- register Sync, :sync, "sync [subcommand]", "Synchronize!"
21
- register Hackademic::New, :new, "new [PROJECT]", "Create something new!"
21
+ register Hackademic::Sync, :sync, "sync [SUBCOMMAND]", "Synchronize!"
22
+ register Hackademic::Project, :project, "project [SUBCOMMAND]", "Work with projects!"
23
+ register Hackademic::Setup, :setup, "setup [SUBCOMMAND]", "Set up and maintenance!"
22
24
 
23
25
  desc 'compile [FORMAT]', 'Type "hackademic help compile" to see choices'
24
- subcommand 'compile', ::Hackademic::Compile
25
-
26
- desc "list", "List the current projects in #{HACKADEMIC_DIRECTORY}"
27
- def list
28
- say ""
29
- say " ❡ hackademic ➤➤➤", :magenta
30
- say ""
31
- say " Listing projects found in #{HACKADEMIC_DIRECTORY}/Projects/", :cyan
32
- say ""
33
- say " " + %x[ls -1 #{HACKADEMIC_DIRECTORY}/Projects].gsub!("\n","\n "), :blue
34
- end
35
-
36
- desc "update_pandoc", "Update to latest pandoc and pandoc-citeproc"
37
- def update_pandoc(args)
38
- if !pandoc_is_current
39
- run "brew unlink pandoc"
40
- run "brew install pandoc"
41
- run "brew link pandoc"
42
- run "brew unlink pandoc-citeproc"
43
- run "brew install pandoc-citeproc"
44
- run "brew link pandoc-citeproc"
45
- end
46
- end
47
-
48
- desc "install_templates", "Install latest pandoc templates"
49
- def install_templates(args)
50
- if !Dir.exists?(ENV["HOME"]+"/.pandoc/templates")
51
- empty_directory ENV["HOME"]+"/.pandoc"
52
- empty_directory ENV["HOME"]+"/.pandoc/templates"
53
- end
54
- template "../templates/default.asciidoc", ENV["HOME"] + "/.pandoc/templates/default.asciidoc"
55
- template "../templates/default.html5", ENV["HOME"] + "/.pandoc/templates/default.html5"
56
- template "../templates/default.latex", ENV["HOME"] + "/.pandoc/templates/default.latex"
57
- template "../templates/default.odt", ENV["HOME"] + "/.pandoc/templates/default.odt"
58
- end
59
-
60
- desc "setup [FOLDER]", "Setup a new Hackademic repository at [FOLDER]"
61
- def setup(root_directory)
62
-
63
- say "--------------------------------------------------------------", :cyan
64
- say "Hackademic Setup:", :green
65
- say "⫸⫸⫸ Setting up main Hackademic folder structure:", :yellow
66
-
67
- directory = "#{root_directory}/Hackademic"
68
- empty_directory(directory)
69
- File.open("#{ENV['HOME']}/.hackademic", "w+"){|config| config << directory }
70
-
71
- empty_directory "#{directory}/Libraries"
72
- empty_directory "#{directory}/Libraries/My-Library"
73
- create_file "#{directory}/Libraries/My-Library/References.bib"
74
-
75
- empty_directory "#{directory}/Meta"
76
-
77
- if system("which brew")
78
- run "brew update"
79
- else
80
- run 'ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"'
81
- end
82
-
83
- invoke :update_pandoc
84
- invoke :install_templates
85
-
86
- say "⫸⫸⫸ Initializing version control (git) for Notes database:", :yellow
87
- empty_directory "#{directory}/Notes"
88
- create_file "#{directory}/Notes/SampleNote.md"
89
- unless File.exists? "#{directory}/Notes/.git"
90
- inside "#{directory}/Notes" do
91
- run "git init ."
92
- run "git add ."
93
- run "git commit -m 'Initial commit of Notes Database'"
94
- end
95
- end
96
-
97
- empty_directory "#{directory}/Projects"
98
-
99
- say "»»»»» Done!", :green
100
- say "--------------------------------------------------------------", :cyan
101
-
102
- end
103
-
104
- no_tasks {
105
-
106
- def pandoc_is_current
107
- if system("which pandoc")
108
- current = `pandoc --version`[/.*\n/].strip.split(" ").last
109
- latest = `brew info pandoc`[/\w+:\s\w+\s[\d+\.]*/].split(" ").last
110
- current_status = semantic_version_checker(current, latest)
111
- current_status
112
- else
113
- false
114
- end
115
- end
116
-
117
- def semantic_version_checker(current, latest)
118
- return true if current == latest
119
-
120
- latest = latest.split(".")
121
- current = current.split(".")
122
-
123
- if current.length < latest.length
124
- current = "#{current.join(".")}" + (".0" * (latest.length - current.length))
125
- current = current.split(".")
126
- end
127
-
128
- # return true if current.length > latest.length
129
- versionator = []
130
- current.each_with_index do |v, index|
131
- version = v.to_i
132
- latest_version = latest[index].to_i
133
-
134
- return true if version > latest_version
135
- versionator << (version >= latest_version)
136
- # versionator << (v.to_i >= latest[index].to_i)
137
- end
138
- versionator.all?{|v| v == true }
139
- end
140
-
141
- }
26
+ subcommand 'compile', Hackademic::Compile
142
27
 
143
28
  end
@@ -2,14 +2,15 @@ require 'pathname'
2
2
 
3
3
  module Hackademic
4
4
 
5
- class New < Thor
5
+ class Project < Thor
6
6
 
7
7
  include Thor::Actions
8
8
 
9
- source_root "#{Pathname.new(__FILE__).dirname}/templates"
9
+ # source_root "#{Pathname.new(__FILE__).dirname}/templates"
10
+ source_root "#{Pathname.new(__FILE__).dirname}"
10
11
 
11
- desc "project [PROJECTNAME]", "Setup a new Hackademic project called [PROJECTNAME]"
12
- def project(project_name)
12
+ desc "create [PROJECTNAME]", "Setup a new Hackademic project called [PROJECTNAME]"
13
+ def create(project_name)
13
14
  say "--------------------------------------------------------------", :cyan
14
15
  say "⫸⫸⫸⫸ Setting up project #{project_name}!", :cyan
15
16
 
@@ -36,7 +37,7 @@ module Hackademic
36
37
 
37
38
  say "»»»»» Creating *Resources* directory:", :green
38
39
  empty_directory("#{project}/Resources")
39
- template '../../templates/Config.yml.tt', "#{project}/Resources/Config.yml"
40
+ template '../../templates/project/Resources/Config.yml.tt', "#{project}/Resources/Config.yml"
40
41
 
41
42
  empty_directory("#{project}/Resources/Figures")
42
43
  create_file "#{project}/Resources/Figures/.gitkeep"
@@ -44,9 +45,7 @@ module Hackademic
44
45
  empty_directory("#{project}/Resources/Data")
45
46
  create_file "#{project}/Resources/Data/.gitkeep"
46
47
 
47
- empty_directory("#{project}/Resources/templates")
48
- template '../../templates/pandoc-word-template.docx', "#{project}/Resources/templates/pandoc-word-template.docx"
49
- template '../../templates/xelatex.template', "#{project}/Resources/xelatex.template"
48
+ install_templates(project)
50
49
 
51
50
  empty_directory("#{project}/Resources/csl")
52
51
  template '../../templates/apa.csl', "#{project}/Resources/csl/apa.csl"
@@ -77,6 +76,28 @@ module Hackademic
77
76
  File.dirname(__FILE__)
78
77
  end
79
78
 
79
+ desc "install_templates [PROJECTNAME]", "installs the latest templates into a project directory"
80
+ def install_templates(project)
81
+ project = "#{hackademic_directory}/Projects/#{project}"
82
+ empty_directory("#{project}/Resources/templates")
83
+ template '../../templates/project/Resources/templates/pandoc-word-template.docx', "#{project}/Resources/templates/pandoc-word-template.docx"
84
+ template '../../templates/project/Resources/templates/default.asciidoc', "#{project}/Resources/templates/default.asciidoc"
85
+ template '../../templates/project/Resources/templates/default.html5', "#{project}/Resources/templates/default.html5"
86
+ template '../../templates/project/Resources/templates/default.latex', "#{project}/Resources/templates/default.latex"
87
+ template '../../templates/project/Resources/templates/default.odt', "#{project}/Resources/templates/default.odt"
88
+ say "Installed latest hackademic/pandoc templates into #{project}", :blue
89
+ end
90
+
91
+ desc "list", "List the current projects"
92
+ def list
93
+ say ""
94
+ say " ❡ hackademic ➤➤➤", :magenta
95
+ say ""
96
+ say " Listing projects found in #{hackademic_directory}/Projects/", :cyan
97
+ say ""
98
+ say " " + %x[ls -1 #{hackademic_directory}/Projects].gsub!("\n","\n "), :blue
99
+ end
100
+
80
101
  no_tasks {
81
102
 
82
103
  def hackademic_directory
@@ -0,0 +1,118 @@
1
+ module Hackademic
2
+ class Setup < Thor
3
+
4
+ include Thor::Actions
5
+ HACKADEMIC_DIRECTORY = File.open("#{ENV['HOME']}/.hackademic", "r").read.chomp
6
+ source_root "#{Pathname.new(__FILE__).dirname}"
7
+
8
+ default_task :folder
9
+
10
+ desc "update_pandoc", "Update to latest pandoc and pandoc-citeproc"
11
+ def update_pandoc(args=nil)
12
+ if !pandoc_is_current
13
+ run "brew unlink pandoc"
14
+ run "brew install pandoc"
15
+ run "brew link pandoc"
16
+ run "brew unlink pandoc-citeproc"
17
+ run "brew install pandoc-citeproc"
18
+ run "brew link pandoc-citeproc"
19
+ end
20
+ end
21
+
22
+ desc "install_pandoc_templates", "Install latest pandoc templates"
23
+ def install_pandoc_templates(args=nil)
24
+ if !Dir.exists?(ENV["HOME"]+"/.pandoc/templates")
25
+ empty_directory ENV["HOME"]+"/.pandoc"
26
+ empty_directory ENV["HOME"]+"/.pandoc/templates"
27
+ end
28
+ template "../../templates/project/Resources/templates/default.asciidoc", ENV["HOME"] + "/.pandoc/templates/default.asciidoc"
29
+ template "../../templates/project/Resources/templates/default.html5", ENV["HOME"] + "/.pandoc/templates/default.html5"
30
+ template "../../templates/project/Resources/templates/default.latex", ENV["HOME"] + "/.pandoc/templates/default.latex"
31
+ template "../../templates/project/Resources/templates/default.odt", ENV["HOME"] + "/.pandoc/templates/default.odt"
32
+ end
33
+
34
+ desc "folder [FOLDER]", "Setup a new Hackademic skeleton at [FOLDER]"
35
+ def folder(root_directory)
36
+
37
+ say "--------------------------------------------------------------", :cyan
38
+ say "Hackademic Setup:", :green
39
+ say "⫸⫸⫸ Setting up main Hackademic folder structure:", :yellow
40
+
41
+ directory = "#{root_directory}/Hackademic"
42
+ empty_directory(directory)
43
+ File.open("#{ENV['HOME']}/.hackademic", "w+"){|config| config << directory }
44
+
45
+ empty_directory "#{directory}/Libraries"
46
+ empty_directory "#{directory}/Libraries/My-Library"
47
+ create_file "#{directory}/Libraries/My-Library/References.bib"
48
+
49
+ empty_directory "#{directory}/Meta"
50
+
51
+ if system("which brew")
52
+ run "brew update"
53
+ else
54
+ run 'ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"'
55
+ end
56
+
57
+ invoke :update_pandoc
58
+ invoke :install_pandoc_templates
59
+
60
+ say "⫸⫸⫸ Initializing version control (git) for Notes database:", :yellow
61
+ empty_directory "#{directory}/Notes"
62
+ create_file "#{directory}/Notes/SampleNote.md"
63
+ unless File.exists? "#{directory}/Notes/.git"
64
+ inside "#{directory}/Notes" do
65
+ run "git init ."
66
+ run "git add ."
67
+ run "git commit -m 'Initial commit of Notes Database'"
68
+ end
69
+ end
70
+
71
+ empty_directory "#{directory}/Projects"
72
+
73
+ say "»»»»» Done!", :green
74
+ say "--------------------------------------------------------------", :cyan
75
+
76
+ end
77
+
78
+ no_tasks {
79
+
80
+ def pandoc_is_current
81
+ if system("which pandoc")
82
+ current = `pandoc --version`[/.*\n/].strip.split(" ").last
83
+ latest = `brew info pandoc`[/\w+:\s\w+\s[\d+\.]*/].split(" ").last
84
+ current_status = semantic_version_checker(current, latest)
85
+ current_status
86
+ else
87
+ false
88
+ end
89
+ end
90
+
91
+ def semantic_version_checker(current, latest)
92
+ return true if current == latest
93
+
94
+ latest = latest.split(".")
95
+ current = current.split(".")
96
+
97
+ if current.length < latest.length
98
+ current = "#{current.join(".")}" + (".0" * (latest.length - current.length))
99
+ current = current.split(".")
100
+ end
101
+
102
+ # return true if current.length > latest.length
103
+ versionator = []
104
+ current.each_with_index do |v, index|
105
+ version = v.to_i
106
+ latest_version = latest[index].to_i
107
+
108
+ return true if version > latest_version
109
+ versionator << (version >= latest_version)
110
+ # versionator << (v.to_i >= latest[index].to_i)
111
+ end
112
+ versionator.all?{|v| v == true }
113
+ end
114
+
115
+ }
116
+ end
117
+
118
+ end
@@ -1,34 +1,36 @@
1
- class Sync < Thor
2
- desc "notes", "longer desc"
3
- def notes
4
- begin
1
+ module Hackademic
2
+ class Sync < Thor
3
+ desc "notes", "longer desc"
4
+ def notes
5
+ begin
5
6
 
6
- notes_database_directory_path = "#{ENV['HOME']}/Dropbox/Hackademic/Notes"
7
- notes_database_files = `ls -1 #{notes_database_directory_path}`.split("\n")
7
+ notes_database_directory_path = "#{ENV['HOME']}/Dropbox/Hackademic/Notes"
8
+ notes_database_files = `ls -1 #{notes_database_directory_path}`.split("\n")
8
9
 
9
- # project_directory_root_path = "/Users/lodestone/Sync/Code/overall-linking-example/001-DISS"
10
- # for every directory in the projects folder, do this stuff:
11
- # p notes_database_directory_path
12
- Dir.glob("#{ENV['HOME']}/Dropbox/Hackademic/Projects/*").each do |dir|
10
+ # project_directory_root_path = "/Users/lodestone/Sync/Code/overall-linking-example/001-DISS"
11
+ # for every directory in the projects folder, do this stuff:
12
+ # p notes_database_directory_path
13
+ Dir.glob("#{ENV['HOME']}/Dropbox/Hackademic/Projects/*").each do |dir|
13
14
 
14
- project_directory_root_path = dir
15
- referenced_files = `grep -a -h -r -o -G "{{.*}}" #{project_directory_root_path}`.split("\n").map{|f| f.gsub("{{", "").gsub("}}", "") }
15
+ project_directory_root_path = dir
16
+ referenced_files = `grep -a -h -r -o -G "{{.*}}" #{project_directory_root_path}`.split("\n").map{|f| f.gsub("{{", "").gsub("}}", "") }
16
17
 
17
- referenced_files.each do |file|
18
- if notes_database_files.include? file
19
- `unison -silent #{notes_database_directory_path}/#{file} #{project_directory_root_path}/Resources/Notes/#{file}`
18
+ referenced_files.each do |file|
19
+ if notes_database_files.include? file
20
+ `unison -silent #{notes_database_directory_path}/#{file} #{project_directory_root_path}/Resources/Notes/#{file}`
21
+ end
20
22
  end
21
- end
22
23
 
23
- project_notes = `ls -1 #{project_directory_root_path}/Resources/Notes`.split("\n")
24
- project_notes.each do |file|
25
- `unison -silent #{project_directory_root_path}/Resources/Notes/#{file} #{notes_database_directory_path}/#{file}`
24
+ project_notes = `ls -1 #{project_directory_root_path}/Resources/Notes`.split("\n")
25
+ project_notes.each do |file|
26
+ `unison -silent #{project_directory_root_path}/Resources/Notes/#{file} #{notes_database_directory_path}/#{file}`
27
+ end
26
28
  end
29
+
30
+ rescue => ex
31
+ File.open("#{ENV['HOME']}/Library/Logs/hackademic-error.log", "a"){|file| file << ex }
27
32
  end
28
33
 
29
- rescue => ex
30
- File.open("#{ENV['HOME']}/Library/Logs/hackademic-error.log", "a"){|file| file << ex }
31
34
  end
32
-
33
35
  end
34
36
  end
@@ -0,0 +1,3 @@
1
+ module Hackademic
2
+ VERSION = "0.3.2"
3
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hackademic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Petty
@@ -25,23 +25,24 @@ files:
25
25
  - bin/hackademic
26
26
  - hackademic.gemspec
27
27
  - lib/hackademic.rb
28
- - lib/hackademic/.compile.rb.swp
29
28
  - lib/hackademic/compile.rb
30
29
  - lib/hackademic/config.rb
31
- - lib/hackademic/new.rb
30
+ - lib/hackademic/project.rb
31
+ - lib/hackademic/setup.rb
32
32
  - lib/hackademic/sync.rb
33
+ - lib/hackademic/version.rb
33
34
  - templates/CHANGELOG.md.tt
34
- - templates/Config.yml.tt
35
35
  - templates/DRAFT.md.tt
36
36
  - templates/README.md.tt
37
37
  - templates/TODO.txt.tt
38
38
  - templates/apa.csl
39
- - templates/default.asciidoc
40
- - templates/default.html5
41
- - templates/default.latex
42
- - templates/default.odt
43
- - templates/pandoc-word-template.docx
44
- - templates/xelatex.template
39
+ - templates/project/Resources/Config.yml.tt
40
+ - templates/project/Resources/templates/default.asciidoc
41
+ - templates/project/Resources/templates/default.html5
42
+ - templates/project/Resources/templates/default.latex
43
+ - templates/project/Resources/templates/default.odt
44
+ - templates/project/Resources/templates/pandoc-word-template.docx
45
+ - templates/project/Resources/templates/xelatex.template
45
46
  - test/Resources/Config.yml
46
47
  homepage: http://github.com/kizmeta/hackademic
47
48
  licenses:
Binary file