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 +4 -4
- data/README.md +5 -0
- data/lib/my_last_cv/parser.rb +39 -10
- data/lib/my_last_cv/renderer.rb +20 -4
- data/lib/my_last_cv/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94c3e91fc809c66ce9bff0a797dbc4701562502617080a3dfc1980ff72d6d7a8
|
4
|
+
data.tar.gz: 0d92a8897223468db3de303b7a23e312873cc2da76d3b0976e2f642e7863e442
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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`.
|
data/lib/my_last_cv/parser.rb
CHANGED
@@ -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
|
-
|
14
|
-
if
|
14
|
+
line = ligne
|
15
|
+
next if line.strip.empty?
|
16
|
+
|
17
|
+
if (m = line.match(/^#\s+(.*)/))
|
15
18
|
resultat[:name] = m[1].strip
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
elsif (m =
|
20
|
-
|
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
|
-
|
23
|
-
|
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
|
-
|
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
|
|
data/lib/my_last_cv/renderer.rb
CHANGED
@@ -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
|
-
|
72
|
-
|
73
|
-
|
74
|
-
pdf.
|
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
|
data/lib/my_last_cv/version.rb
CHANGED