my-last-cv 0.0.1 → 0.0.2

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: f49e3e414740b89f40a22d988bffe9ec9c9358f54ccc01d19de1747fe503d0cd
4
- data.tar.gz: 6a47be333db52a09c3ad418122c18a112e03c03ca5cc61a5f08f5d4ffe8c87ea
3
+ metadata.gz: 50dc7597459a46e9b9e4dc05be3ce0ad29d79f1aa8827a9286ec06b7f3c14059
4
+ data.tar.gz: df0e733de4e2e514915013766daf2f2f7cf66fb6066ef7ce045b29e0a732ab98
5
5
  SHA512:
6
- metadata.gz: d3b054946d412143dc1bfda3521f4b5311915b749c9581dcb9c8dd2e3b7e3500b8768e6945d32c9c931b5f6928d156821babf8f9e5815382bff4379eb5da6fc3
7
- data.tar.gz: e3400653f75dda9d26f61693b78327ed61b30c3e81c406776ff27d4ce6f97ec8d91a84215649a703bacea3a2b41fba82ac61bc5fe379c74f126cd3b1896b7504
6
+ metadata.gz: b0464ac5ece152ff7a35f63d4ab4faa4701b72af57e6283bc0164301501cd331b129bcd12d43e26daccfe4f89ef10dceb71848acd7cab786e329d70443548af2
7
+ data.tar.gz: b1b9b1b1faa7088385b903f0f2f02012c78813265d25a2e8c573cfc74a88a9a7d556e7a09a4bb3c30c233e47fb22067a51dfc73b3869cc7733de800a23515849
data/README.md CHANGED
@@ -3,7 +3,7 @@ A simple gem to generate beautiful CV from a markdown file
3
3
 
4
4
  ## How to use it?
5
5
  ```bash
6
- gem install bundler
6
+ bundle add my-last-cv
7
7
  bundle install
8
- ruby exe/my_last_cv sample/cv.md output/cv.pdf
8
+ bundle exec my_last_cv sample/cv.md output/cv.pdf
9
9
  ```
data/exe/my_last_cv CHANGED
@@ -1,8 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
- # Script CLI pour utiliser la gem depuis le terminal.
3
- # Usage : my_last_cv input.md output.pdf
2
+
4
3
  require 'bundler/setup'
5
- require_relative '../lib/my_last_cv'
4
+ require 'my_last_cv'
6
5
 
7
6
  if ARGV.length < 2
8
7
  puts "Usage: my_last_cv input.md output.pdf"
@@ -10,5 +9,18 @@ if ARGV.length < 2
10
9
  end
11
10
 
12
11
  input, output = ARGV
13
- MyLastCV.generate(input, output)
12
+
13
+ pro = MyLastCV::Style.new(
14
+ header_font: "Inter",
15
+ header_size: 22,
16
+ section_font: "Inter",
17
+ section_size: 12,
18
+ body_font: "Lora",
19
+ body_size: 10,
20
+ page_options: { margin: 36 },
21
+ accent_color: "1F7AE0" # blue
22
+ )
23
+
24
+ MyLastCV.generate(input, output, style: pro)
25
+
14
26
  puts "CV généré : #{output}"
@@ -13,12 +13,9 @@ module MyLastCV
13
13
  next if ligne.strip.empty?
14
14
  if (m = ligne.match(/^#\s+(.*)/))
15
15
  resultat[:name] = m[1].strip
16
- elsif (m = ligne.match(/^email:\s*(.+)/i))
16
+ elsif (m = ligne.match(/^(email|phone|location):\s*(.+)/i))
17
17
  resultat[:contact] ||= []
18
- resultat[:contact] << m[1].strip
19
- elsif (m = ligne.match(/^location:\s*(.+)/i))
20
- resultat[:contact] ||= []
21
- resultat[:contact] << m[1].strip
18
+ resultat[:contact] << m[2].strip
22
19
  elsif (m = ligne.match(/^##\s+(.*)/))
23
20
  section_actuelle = { title: m[1].strip, items: [] }
24
21
  resultat[:sections] << section_actuelle
@@ -1,4 +1,5 @@
1
1
  require 'prawn'
2
+ require "fileutils"
2
3
 
3
4
  module MyLastCV
4
5
  class Renderer
@@ -8,7 +9,9 @@ module MyLastCV
8
9
  end
9
10
 
10
11
  def to_pdf(output_path)
12
+ FileUtils.mkdir_p(File.dirname(output_path))
11
13
  Prawn::Document.generate(output_path, **@style.page_options) do |pdf|
14
+ register_fonts(pdf)
12
15
  render_header(pdf)
13
16
  render_sections(pdf)
14
17
  end
@@ -16,14 +19,35 @@ module MyLastCV
16
19
 
17
20
  private
18
21
 
22
+ def register_fonts(pdf)
23
+ fonts_dir = File.expand_path("../../fonts", __dir__)
24
+ return unless Dir.exist?(fonts_dir)
25
+
26
+ # Exemple : Inter (Regular / Bold)
27
+ pdf.font_families.update(
28
+ "Inter" => {
29
+ normal: File.join(fonts_dir, "Inter-Regular.ttf"),
30
+ bold: File.join(fonts_dir, "Inter-Bold.ttf")
31
+ },
32
+ "Lora" => {
33
+ normal: File.join(fonts_dir, "Lora-Regular.ttf"),
34
+ bold: File.join(fonts_dir, "Lora-Bold.ttf")
35
+ }
36
+ )
37
+ end
38
+
19
39
  def render_header(pdf)
20
40
  pdf.font(@style.header_font)
21
41
  pdf.move_down 12
22
- pdf.text(@parsed_cv[:name] || '-', size: @style.header_size, align: :center)
42
+ with_color(pdf, @style.accent_color) do
43
+ pdf.text(@parsed_cv[:name] || '-', size: @style.header_size, align: :center)
44
+ end
23
45
  pdf.move_down 6
24
46
  pdf.font(@style.body_font)
25
47
  pdf.text(@parsed_cv[:contact] || '', size: @style.body_size, align: :center)
26
- pdf.stroke_horizontal_rule
48
+ with_color(pdf, @style.accent_color) do
49
+ pdf.stroke_horizontal_rule
50
+ end
27
51
  pdf.move_down 12
28
52
  end
29
53
 
@@ -39,5 +63,14 @@ module MyLastCV
39
63
  end
40
64
  end
41
65
  end
66
+
67
+ def with_color(pdf, hex)
68
+ return yield if hex.to_s.strip.empty?
69
+ previous = pdf.fill_color
70
+ pdf.fill_color(hex)
71
+ yield
72
+ ensure
73
+ pdf.fill_color(previous) if previous
74
+ end
42
75
  end
43
76
  end
@@ -1,3 +1,3 @@
1
1
  module MyLastCV
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
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.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maxime Hanicotte
@@ -57,5 +57,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
57
57
  requirements: []
58
58
  rubygems_version: 3.7.1
59
59
  specification_version: 4
60
- summary: Generate your CV from Mardown to PDF
60
+ summary: Generate your CV from Markdown to PDF
61
61
  test_files: []