curriculum-generator 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 35549f211438e86fe041498e882c7869b61d5f99
4
- data.tar.gz: c11c2225c8bd3b934c33c1a0cd023b3d958efa9f
3
+ metadata.gz: 4ca48dcc11780c66bb696b872897abb8b9b94c84
4
+ data.tar.gz: 69d410306cf74b85962261c54f5a2da1d4926baf
5
5
  SHA512:
6
- metadata.gz: 4d4364d64e1631b1c7d6cf3d45e3a169f16e14f9de4d8e971492cb3be51691a9a71f2a7c2eefe9b1a2bd1e75865215fcce175da24d7da7b61dd2f437c79f6d1c
7
- data.tar.gz: 276ca0fbfe4463bb8b606aafcfe65a408e893461d178dbf0289ca0fc69a2ba6f7db0d3a03ae6e8e9fdae06122d02b6b7bf04c66ef0b69abcef17530a311abc97
6
+ metadata.gz: 380be4c4ed32c3502b01de9dba5ca46326b904f79865b4b9b11ad09a8b616b5d027c6e666f44e4d665ce17dc273fb9a93b7bfce8b110b18ee9fe61697e79aa6c
7
+ data.tar.gz: 1c192889f053696e106d8c5b7a60b18f9c07d01eba34a247a83021df75a6dc4812d51483ffa368264094626b8ab87cbc0db0e6d67c30f93d0c6a6880b9bf9fb4
@@ -1,8 +1,8 @@
1
- # ==> Require the core dependencies.
1
+ # Require the core dependencies.
2
2
  require "tmpdir"
3
3
  require "pathname"
4
4
 
5
- # ==> Require all of the external dependencies.
5
+ # Require all of the external dependencies.
6
6
  require "hash_deep_merge"
7
7
  require "monadic"
8
8
  require "awesome_print"
@@ -10,7 +10,7 @@ require "colorize"
10
10
  require "highline/import"
11
11
  require "erubis"
12
12
 
13
- # ==> Require the project stuff.
13
+ # Require the project stuff.
14
14
  require "curriculum-generator/version"
15
15
  require "curriculum-generator/util"
16
16
  require "curriculum-generator/compiler"
@@ -1,31 +1,37 @@
1
- require 'yaml'
1
+ require "yaml"
2
2
 
3
3
 
4
- class CurriculumGenerator::DataLoader::YamlDataLoader
4
+ module CurriculumGenerator
5
+ module DataLoader
6
+ class YamlDataLoader
5
7
 
6
- # Load the localized data from the directory `data_dir_pth`, following the convention that the localized data for
7
- # a language are in a subdirectory of `data_dir_pth` named with the same name of the language.
8
- # The target language name (which is also the subdirectory name) is `trgt_lang`, which fallbacks to the `master_lang`
9
- def load_data(data_dir_pth, trgt_lang, master_lang)
10
- CurriculumGenerator::Util::Logging.log(:loading_curriculum_data, trgt_lang: trgt_lang, master_lang: master_lang)
8
+ # Load the localized data from the directory `data_dir_pth`, following the convention that the localized data for
9
+ # a language are in a subdirectory of `data_dir_pth` named with the same name of the language.
10
+ # The target language name (which is also the subdirectory name) is `trgt_lang`, which fallbacks to the `master_lang`
11
+ def load_data(data_dir_pth, trgt_lang, master_lang)
12
+ CurriculumGenerator::Util::Logging.log(:loading_curriculum_data, trgt_lang: trgt_lang, master_lang: master_lang)
11
13
 
12
- trgt_lang_data_dir_pth = data_dir_pth.join(trgt_lang.to_s)
13
- master_lang_data_dir_pth = data_dir_pth.join(master_lang.to_s)
14
+ trgt_lang_data_dir_pth = data_dir_pth.join(trgt_lang.to_s)
15
+ master_lang_data_dir_pth = data_dir_pth.join(master_lang.to_s)
14
16
 
15
- master_data = load_recursive_from_pth(trgt_lang_data_dir_pth)
16
- trgt_data = load_recursive_from_pth(master_lang_data_dir_pth)
17
+ master_data = load_recursive_from_pth(trgt_lang_data_dir_pth)
18
+ trgt_data = load_recursive_from_pth(master_lang_data_dir_pth)
17
19
 
18
- trgt_data.deep_merge(master_data) # return
19
- end
20
+ trgt_data.deep_merge(master_data)
21
+ end
22
+
23
+ # Load all of the YAML file starting from the given `base_dir_pth` and merges all of the data into an `Hash` and
24
+ # returns it
25
+ def load_recursive_from_pth(base_dir_pth)
26
+ data = {}
27
+
28
+ Dir.glob(base_dir_pth.join('**').join('*.yml')) do |yml_file_pth|
29
+ File.open(yml_file_pth, 'r') { |yml_file| data.merge!(YAML::load(yml_file)) }
30
+ end
31
+
32
+ data
33
+ end
20
34
 
