curriculum-generator 1.0.6 → 1.0.7

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: 4ca48dcc11780c66bb696b872897abb8b9b94c84
4
- data.tar.gz: 69d410306cf74b85962261c54f5a2da1d4926baf
3
+ metadata.gz: ef688b2679571a949a8c0f6fc64d5e4c3a1c710a
4
+ data.tar.gz: edc6ada8ecfffae2395c3bb4417f0f0f9507e490
5
5
  SHA512:
6
- metadata.gz: 380be4c4ed32c3502b01de9dba5ca46326b904f79865b4b9b11ad09a8b616b5d027c6e666f44e4d665ce17dc273fb9a93b7bfce8b110b18ee9fe61697e79aa6c
7
- data.tar.gz: 1c192889f053696e106d8c5b7a60b18f9c07d01eba34a247a83021df75a6dc4812d51483ffa368264094626b8ab87cbc0db0e6d67c30f93d0c6a6880b9bf9fb4
6
+ metadata.gz: 7432d3b9d63391128926fdf5d75fbc91cbb2e4787f2096bff76fb57fcaac791042780d7ab451ae7de62088dc290a6d64e7a242a1ea4249a81778846121727a1f
7
+ data.tar.gz: d5d5106055943546c6fbfb25b8475b4becdac9db1a0514b08d3e2f5d0b052d408d6644fc5db9a569465a33702eee60f3fb6094a48e1732451f4fce5017fa9afe
data/Rakefile CHANGED
@@ -2,3 +2,19 @@ require "rake"
2
2
 
3
3
  require "bundler/gem_tasks"
4
4
  require "rake/clean"
5
+
6
+
7
+ namespace :cli do
8
+
9
+ desc "Run the CurriculumGenerator command-line interface."
10
+ task :run do
11
+ lib_dir_path = File.expand_path("./lib", __FILE__)
12
+ $LOAD_PATH.unshift(lib_dir_path) unless $LOAD_PATH.include?(lib_dir_path)
13
+
14
+ require "curriculum-generator"
15
+
16
+ cli = CurriculumGenerator::CLI.new(ARGV)
17
+ cli.run
18
+ end
19
+
20
+ end
@@ -9,85 +9,5 @@ end
9
9
 
10
10
  require "curriculum-generator"
11
11
 
12
-
13
- # == Setup functions ===========================================================
14
-
15
- def setup_opts
16
-
17
- $tmp_pth = Pathname.new Dir.mktmpdir
18
- $tex_out_pth = Pathname.new Dir.mktmpdir
19
- $log_dir = $tmp_pth.join('log')
20
-
21
- $data_pth = Pathname.new File.expand_path(ask("What's the path for the directory containing the data ? ".magenta))
22
- $out_pth = Pathname.new File.expand_path(ask("What's the destination path ? ".magenta))
23
- $main_tex_file_name = ask('Main TeX file name ? '.magenta) { |q| q.default = 'main.tex' }
24
- $resources_dir_name = ask("What's the name for the directory containing the resources (relative to the directory that contains the template) ? ".magenta) { |q| q.default = 'resources' }
25
- $template_dir_pth = Pathname.new(File.expand_path(
26
- ask("What's the path of the template (leave empty for the default template) ? ".magenta) { |q|
27
- q.default = File.join(File.dirname(File.dirname(__FILE__)), 'static', 'bundled_templates', 'moderncv')
28
- }))
29
- $template_deps_file_pth = Pathname.new(File.expand_path(
30
- ask("What's the path for the YAML file containing the dependencies ? ".magenta) { |q|
31
- q.default = $template_dir_pth.join('deps.yml').to_s
32
- }))
33
-
34
- # Ensure that the languages are correctly setup, i.e. if they aren't given use all of the available languages
35
- $langs ||= Dir.glob($data_pth.join('*')).collect do |lang_data_pth|
36
- File.basename(lang_data_pth).to_sym
37
- end
38
-
39
- end
40
-
41
- # Setup the files / directories
42
- def setup_filesystem
43
- FileUtils.mkdir_p($out_pth)
44
- FileUtils.mkdir_p($log_dir)
45
- end
46
-
47
-
48
- # == Utilities =================================================================
49
-
50
- def create_log_file(name)
51
- $log_dir.join("log_#{DateTime.now.strftime('%Y.%m.%d')}_#{name}.txt")
52
- end
53
-
54
-
55
- # == CurriculumGenerator entry point ==========================================================
56
-
57
- puts '> Starting Curriculum'.green
58
-
59
- setup_opts
60
- setup_filesystem
61
-
62
- $curriculum = CurriculumGenerator::Curriculum.new(
63
- CurriculumGenerator::DataLoader::YamlDataLoader.new, # TODO: Let the user choose the data loader
64
- CurriculumGenerator::Compiler.new($tex_out_pth),
65
- $data_pth,
66
- $template_dir_pth,
67
- $langs,
68
- File.directory?($data_pth.join('en')) ? :en : nil)
69
-
70
- unless $curriculum.validate_deps($template_deps_file_pth)
71
- CurriculumGenerator::Util::Logging.log(:fatal_error, msg: "The dependencies are not satisfied.")
72
- end
73
-
74
- $curriculum.compile($langs)
75
-
76
- puts ">> Generating PDFs".green
77
-
78
- $langs.each do |lang|
79
- puts ">> Generating PDF for language #{lang.to_s.light_black}".cyan
80
-
81
- input_dir = $tex_out_pth.join(lang.to_s)
82
- out_pth = $out_pth.join(lang.to_s)
83
- FileUtils.mkdir_p(out_pth)
84
-
85
- latex_to_pdf = CurriculumGenerator::Util::LatexToPdf.new(
86
- $main_tex_file_name,
87
- input_dir,
88
- input_dir.join($resources_dir_name).join('*').to_s,
89
- out_pth,
90
- create_log_file('latex_to_pdf'))
91
-
92
- latex_to_pdf.generate
93
- end
12
+ cli = CurriculumGenerator::CLI.new(ARGV)
13
+ cli.run
@@ -13,7 +13,10 @@ require "erubis"
13
13
  # Require the project stuff.
