my-last-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
2
  SHA256:
3
- metadata.gz: cf2509574951b9a1befe15309696db3b3dbfd5ce8196fafbd8ec48d2d4ae9d80
4
- data.tar.gz: f0c6d142419598ce2246156320db87a98062667acd39e8ed30fbc06529745366
3
+ metadata.gz: 94c3e91fc809c66ce9bff0a797dbc4701562502617080a3dfc1980ff72d6d7a8
4
+ data.tar.gz: 0d92a8897223468db3de303b7a23e312873cc2da76d3b0976e2f642e7863e442
5
5
  SHA512:
6
- metadata.gz: 32586b06068dcc7b74e3700581634f6bf693108b87181641edf25c69084e1ad42258fd64fee58492a8fd509bf0fc1873a3d4efb5291504383fd508a2857d625a
7
- data.tar.gz: 7ce669851940b2e5f9c1fdec663eb8d84f90b75da8ef3e927c111d58bd038c55727386e0742b6135dc184c69e09c9f06f9ad5366f9422b3329f1eab9b40c6808
6
+ metadata.gz: cdfc99a9a7ae9d9145c643df109dedb8f9c02860e1d2d92c859a4d28a55a82bb8aff49e5d1fd478683b1e8d98f952d43d88a243749c12691f39a31489c000c4d
7
+ data.tar.gz: b8970a939e5ff4f47640dc3021cb743e4794e58a96d41db4c74ce4ed75949cc4481fd274d7b9a708a2c3badb8d257fe5982308f7b3fa931b1329cfb9d260fb20
data/README.md CHANGED
@@ -7,3 +7,8 @@ bundle add my-last-cv
7
7
  bundle install
8
8
  bundle exec my_last_cv sample/cv.md output/cv.pdf
9
9
  ```
10
+
11
+ ## Custom fonts
12
+ By default, the gem looks for fonts in `./fonts` of the calling project.
13
+ You can override this with `Style.new(fonts_dir: "/path/to/fonts")`
14
+ or `MY_LAST_CV_FONTS_DIR=/path/to/fonts`.
@@ -8,21 +8,50 @@ module MyLastCV
8
8
  lignes = @markdown.lines.map(&:chomp)
9
9
  resultat = { sections: [] }
10
10
  section_actuelle = nil
11
+ element_actuel = nil
11
12
 
12
13
  lignes.each do |ligne|
13
- next if ligne.strip.empty?
14
- if (m = ligne.match(/^#\s+(.*)/))
14
+ line = ligne
15
+ next if line.strip.empty?
16
+
17
+ if (m = line.match(/^#\s+(.*)/))
15
18
  resultat[:name] = m[1].strip
16
- elsif (m = ligne.match(/^(email|phone|location):\s*(.+)/i))
17
- resultat[:contact] ||= []
18
- resultat[:contact] << m[2].strip
19
- elsif (m = ligne.match(/^##\s+(.*)/))
20
- section_actuelle = { title: m[1].strip, items: [] }
19
+ section_actuelle = nil
20
+ element_actuel = nil
21
+
22
+ elsif (m = line.match(/^(email|phone|location):\s*(.+)/i))
23
+ (resultat[:contact] ||= []) << m[2].strip
24
+
25
+ elsif (m = line.match(/^##\s+(.*)/))
26
+ section_actuelle = { title: m[1].strip, items: [], elements: [] }
21
27
  resultat[:sections] << section_actuelle
22
- elsif (m = ligne.match(/^[-*]\s+(.*)/))
23
- section_actuelle ||= { title: "Divers", items: [] }
28
+ element_actuel = nil
29
+
30
+ elsif (m = line.match(/^###\s+(.*)/))
31
+ section_actuelle ||= { title: "Divers", items: [], elements: [] }
24
32
  resultat[:sections] << section_actuelle unless resultat[:sections].include?(section_actuelle)
25
- section_actuelle[:items] << m[1].strip
33
+
34
+ element_actuel = { title: m[1].strip, items: [] }
35
+ section_actuelle[:elements] ||= []
36
+ section_actuelle[:elements] << element_actuel
37
+
38
+ elsif (m = line.match(/^[-*]\s+(.*)/))
39
+ if element_actuel
40
+ element_actuel[:items] << m[1].strip
41
+ else
42
+ section_actuelle ||= { title: "Divers", items: [], elements: [] }
43
+ resultat[:sections] << section_actuelle unless resultat[:sections].include?(section_actuelle)
44
+ section_actuelle[:items] << m[1].strip
45
+ end
46
+ else
47
+ if element_actuel && !element_actuel[:items].empty?
48
+ element_actuel[:items][-1] += " " + line.strip
49
+ elsif section_actuelle && !section_actuelle[:items].empty?
50
+ section_actuelle[:items][-1] += " " + line.strip
51
+ else
52
+ section_actuelle ||= { title: "Divers", items: [], elements: [] }
53
+ section_actuelle[:items] << line.strip
54
+ end
26
55
  end
27
56
  end
28
57
 
@@ -68,14 +68,30 @@ module MyLastCV
68
68
  pdf.move_down 8
69
69
  pdf.font(@style.section_font)
70
70
  pdf.text(section[:title], size: @style.section_size, style: :bold)
71
- pdf.move_down 4
72
- pdf.font(@style.body_font)
73
- section[:items].each do |item|
74
- pdf.text("• #{item}", size: @style.body_size, indent_paragraphs: 16)
71
+
72
+ unless section[:items].nil? || section[:items].empty?
73
+ pdf.move_down 4
74
+ pdf.font(@style.body_font)
75
+ section[:items].each do |item|
76
+ pdf.text("• #{item}", size: @style.body_size, indent_paragraphs: 16)
77
+ end
78
+ end
79
+
80
+ (section[:elements] || []).each do |el|
81
+ pdf.move_down 6
82
+ pdf.font(@style.section_font)
83
+ pdf.text(el[:title], size: (@style.section_size - 3), style: :bold)
84
+
85
+ pdf.move_down 2
86
+ pdf.font(@style.body_font)
87
+ (el[:items] || []).each do |item|
88
+ pdf.text("• #{item}", size: @style.body_size, indent_paragraphs: 20)
89
+ end
75
90
  end
76
91
  end
77
92
  end
78
93
 
94
+
79
95
  def with_color(pdf, hex)
80
96
  return yield if hex.to_s.strip.empty?
81
97
  previous = pdf.fill_color
@@ -1,3 +1,3 @@
1
1
  module MyLastCV
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: my-last-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
  - Maxime Hanicotte