21
- # Load all of the YAML file starting from the given `base_dir_pth` and merges all of the data into an `Hash` and
22
- # returns it
23
- def load_recursive_from_pth(base_dir_pth)
24
- data = {}
25
- Dir.glob(base_dir_pth.join('**').join('*.yml')) do |yml_file_pth|
26
- File.open(yml_file_pth, 'r') { |yml_file| data.merge!(YAML::load(yml_file)) }
27
35
  end
28
- data # return
29
36
  end
30
-
31
37
  end
@@ -1,32 +1,36 @@
1
- class CurriculumGenerator::Generator::CvItemWithComment < CurriculumGenerator::Generator::BasicGenerator
1
+ module CurriculumGenerator
2
+ module Generator
3
+ class CvItemWithComment < BasicGenerator
2
4
 
3
- def initialize(param, data, lang)
4
- super(param, data, lang)
5
- end
5
+ def initialize(param, data, lang)
6
+ super(param, data, lang)
7
+ end
6
8
 
7
- def generate
8
- value = get_value(param)
9
- value = Array[value] unless value.is_a?(Array)
9
+ def generate
10
+ value = get_value(param)
11
+ value = Array[value] unless value.is_a?(Array)
10
12
 
11
- inst = self
12
- value.collect do |elem|
13
- result = Either.chain do
14
- bind -> { elem.is_a?(Hash) }
15
- bind -> {
16
- elem.has_key?('title') &&
17
- elem.has_key?('content') &&
18
- elem.has_key?('comment')
19
- }
20
- bind -> {
21
- inst.get_cv_item_with_comment(elem['title'], elem['content'], elem['comment'])
22
- }
13
+ inst = self
14
+ value.collect do |elem|
15
+ result = Either.chain do
16
+ bind -> { elem.is_a?(Hash) }
17
+ bind -> {
18
+ elem.has_key?('title') &&
19
+ elem.has_key?('content') &&
20
+ elem.has_key?('comment')
21
+ }
22
+ bind -> {
23
+ inst.get_cv_item_with_comment(elem['title'], elem['content'], elem['comment'])
24
+ }
25
+ end
26
+ result.success? ? result.fetch : ''
27
+ end.join("\n")
23
28
  end
24
- result.success? ? result.fetch : ''
25
- end.join("\n")
26
- end
27
29
 
28
- def get_cv_item_with_comment(title, content, comment)
29
- "\\cvitemwithcomment{#{title}}{#{content}}{#{comment}}"
30
- end
30
+ def get_cv_item_with_comment(title, content, comment)
31
+ "\\cvitemwithcomment{#{title}}{#{content}}{#{comment}}"
32
+ end
31
33
 
34
+ end
35
+ end
32
36
  end
@@ -1,31 +1,35 @@
1
- class CurriculumGenerator::Generator::CvListDoubleItem < CurriculumGenerator::Generator::BasicGenerator
1
+ module CurriculumGenerator
2
+ module Generator
3
+ class CvListDoubleItem < BasicGenerator
2
4
 
3
- def initialize(param, data, lang)
4
- super(param, data, lang)
5
- end
5
+ def initialize(param, data, lang)
6
+ super(param, data, lang)
7
+ end
6
8
 
7
- def generate
8
- value = get_value(param)
9
- unless value.is_a?(Array)
10
- value = Array[value]
11
- end
12
- value.collect do |elem|
13
- instance = self
14
- result = Either.chain do
15
- bind -> { elem.is_a?(Hash) }
16
- bind -> { elem.has_key?('item_0') && elem.has_key?('item_1') }
17
- bind -> {
18
- instance.get_cv_list_double_item(elem['item_0'], elem['item_1'])
19
- }
9
+ def generate
10
+ value = get_value(param)
11
+ unless value.is_a?(Array)
12
+ value = Array[value]
13
+ end
14
+ value.collect do |elem|
15
+ instance = self
16
+ result = Either.chain do
17
+ bind -> { elem.is_a?(Hash) }
18
+ bind -> { elem.has_key?('item_0') && elem.has_key?('item_1') }
19
+ bind -> {
20
+ instance.get_cv_list_double_item(elem['item_0'], elem['item_1'])
21
+ }
22
+ end
23
+ result.success? ? result.fetch : ''
24
+ end.join("\n")
20
25
  end
21
- result.success? ? result.fetch : ''
22
- end.join("\n")
23
- end
24
26
 
25
- protected
27
+ protected
26
28
 
27
- def get_cv_list_double_item(item_0, item_1)
28
- "\\cvlistdoubleitem{#{item_0}}{#{item_1}}"
29
- end
29
+ def get_cv_list_double_item(item_0, item_1)
30
+ "\\cvlistdoubleitem{#{item_0}}{#{item_1}}"
31
+ end
30
32
 
33
+ end
34
+ end
31
35
  end
@@ -1,23 +1,27 @@
1
- class CurriculumGenerator::Generator::CvListItem < CurriculumGenerator::Generator::BasicGenerator
1
+ class CurriculumGenerator
2
+ module Generator
3
+ class CvListItem < BasicGenerator
2
4
 