14
14
  require "curriculum-generator/version"
15
15
  require "curriculum-generator/util"
16
+ require "curriculum-generator/generator"
16
17
  require "curriculum-generator/compiler"
17
18
  require "curriculum-generator/curriculum"
18
19
  require "curriculum-generator/data_loader"
19
- require "curriculum-generator/generator"
20
+
21
+ # Require the project entry points (a.k.a. the applications).
22
+ require "curriculum-generator/cli"
@@ -0,0 +1,87 @@
1
+ module CurriculumGenerator
2
+ class CLI
3
+
4
+ def initialize(args)
5
+ @args = args
6
+ end
7
+
8
+ def run
9
+ puts '> Starting Curriculum'.green
10
+
11
+ setup_opts
12
+ setup_filesystem
13
+
14
+ $curriculum = Curriculum.new(
15
+ DataLoader::YamlDataLoader.new, # TODO: Let the user choose the data loader.
16
+ Compiler.new($tex_out_pth),
17
+ $data_pth,
18
+ $template_dir_pth,
19
+ $langs,
20
+ File.directory?($data_pth.join('en')) ? :en : nil)
21
+
22
+ unless $curriculum.validate_deps($template_deps_file_pth)
23
+ Util::Logging.log(:fatal_error, msg: "The dependencies are not satisfied.")
24
+ end
25
+
26
+ $curriculum.compile($langs)
27
+
28
+ puts ">> Generating PDFs".green
29
+
30
+ $langs.each do |lang|
31
+ puts ">> Generating PDF for language #{lang.to_s.light_black}".cyan
32
+
33
+ input_dir = $tex_out_pth.join(lang.to_s)
34
+ out_pth = $out_pth.join(lang.to_s)
35
+ FileUtils.mkdir_p(out_pth)
36
+
37
+ latex_to_pdf = CurriculumGenerator::Util::LatexToPdf.new(
38
+ $main_tex_file_name,
39
+ input_dir,
40
+ input_dir.join($resources_dir_name).join('*').to_s,
41
+ out_pth,
42
+ create_log_file('latex_to_pdf'))
43
+
44
+ latex_to_pdf.generate
45
+ end
46
+ end
47
+
48
+ # {{{ Utilities.
49
+
50
+ def setup_opts
51
+ $tmp_pth = Pathname.new Dir.mktmpdir
52
+ $tex_out_pth = Pathname.new Dir.mktmpdir
53
+ $log_dir = $tmp_pth.join('log')
54
+
55
+ $data_pth = Pathname.new File.expand_path(ask("What's the path for the directory containing the data ? ".magenta))
56
+ $out_pth = Pathname.new File.expand_path(ask("What's the destination path ? ".magenta))
57
+ $main_tex_file_name = ask('Main TeX file name ? '.magenta) { |q| q.default = 'main.tex' }
58
+ $resources_dir_name = ask("What's the name for the directory containing the resources (relative to the directory that contains the template) ? ".magenta) { |q| q.default = 'resources' }
59
+ $template_dir_pth = Pathname.new(File.expand_path(
60
+ ask("What's the path of the template (leave empty for the default template) ? ".magenta) { |q|
61
+ q.default = File.join(File.dirname(File.dirname(__FILE__)), 'static', 'bundled_templates', 'moderncv')
62
+ }))
63
+ $template_deps_file_pth = Pathname.new(File.expand_path(
64
+ ask("What's the path for the YAML file containing the dependencies ? ".magenta) { |q|
65
+ q.default = $template_dir_pth.join('deps.yml').to_s
66
+ }))
67
+
68
+ # Ensure that the languages are correctly setup, i.e. if they aren't given use all of the available languages
69
+ $langs ||= Dir.glob($data_pth.join('*')).collect do |lang_data_pth|
70
+ File.basename(lang_data_pth).to_sym
71
+ end
72
+ end
73
+
74
+ # Setup the files / directories.
75
+ def setup_filesystem
76
+ FileUtils.mkdir_p($out_pth)
77
+ FileUtils.mkdir_p($log_dir)
78
+ end
79
+
80
+ def create_log_file(name)
81
+ $log_dir.join("log_#{DateTime.now.strftime('%Y.%m.%d')}_#{name}.txt")
82
+ end
83
+
84
+ # }}}
85
+
86
+ end
87
+ end
@@ -1,4 +1,4 @@
1
- class CurriculumGenerator
1
+ module CurriculumGenerator
2
2
  module Generator
3
3
  class CvListItem < BasicGenerator
4
4
 
@@ -1,6 +1,6 @@
1
1
  module CurriculumGenerator
2
2
 
3
3
  # This is the current version of `CurriculumGenerator`.
4
- VERSION = "1.0.6"
4
+ VERSION = "1.0.7"
5
5
 
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: curriculum-generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alessandro Molari
@@ -139,6 +139,7 @@ files:
139
139
  - bin/curriculum-generator
140
140
  - curriculum-generator.gemspec
141
141
  - lib/curriculum-generator.rb
142
+ - lib/curriculum-generator/cli.rb
142
143
  - lib/curriculum-generator/compiler.rb
143
144
  - lib/curriculum-generator/curriculum.rb
144
145
  - lib/curriculum-generator/data_loader.rb