multiformat-cv 0.0.4 → 0.0.5

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
- SHA1:
3
- metadata.gz: fb6848449162f50e5789eee60cd365254ee5c5d1
4
- data.tar.gz: 2c59c1f728b2a812af93c2d89fcf7ba690258605
2
+ SHA256:
3
+ metadata.gz: 46029dcec4bbd91c576ad53361d1738902b2d50bbc2161797bbae740cc5ca9c7
4
+ data.tar.gz: f737b5ac82aadd2f0b8ba8e28d3b4fd2e1800a9caf4aca194282890f947dec21
5
5
  SHA512:
6
- metadata.gz: abe7dfeb1ff955dc1b08744837e6ccb9a29e6f8e1ad6577d683ed808a562a7681d19de2a807234aff914cc54f2bc0f04a916d14380e4c1d318243878a2eec734
7
- data.tar.gz: e9a943bf7da55437b8b84b672a62b9c902887c3662541c6b277725eae8e04e8db1cea37259f803df2ca3c20c1542f850c0feb513570b91112313d21689782e39
6
+ metadata.gz: b4b4ba02dbfe90c2140817ab79053eb5935b279e8810794d20ce4db45d928d6b3f3b1fedce58203fdbcd21c7487018bf1212e21c42797f0bce6e0fdb67509076
7
+ data.tar.gz: 61962fc1806b742df3bb5caa09cf57fdd06cc41ebb06919cebf3af6aceab304f8ccd7e7f3b2b9623c062ad92895af6195fa7f004ecc61129dbbf51273eb0d048
data/lib/multiformatcv.rb CHANGED
@@ -9,19 +9,21 @@ module MultiformatCV
9
9
  # Parse yaml files located at data directory
10
10
  #
11
11
  # @param [Hash] opts Options to specify format and templates source
12
- # @option opts [String] :data_dir Directory where the YAML files are located.
13
- # @option opts [Symbol] :format One of [ :html, :tex ]
14
- # @option opts [String] :templates Directory where templates are located,
12
+ # @option opts [String] 'data_dir' Directory where the YAML files are located.
13
+ # @option opts [Symbol] 'format' One of [ :html, :tex ]
14
+ # @option opts [Symbol] 'output' Output file
15
+ # @option opts [String] 'templates' Directory where templates are located,
15
16
  # expected template files are `cv.#{ format }.erb`
16
17
  #
17
- # @return [String] Evaluated Erubi::Engine's source
18
+ # @return [MultiformatCV::Resume] Resume with parsed data
18
19
  # @see https://www.rubydoc.info/gems/erubi/1.8.0 Erubi documentation
19
20
  # @see Erubi::Engine
21
+
20
22
  def self.generate(opts = {})
21
23
  opts['format'] ||= 'html'
22
24
  opts['data_dir'] ||= 'data'
23
- opts['templates'] ||= File.expand_path("../multiformatcv/templates", __FILE__)
24
- opts['output'] ||= STDOUT
25
+ opts['templates'] ||= default_template_path
26
+ opts['output'] ||= nil
25
27
 
26
28
  template = File.read("#{ opts['templates'] }/cv.#{ opts['format'] }.erb")
27
29
  resume = Resume.new
@@ -34,12 +36,19 @@ module MultiformatCV
34
36
  end
35
37
  end
36
38
 
37
- result = eval Erubi::Engine.new(template).src
38
- if opts['output'] == STDOUT then
39
- puts result
40
- else
41
- File.open(opts['output'], "w") { |f| f.write(result) }
39
+ resume.rendered = eval Erubi::Engine.new(template).src
40
+
41
+ if opts['output'] then
42
+ File.open(opts['output'], 'w') { |f| f.write(resume.rendered) }
42
43
  end
44
+
45
+ resume
46
+ end
47
+
48
+ private
49
+
50
+ def self.default_template_path
51
+ File.expand_path('../../sample/onepager', __FILE__)
43
52
  end
44
53
  end
45
54
 
@@ -23,7 +23,7 @@ class MultiformatCV::Contact
23
23
  # @option h [Hash<String, String>] 'links'
24
24
 
25
25
  def initialize(h = {})
26
- @name = h['name']
26
+ @name = h['name']
27
27
  @title = h['title']
28
28
  @email = h['email']
29
29
  @phone = h['phone']
@@ -33,8 +33,10 @@ class MultiformatCV::Job
33
33
  @summary = h['summary']
34
34
  @projects = []
35
35
 
36
- h['projects'].each do |p|
37
- @projects << MultiformatCV::Project.new(p)
36
+ if h['projects']
37
+ h['projects'].each do |p|
38
+ @projects << MultiformatCV::Project.new(p)
39
+ end
38
40
  end
39
41
  end
40
42
  end
@@ -11,13 +11,29 @@ class MultiformatCV::Resume
11
11
  # @return [MultiformatCV::Personal]
12
12
  attr_accessor :personal
13
13
 
14
+ # Rendered templates with CV data
15
+ # @return [String]
16
+ attr_accessor :rendered
17
+
18
+ # Initialize Resume
19
+ #
20
+ # @param [Hash] h Options
21
+ # @option h [Array<MultiformatCV::Contact>] 'contact' Contact information
22
+ # @option h [Array<MultiformatCV::Job>] 'jobs' Jobs list
23
+ # @option h [Array<MultiformatCV::Personal>] 'personal' Personal information
24
+
14
25
  def initialize(h = {})
26
+ @contact = MultiformatCV::Contact.new(h['contact'] || []) if h['contact']
15
27
  @jobs = []
28
+ @personal = MultiformatCV::Personal.new(h['personal'] || []) if h['personal']
29
+
30
+ h['jobs'].each { |j| @jobs << MultiformatCV::Job.new(j) } if h['jobs']
16
31
  end
17
32
 
18
33
  # Set contact information
19
34
  # @param [Hash] h Hash used to initialize new MultiformatCV::Contact
20
35
  # @see MultiformatCV::Contact
36
+
21
37
  def add_contact(h = {})
22
38
  @contact = MultiformatCV::Contact.new(h)
23
39
  end
@@ -28,6 +44,7 @@ class MultiformatCV::Resume
28
44
  # MultiformatCV::Job entries
29
45
  #
30
46
  # @see MultiformatCV::Job
47
+
31
48
  def add_jobs(arr = [])
32
49
  arr.each { |j| @jobs << MultiformatCV::Job.new(j) }
33
50
  end
@@ -35,6 +52,7 @@ class MultiformatCV::Resume
35
52
  # Set personal information
36
53
  # @param [Hash] h Hash used to initialize new MultiformatCV::Personal
37
54
  # @see MultiformatCV::Personal
55
+
38
56
  def add_personal(h = {})
39
57
  @personal = MultiformatCV::Personal.new(h)
40
58
  end
@@ -1 +1,4 @@
1
- module MultiformatCV VERSION = "0.0.4" end
1
+ module MultiformatCV
2
+ # Gem version
3
+ VERSION = '0.0.5'
4
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multiformat-cv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - JuanKman94
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-24 00:00:00.000000000 Z
11
+ date: 2020-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: erubi
@@ -77,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
77
  version: '0'
78
78
  requirements: []
79
79
  rubyforge_project:
80
- rubygems_version: 2.6.14.3
80
+ rubygems_version: 2.7.6.2
81
81
  signing_key:
82
82
  specification_version: 4
83
83
  summary: Generate your CV in different formats