3
- def initialize(param, data, lang)
4
- super(param, data, lang)
5
- end
5
+ def initialize(param, data, lang)
6
+ super(param, data, lang)
7
+ end
6
8
 
7
- def generate
8
- value = get_value(param)
9
- unless value.is_a?(Array)
10
- value = Array[value]
11
- end
12
- value.collect do |content|
13
- get_cv_list_item(content)
14
- end.join("\n")
15
- end
9
+ def generate
10
+ value = get_value(param)
11
+ unless value.is_a?(Array)
12
+ value = Array[value]
13
+ end
14
+ value.collect do |content|
15
+ get_cv_list_item(content)
16
+ end.join("\n")
17
+ end
16
18
 
17
- protected
19
+ protected
18
20
 
19
- def get_cv_list_item(content)
20
- "\\cvlistitem{#{content}}"
21
- end
21
+ def get_cv_list_item(content)
22
+ "\\cvlistitem{#{content}}"
23
+ end
22
24
 
25
+ end
26
+ end
23
27
  end
@@ -1,25 +1,29 @@
1
- class CurriculumGenerator::Generator::List < CurriculumGenerator::Generator::BasicGenerator
1
+ module CurriculumGenerator
2
+ module Generator
3
+ class List < BasicGenerator
2
4
 
3
- def initialize(param, data, lang)
4
- super(param, data, lang)
5
- end
5
+ def initialize(param, data, lang)
6
+ super(param, data, lang)
7
+ end
6
8
 
7
- def generate
8
- value = get_value(param)
9
- unless value.is_a?(Array)
10
- value = Array[value]
11
- end
12
- '\begin{itemize}' +
13
- value.collect do |item|
14
- get_list(item)
15
- end.join('') +
16
- '\end{itemize}'
17
- end
9
+ def generate
10
+ value = get_value(param)
11
+ unless value.is_a?(Array)
12
+ value = Array[value]
13
+ end
14
+ '\begin{itemize}' +
15
+ value.collect do |item|
16
+ get_list(item)
17
+ end.join('') +
18
+ '\end{itemize}'
19
+ end
18
20
 
19
- protected
21
+ protected
20
22
 
21
- def get_list(item)
22
- "\\item #{item}"
23
- end
23
+ def get_list(item)
24
+ "\\item #{item}"
25
+ end
24
26
 
27
+ end
28
+ end
25
29
  end
@@ -1,11 +1,15 @@
1
- class CurriculumGenerator::Generator::MacroSubstitution < CurriculumGenerator::Generator::BasicGenerator
1
+ module CurriculumGenerator
2
+ module Generator
3
+ class MacroSubstitution < BasicGenerator
2
4
 
3
- def initialize(param, data, lang)
4
- super(param, data, lang)
5
- end
5
+ def initialize(param, data, lang)
6
+ super(param, data, lang)
7
+ end
6
8
 
7
- def generate
8
- get_value(param)
9
- end
9
+ def generate
10
+ get_value(param)
11
+ end
10
12
 
13
+ end
14
+ end
11
15
  end
@@ -1,95 +1,99 @@
1
- class CurriculumGenerator::Generator::Education < CurriculumGenerator::Generator::BasicGenerator
1
+ module CurriculumGenerator
2
+ module Generator
3
+ class Education < BasicGenerator
2
4
 
3
- def initialize(param, data, lang)
4
- super(param, data, lang)
5
- end
5
+ def initialize(param, data, lang)
6
+ super(param, data, lang)
7
+ end
6
8
 
7
- def generate
8
- value = get_value(param)
9
- value.collect do |elem|
10
- get_education(elem)
11
- end.join('')
12
- end
9
+ def generate
10
+ value = get_value(param)
11
+ value.collect do |elem|
12
+ get_education(elem)
13
+ end.join('')
14
+ end
13
15
 
14
- protected
16
+ protected
15
17
 
16
- def get_education(context)
17
- context.merge!({'titles' => get_value('titles')})
18
+ def get_education(context)
19
+ context.merge!({'titles' => get_value('titles')})
18
20
 
19
- input = <<-CODE
21
+ input = <<-CODE
20
22
 
21
- \\cventry
23
+ \\cventry
22
24
 
23
- <% if @date.nil? %>
24
- {}
25
- <% elsif @date.is_a?(Hash) && @date.has_key?('from') && @date.has_key?('to') %>
26
- {<%= @date['from'] %>\\\\<%= @date['to'] %>}
27
- <% else %>
28
- {<%= @date %>}
29
- <% end %>
25
+ <% if @date.nil? %>
26
+ {}
27
+ <% elsif @date.is_a?(Hash) && @date.has_key?('from') && @date.has_key?('to') %>
28
+ {<%= @date['from'] %>\\\\<%= @date['to'] %>}
29
+ <% else %>
30
+ {<%= @date %>}
31
+ <% end %>
30
32
 
31
- {<%= @title.nil? ? '' : @title %>}
33
+ {<%= @title.nil? ? '' : @title %>}
32
34
 
33
- {}{}{}
35
+ {}{}{}
34
36
 
35
- {\\begin{itemize}
37
+ {\\begin{itemize}
36
38
 
37
- <% if @qualification %>
38
- \\item \\textit{<%= @titles['S_4']['qualification'] %>}: <%= @qualification %>
39
- <% end %>
39
+ <% if @qualification %>
40
+ \\item \\textit{<%= @titles['S_4']['qualification'] %>}: <%= @qualification %>
41
+ <% end %>
40
42
 
41
- <% if @organisation %>
42
- \\item \\textit{<%= @titles['S_4']['organisation'] %>}: <%= @organisation %>
43
- <% end %>
43
+ <% if @organisation %>
44
+ \\item \\textit{<%= @titles['S_4']['organisation'] %>}: <%= @organisation %>
45
+ <% end %>
46
+
47
+ <% if @level %>
48
+ \\item \\textit{<%= @titles['S_4']['level'] %>}: <%= @level %>
49
+ <% end %>
44
50
 
45
- <% if @level %>
46
- \\item \\textit{<%= @titles['S_4']['level'] %>}: <%= @level %>
47
- <% end %>
51
+ <% if @lessons %>
52
+ \\item \\textit{<%= @titles['S_4']['lessons'] %>}: <%= @lessons %>
53
+ <% end %>
48
54
 
49
- <% if @lessons %>
50
- \\item \\textit{<%= @titles['S_4']['lessons'] %>}: <%= @lessons %>
51
- <% end %>
55
+ <% if @validity %>
56
+ \\item \\textit{<%= @titles['S_4']['validity'] %>}: <%= @validity %>
57
+ <% end %>
52
58
 
53
- <% if @validity %>
54
- \\item \\textit{<%= @titles['S_4']['validity'] %>}: <%= @validity %>
55
- <% end %>
59
+ <% if @location %>
60
+ \\item \\textit{<%= @titles['S_4']['location'] %>}: <%= @location %>
61
+ <% end %>
56
62
 
57
- <% if @location %>
58
- \\item \\textit{<%= @titles['S_4']['location'] %>}: <%= @location %>
59
- <% end %>
63
+ <% if @teacher %>
64
+ \\item \\textit{<%= @titles['S_4']['teacher'] %>}: <%= @teacher %>
65
+ <% end %>
60
66
 
61
- <% if @teacher %>
62
- \\item \\textit{<%= @titles['S_4']['teacher'] %>}: <%= @teacher %>
63
- <% end %>
67
+ <% if @skills_covered %>
64
68
 
65
- <% if @skills_covered %>
69
+ <% unless @skills_covered.is_a?(Array) %>
70
+ <% @skills_covered = Array[@skills_covered] %>
71
+ <% end %>
66
72
 
67
- <% unless @skills_covered.is_a?(Array) %>
68
- <% @skills_covered = Array[@skills_covered] %>
69
- <% end %>
73
+ <% @skills_covered.compact! %>
70
74
 
71
- <% @skills_covered.compact! %>
75
+ <% if @skills_covered.length > 0 %>
72
76
 
73
- <% if @skills_covered.length > 0 %>
77
+ \\item \\textit{<%= @titles['S_4']['skills_covered'] %>}:
78
+ \\begin{itemize}
74
79
 
75
- \\item \\textit{<%= @titles['S_4']['skills_covered'] %>}:
76
- \\begin{itemize}
80
+ <% @skills_covered.each do |skill_covered| %>
81
+ \\item <%= skill_covered %>
82
+ <% end %>
77
83
 
78
- <% @skills_covered.each do |skill_covered| %>
79
- \\item <%= skill_covered %>
80
- <% end %>
84
+ \\end{itemize}
81
85
 
82
- \\end{itemize}
86
+ <% end %>
83
87
 
84
- <% end %>
88
+ <% end %>
85
89
 
86
- <% end %>
90
+ \\end{itemize}}
87
91
 
88
- \\end{itemize}}
92
+ CODE
89
93
 
90
- CODE
94
+ evaluate(input, context).gsub(/^\s+/,'').gsub(/\n/,'') + "\n\n"
95
+ end
91
96
 
92
- evaluate(input, context).gsub(/^\s+/,'').gsub(/\n/,'') + "\n\n"
97
+ end
93
98
  end
94
-
95
99
  end
@@ -1,61 +1,65 @@
1
- class CurriculumGenerator::Generator::SelfAssessment < CurriculumGenerator::Generator::BasicGenerator
1
+ module CurriculumGenerator
2
+ module Generator
3
+ class SelfAssessment < BasicGenerator
2
4
 
3
- def initialize(param, data, lang)
4
- super(param, data, lang)
5
- end
5
+ def initialize(param, data, lang)
6
+ super(param, data, lang)
7
+ end
6
8
 
7
- def generate
8
- get_self_assessment(get_value(param))
9
- end
9
+ def generate
10
+ get_self_assessment(get_value(param))
11
+ end
10
12
 
11
- protected
12
-
13
- def get_self_assessment(context)
14
- context.merge!({'titles' => get_value('titles')})
15
-
16
- input = <<-CODE
17
-
18
- \\cvitem{<%= @titles['S_5']['self_assessment'] %>}
19
-
20
- {
21
- \\scriptsize
22
- \\begin{tabular}{l|l|l|l|l|l|l|l|l|l|l}
23
-
24
- \\multicolumn{1}{c|}{<%= ' ' %>} &
25
- \\multicolumn{4}{|c|}{\\textbf{<%= @titles['S_5']['understanding'] %>}} &
26
- \\multicolumn{4}{|c|}{\\textbf{<%= @titles['S_5']['speaking'] %>}} &
27
- \\multicolumn{2}{|c|}{\\textbf{<%= @titles['S_5']['writing'] %>}} \\\\
28
-
29
- \\multicolumn{1}{c|}{<%= ' ' %>} &
30
- \\multicolumn{2}{|c|}{<%= @titles['S_5']['listening'] %>} &
31
- \\multicolumn{2}{|c|}{<%= @titles['S_5']['reading'] %>} &
32
- \\multicolumn{2}{|c|}{<%= @titles['S_5']['spoken_interaction'] %>} &
33
- \\multicolumn{2}{|c|}{<%= @titles['S_5']['spoken_production'] %>} &
34
- \\multicolumn{2}{|c|}{<%= @titles['S_5']['written_production'] %>} \\\\
35
- \\hline
36
-
37
- <% @languages.each do |language| %>
38
- \\hline
39
- \\textbf{<%= language['name'] %>} &
40
- <%= language['listening']['level'] %> &
41
- <%= language['listening']['description'] %> &
42
- <%= language['reading']['level'] %> &
43
- <%= language['reading']['description'] %> &
44
- <%= language['spoken_interaction']['level'] %> &
45
- <%= language['spoken_interaction']['description'] %> &
46
- <%= language['spoken_production']['level'] %> &
47
- <%= language['spoken_production']['description'] %> &
48
- <%= language['written_production']['level'] %> &
49
- <%= language['written_production']['description'] %> \\\\
50
- <% end %>
51
- \\hline
52
-
53
- \\end{tabular}
54
- }
55
-
56
- CODE
57
-
58
- evaluate(input, context).gsub(/^\s+/,'').gsub(/\n/,'') + "\n\n"
59
- end
13
+ protected
14
+
15
+ def get_self_assessment(context)
16
+ context.merge!({'titles' => get_value('titles')})
17
+
18
+ input = <<-CODE
19
+
20
+ \\cvitem{<%= @titles['S_5']['self_assessment'] %>}
21
+
22
+ {
23
+ \\scriptsize
24
+ \\begin{tabular}{l|l|l|l|l|l|l|l|l|l|l}
60
25
 
26
+ \\multicolumn{1}{c|}{<%= ' ' %>} &
27
+ \\multicolumn{4}{|c|}{\\textbf{<%= @titles['S_5']['understanding'] %>}} &
28
+ \\multicolumn{4}{|c|}{\\textbf{<%= @titles['S_5']['speaking'] %>}} &
29
+ \\multicolumn{2}{|c|}{\\textbf{<%= @titles['S_5']['writing'] %>}} \\\\
30
+
31
+ \\multicolumn{1}{c|}{<%= ' ' %>} &
32
+ \\multicolumn{2}{|c|}{<%= @titles['S_5']['listening'] %>} &
33
+ \\multicolumn{2}{|c|}{<%= @titles['S_5']['reading'] %>} &
34
+ \\multicolumn{2}{|c|}{<%= @titles['S_5']['spoken_interaction'] %>} &
35
+ \\multicolumn{2}{|c|}{<%= @titles['S_5']['spoken_production'] %>} &
36
+ \\multicolumn{2}{|c|}{<%= @titles['S_5']['written_production'] %>} \\\\
37
+ \\hline
38
+
39
+ <% @languages.each do |language| %>
40
+ \\hline
41
+ \\textbf{<%= language['name'] %>} &
42
+ <%= language['listening']['level'] %> &
43
+ <%= language['listening']['description'] %> &
44
+ <%= language['reading']['level'] %> &
45
+ <%= language['reading']['description'] %> &
46
+ <%= language['spoken_interaction']['level'] %> &
47
+ <%= language['spoken_interaction']['description'] %> &
48
+ <%= language['spoken_production']['level'] %> &
49
+ <%= language['spoken_production']['description'] %> &
50
+ <%= language['written_production']['level'] %> &
51
+ <%= language['written_production']['description'] %> \\\\
52
+ <% end %>
53
+ \\hline
54
+
55
+ \\end{tabular}
56
+ }
57
+
58
+ CODE
59
+
60
+ evaluate(input, context).gsub(/^\s+/,'').gsub(/\n/,'') + "\n\n"
61
+ end
62
+
63
+ end
64
+ end
61
65
  end
@@ -1,81 +1,85 @@
1
- class CurriculumGenerator::Generator::WorkExperience < CurriculumGenerator::Generator::BasicGenerator
1
+ module CurriculumGenerator
2
+ module Generator
3
+ class WorkExperience < BasicGenerator
2
4
 
3
- def initialize(param, data, lang)
4
- super(param, data, lang)
5
- end
5
+ def initialize(param, data, lang)
6
+ super(param, data, lang)
7
+ end
6
8
 
7
- def generate
8
- value = get_value(param)
9
- value.collect do |elem|
10
- get_work_experience(elem)
11
- end.join("\n")
12
- end
9
+ def generate
10
+ value = get_value(param)
11
+ value.collect do |elem|
12
+ get_work_experience(elem)
13
+ end.join("\n")
14
+ end
13
15
 
14
- protected
16
+ protected
15
17
 
16
- def get_work_experience(context)
18
+ def get_work_experience(context)
17
19
 
18
- context.merge!({'titles' => get_value('titles')})
20
+ context.merge!({'titles' => get_value('titles')})
19
21
 
20
- input = <<-CODE
22
+ input = <<-CODE
21
23
 
22
- \\cventry
24
+ \\cventry
25
+
26
+ <% if @date.nil? %>
27
+ {}
28
+ <% elsif @date.is_a?(Hash) && @date.has_key?('from') && @date.has_key?('to') %>
29
+ {<%= @date['from'] %>\\\\<%= @date['to'] %>}
30
+ <% else %>
31
+ {<%= @date %>}
32
+ <% end %>
23
33
 
24
- <% if @date.nil? %>
25
- {}
26
- <% elsif @date.is_a?(Hash) && @date.has_key?('from') && @date.has_key?('to') %>
27
- {<%= @date['from'] %>\\\\<%= @date['to'] %>}
28
- <% else %>
29
- {<%= @date %>}
30
- <% end %>
34
+ {<%= @occupation.nil? ? '' : @occupation %>}
31
35
 
32
- {<%= @occupation.nil? ? '' : @occupation %>}
36
+ <% if @employer_name %>
33
37
 
34
- <% if @employer_name %>
38
+ {
39
+ <%= @employer_name %>
40
+ <% if @type_of_business %>
41
+ (<%= @type_of_business %>)
42
+ <% end %>
43
+ }
35
44
 
36
- {
37
- <%= @employer_name %>
38
- <% if @type_of_business %>
39
- (<%= @type_of_business %>)
40
- <% end %>
41
- }
45
+ <% if @employer_address %>
46
+ {<%= @employer_address %>}
47
+ <% end %>
42
48
 
43
- <% if @employer_address %>
44
- {<%= @employer_address %>}
45
- <% end %>
49
+ <% end %>
46
50
 
47
- <% end %>
51
+ {}
48
52
 
49
- {}
53
+ {
54
+ <% if @main_activities %>
50
55
 
51
- {
52
- <% if @main_activities %>
56
+ <% unless @main_activities.is_a?(Array) %>
57
+ <% @main_activities = Array[@main_activities] %>
58
+ <% end %>
53
59
 
54
- <% unless @main_activities.is_a?(Array) %>
55
- <% @main_activities = Array[@main_activities] %>
56
- <% end %>
60
+ <% @main_activities.compact! %>
57
61
 
58
- <% @main_activities.compact! %>
62
+ <% if @main_activities.length > 0 %>
59
63
 
60
- <% if @main_activities.length > 0 %>
64
+ \\textit{<%= @titles['S_3']['main_activities'] %>}:
65
+ \\begin{itemize}
61
66
 
62
- \\textit{<%= @titles['S_3']['main_activities'] %>}:
63
- \\begin{itemize}
67
+ <% @main_activities.each do |main_activity| %>
68
+ \\item <%= main_activity %>
69
+ <% end %>
64
70
 
65
- <% @main_activities.each do |main_activity| %>
66
- \\item <%= main_activity %>
67
- <% end %>
71
+ \\end{itemize}
68
72
 
69
- \\end{itemize}
73
+ <% end %>
70
74
 
71
- <% end %>
75
+ <% end %>
76
+ }
72
77
 
73
- <% end %>
74
- }
78
+ CODE
75
79
 
76
- CODE
80
+ evaluate(input, context).gsub(/^\s+/,'').gsub(/\n/,'') + "\n\n"
81
+ end
77
82
 
78
- evaluate(input, context).gsub(/^\s+/,'').gsub(/\n/,'') + "\n\n"
83
+ end
79
84
  end
80
-
81
85
  end
@@ -1,61 +1,65 @@
1
- class CurriculumGenerator::Util::LatexToPdf
2
-
3
- def initialize(
4
- input_file_name, input_dir, resources_pths, out_dir, log_file,
5
- halt_on_error=true, shell_enabled=true, interpreter='xelatex', additional_args=[])
6
- @interpreter = interpreter
7
- @halt_on_error = !!halt_on_error
8
- @shell_enabled = !!shell_enabled
9
- @out_dir = out_dir
10
- @input_file_name = input_file_name
11
- @input_dir = input_dir
12
- @resources_pths = resources_pths
13
- @log_file = log_file
14
- @additional_args = additional_args.is_a?(Array) ? additional_args : []
15
- end
1
+ module CurriculumGenerator
2
+ module Util
3
+ class LatexToPdf
16
4
 
17
- def generate
18
-
19
- # Store the starting resources for later cleanup
20
- starting_resources = resources_files
21
-
22
- # Create the command used to generate the PDF
23
- gen_pdf_cmd = CurriculumGenerator::Util::ShellCommand.new(get_tex_cmd, @input_dir, @log_file)
24
- # Create the command used to generate the bibliography
25
- gen_bib_cmd = CurriculumGenerator::Util::ShellCommand.new(get_bibtex_cmd, @out_dir, @log_file)
26
-
27
- Either.chain do
28
- bind -> { gen_pdf_cmd.run }
29
- bind -> { gen_bib_cmd.run }
30
- bind -> { gen_pdf_cmd.run }
31
- bind -> { gen_pdf_cmd.run }
32
- bind -> {
33
- # ==> Cleanup resources files
34
- dirty_files = resources_files - starting_resources
35
- dirty_files.length > 0 ? system("rm #{dirty_files.join(' ')}") : false
36
- }
37
- end
38
- end
5
+ def initialize(
6
+ input_file_name, input_dir, resources_pths, out_dir, log_file,
7
+ halt_on_error=true, shell_enabled=true, interpreter='xelatex', additional_args=[])
8
+ @interpreter = interpreter
9
+ @halt_on_error = !!halt_on_error
10
+ @shell_enabled = !!shell_enabled
11
+ @out_dir = out_dir
12
+ @input_file_name = input_file_name
13
+ @input_dir = input_dir
14
+ @resources_pths = resources_pths
15
+ @log_file = log_file
16
+ @additional_args = additional_args.is_a?(Array) ? additional_args : []
17
+ end
39
18
 
40
- protected
19
+ def generate
41
20
 
42
- def get_tex_cmd
43
- args = %w(-synctex=1 -interaction=batchmode) # default arguments
44
- args << '-halt-on-error' if @halt_on_error # halt on error
45
- args += %w(-shell-escape --enable-write18) if @shell_enabled # shell escape
46
- args << "-output-directory=#{@out_dir}" # output directory
47
- args += @additional_args # add the additional arguments to the computed ones
48
- args << @input_file_name
21
+ # Store the starting resources for later cleanup
22
+ starting_resources = resources_files
49
23
 
50
- "#{@interpreter} #{args.join(' ')}" # build the tex command and return it
51
- end
24
+ # Create the command used to generate the PDF
25
+ gen_pdf_cmd = ShellCommand.new(get_tex_cmd, @input_dir, @log_file)
26
+ # Create the command used to generate the bibliography
27
+ gen_bib_cmd = ShellCommand.new(get_bibtex_cmd, @out_dir, @log_file)
52
28
 
53
- def get_bibtex_cmd
54
- "BIBINPUTS=\"#{@input_dir}\" " + "bibtex #{@input_file_name}" # build the bibtex command and return it
55
- end
29
+ Either.chain do
30
+ bind -> { gen_pdf_cmd.run }
31
+ bind -> { gen_bib_cmd.run }
32
+ bind -> { gen_pdf_cmd.run }
33
+ bind -> { gen_pdf_cmd.run }
34
+ bind -> {
35
+ # ==> Cleanup resources files
36
+ dirty_files = resources_files - starting_resources
37
+ dirty_files.length > 0 ? system("rm #{dirty_files.join(' ')}") : false
38
+ }
39
+ end
40
+ end
56
41
 
57
- def resources_files
58
- Dir.glob(@resources_pths)
59
- end
42
+ protected
60
43
 
44
+ def get_tex_cmd
45
+ args = %w(-synctex=1 -interaction=batchmode) # default arguments
46
+ args << '-halt-on-error' if @halt_on_error # halt on error
47
+ args += %w(-shell-escape --enable-write18) if @shell_enabled # shell escape
48
+ args << "-output-directory=#{@out_dir}" # output directory
49
+ args += @additional_args # add the additional arguments to the computed ones
50
+ args << @input_file_name
51
+
52
+ "#{@interpreter} #{args.join(' ')}" # build the tex command and return it
53
+ end
54
+
55
+ def get_bibtex_cmd
56
+ "BIBINPUTS=\"#{@input_dir}\" " + "bibtex #{@input_file_name}" # build the bibtex command and return it
57
+ end
58
+
59
+ def resources_files
60
+ Dir.glob(@resources_pths)
61
+ end
62
+
63
+ end
64
+ end
61
65
  end
@@ -1,27 +1,31 @@
1
- module CurriculumGenerator::Util::Logging
1
+ module CurriculumGenerator
2
+ module Util
3
+ class Logging
2
4
 
3
- def self.log(name, opts={})
4
- case name
5
- when :fatal_error
6
- puts "#{prefix} Fatal error: #{opts[:msg].light_black}. Aborting...".red
7
- when :loading_curriculum_data
8
- puts "#{prefix} Loading the curriculum data for ".cyan + opts[:trgt_lang].to_s.light_black
9
- puts "#{indent} using ".cyan + opts[:master_lang].to_s.light_black + ' as the default'.cyan
10
- when :executing_command
11
- puts "#{prefix} Executing ".cyan + opts[:cmd].to_s.light_black
12
- puts "#{indent} from the directory ".cyan + opts[:exec_dir].to_s.light_black if opts.has_key? :exec_dir
13
- puts "#{indent} logging to ".cyan + opts[:log_file].to_s.light_black if opts.has_key? :log_file
14
- else
15
- # nothing to do
16
- end
17
- end
5
+ def self.log(name, opts={})
6
+ case name
7
+ when :fatal_error
8
+ puts "#{prefix} Fatal error: #{opts[:msg].light_black}. Aborting...".red
9
+ when :loading_curriculum_data
10
+ puts "#{prefix} Loading the curriculum data for ".cyan + opts[:trgt_lang].to_s.light_black
11
+ puts "#{indent} using ".cyan + opts[:master_lang].to_s.light_black + ' as the default'.cyan
12
+ when :executing_command
13
+ puts "#{prefix} Executing ".cyan + opts[:cmd].to_s.light_black
14
+ puts "#{indent} from the directory ".cyan + opts[:exec_dir].to_s.light_black if opts.has_key? :exec_dir
15
+ puts "#{indent} logging to ".cyan + opts[:log_file].to_s.light_black if opts.has_key? :log_file
16
+ else
17
+ # nothing to do
18
+ end
19
+ end
18
20
 
19
- def self.prefix
20
- '>>'
21
- end
21
+ def self.prefix
22
+ ">>"
23
+ end
22
24
 
23
- def self.indent
24
- ' '
25
- end
25
+ def self.indent
26
+ " "
27
+ end
26
28
 
29
+ end
30
+ end
27
31
  end
@@ -1,48 +1,52 @@
1
- class CurriculumGenerator::Util::ShellCommand
1
+ module CurriculumGenerator
2
+ module Util
3
+ class ShellCommand
4
+
5
+ def initialize(command, execution_dir, log_file=nil)
6
+ @command = command
7
+ @execution_dir = execution_dir
8
+ @log_file = log_file
9
+ end
2
10
 
3
- def initialize(command, execution_dir, log_file=nil)
4
- @command = command
5
- @execution_dir = execution_dir
6
- @log_file = log_file
7
- end
11
+ def run
12
+ Logging.log(:executing_command, cmd: @command, exec_dir: @execution_dir, log_file: @log_file)
8
13
 
9
- def run
10
- CurriculumGenerator::Util::Logging.log(:executing_command, cmd: @command, exec_dir: @execution_dir, log_file: @log_file)
14
+ status = true
11
15
 
12
- status = true
16
+ Process.waitpid(
17
+ fork do
18
+ original_stdout, original_stderr = $stdout, $stderr
19
+ FileUtils.chdir @execution_dir do
20
+ File.open(@log_file, 'a') do |log_file|
21
+ $stderr = $stdout = log_file
22
+ system @command
23
+ $stdout, $stderr = original_stdout, original_stderr
24
+ end
25
+ end
26
+ end)
13
27
 
14
- Process.waitpid(
15
- fork do
16
- original_stdout, original_stderr = $stdout, $stderr
17
- FileUtils.chdir @execution_dir do
18
- File.open(@log_file, 'a') do |log_file|
19
- $stderr = $stdout = log_file
20
- system @command
21
- $stdout, $stderr = original_stdout, original_stderr
22
- end
23
- end
24
- end)
28
+ status # return
29
+ end
25
30
 
26
- status # return
27
- end
31
+ def self.exist?(command)
32
+ exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
33
+ ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
34
+ exts.collect do |ext|
35
+ exe = File.join(path, "#{command}#{ext}")
36
+ return true if File.executable? exe
37
+ end
38
+ end
39
+ false # return
40
+ end
28
41
 
29
- def self.exist?(command)
30
- exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
31
- ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
32
- exts.collect do |ext|
33
- exe = File.join(path, "#{command}#{ext}")
34
- return true if File.executable? exe
42
+ def exist?
43
+ self.class.exist? @command
35
44
  end
36
- end
37
- false # return
38
- end
39
45
 
40
- def exist?
41
- self.class.exist? @command
42
- end
46
+ def find_executable_part(command)
47
+ command.split(' ').first
48
+ end
43
49
 
44
- def find_executable_part(command)
45
- command.split(' ').first
50
+ end
46
51
  end
47
-
48
52
  end
@@ -1,6 +1,6 @@
1
1
  module CurriculumGenerator
2
2
 
3
3
  # This is the current version of `CurriculumGenerator`.
4
- VERSION = "1.0.5"
4
+ VERSION = "1.0.6"
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.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alessandro Molari