simple_cv 0.1.0 → 0.2.1

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.
@@ -1,19 +1,25 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "prawn"
2
- require "prawn-svg"
3
4
 
4
5
  module SimpleCV
5
6
  class Layout < ::Prawn::Document
7
+ attr_reader :config, :black, :dark_gray, :light_gray
6
8
 
7
- def initialize config:
9
+ def initialize(config = {})
8
10
  @config = config
9
11
 
12
+ @black = "000000"
13
+ @dark_gray = "6c6c6c"
14
+ @light_gray = "A2A2A2"
15
+
10
16
  super({
11
17
  page_size: "A4",
12
18
  info: {
13
- Title: @config.title,
14
- Author: @config.author,
15
- Creator: "AwesomeCV",
16
- Producer: "AwesomeCV",
19
+ Title: config["title"],
20
+ Author: config["author"],
21
+ Creator: config["author"],
22
+ Producer: config["author"],
17
23
  CreationDate: Time.now
18
24
  }
19
25
  })
@@ -22,165 +28,170 @@ module SimpleCV
22
28
  font "Default"
23
29
  stroke_color "000000"
24
30
  main
25
- end
26
-
27
- # Main
28
- #
29
- # This builds main layout. Document is diveded in two columns.
30
- # First column provides personal details and skills, second
31
- # column show historic experience and education.
32
31
 
33
- def main
34
- bounding_box([0, 770], width: 170) do
35
- job
36
- profile
37
- contact
38
- skills
32
+ if page_count > 1
33
+ options = { start_count_at: 1, at: [0, -10], size: 7, style: :light, color: light_gray, align: :right }
34
+ number_pages("Page <page> of <total>", options)
39
35
  end
36
+ end
40
37
 
41
- bounding_box([200, 770], width: 320) do
42
- experience
43
- education
38
+ def main
39
+ header
40
+ if config["intro"]
41
+ intro
42
+ start_new_page
44
43
  end
44
+ experience
45
+ education
46
+ certification
45
47
  end
46
48
 
47
- def job
48
- h1 @config.profile&.name
49
- text @config.profile&.job, style: :normal, size: 11
49
+ def header
50
+ text(config.dig("profile", "name")&.upcase, size: 20, leading: 3, character_spacing: 1.9)
51
+ move_down(2)
52
+ text(config.dig("profile", "job")&.upcase, style: :light, size: 12, leading: 3, character_spacing: 1.9, color: dark_gray)
53
+ move_down(10)
54
+ stroke_color(black)
55
+ line_width(1)
56
+ line([0, cursor], [523, cursor])
50
57
  stroke
51
- move_down 25
52
- end
53
-
54
- def profile
55
- h2 "profile"
56
- text @config.profile&.description, style: :normal, size: 10
57
- move_down 25
58
- end
59
58
 
60
- def contact
61
- h2 "contact"
62
- contact_table
63
- move_down 25
64
- end
59
+ line_pointer = 770
60
+ text_box(config.dig("contact", "address"), size: 8, at: [240, line_pointer], align: :right, style: :light)
65
61
 
66
- def skills
67
- h2 "skills"
68
- skill_table
69
- move_down 25
70
- end
62
+ fill_color(dark_gray)
71
63
 
72
- def experience
73
- h2 "experience"
74
- @config.experience&.each do |elem|
75
- h3 elem.job
76
- h4 "#{elem.company} - #{elem.location}"
77
- h4 elem.date
78
- move_down 5
79
- paragaph elem.description
80
- move_down 14
64
+ config["contact"]&.each do |k,v|
65
+ line_pointer -= 10
66
+ text_box("<color rgb='#{black}'>#{k.capitalize}:</color> #{v}", size: 8, at: [240, line_pointer], align: :right, inline_format: true, style: :light)
81
67
  end
82
- end
83
68
 
84
- def education
85
- h2 "education"
86
- @config.education&.each do |elem|
87
- h3 elem.subject
88
- h4 elem.institution
89
- h4 elem.date
90
- move_down 14
91
- end
69
+ fill_color(black)
70
+ move_down(20)
92
71
  end
93
72
 
94
- private
73
+ def intro
74
+ text_box(DateTime.now.strftime("%d.%m.%Y"), at: [0, cursor], align: :right, size: 7)
75
+ text(config.dig("intro", "receiver", "name")&.upcase, size: 7, color: black)
76
+ text(config.dig("intro", "receiver", "position")&.upcase, size: 7, color: dark_gray)
95
77
 
96
- # Set fonts
97
- #
98
- # Font of document can be customized over config file.
99
- # TODO: check if file exists, when path given over config file and do proper
100
- # error handling
78
+ move_down(30)
79
+ text(config.dig("intro", "text"), size: 9, color: dark_gray, style: :light)
101
80
 
102
- def default_font_files
103
- {
104
- light: @config.font&.light || File.join("lib", "font", "Lato-Light.ttf"),
105
- normal: @config.font&.normal || File.join("lib", "font", "Lato-Medium.ttf"),
106
- bold: @config.font&.bold || File.join("lib", "font", "Lato-Bold.ttf")
107
- }
81
+ # move_down(20)
82
+ # stroke_color(light_gray)
83
+ # line_width(0.5)
84
+ # line([0, cursor], [523, cursor])
85
+ # stroke
86
+ # move_down(30)
108
87
  end
109
88
 
110
- def h1 title
111
- text title&.upcase, style: :bold, size: 22, leading: 5
112
- line_width(0.5)
113
- stroke_color "000000"
114
- horizontal_rule
115
- move_down 10
116
- end
89
+ def experience
90
+ h2("work experience")
91
+ last_cursor = start_cursor = cursor
92
+
93
+ config["experience"]&.each do |elem|
94
+ bounding_box([0, last_cursor], width: 523) do
95
+ bounding_box([15, 0], width: 165) do
96
+ fill_color(light_gray)
97
+ stroke_color("ffffff")
98
+ text_box("•", at: [-19, cursor+2], size: 13, color: light_gray, mode: :fill_stroke)
99
+ fill_color(black)
100
+ text(elem["company"], size: 9, style: :light)
101
+ text(elem["date"], size: 7.5, color: dark_gray, style: :light)
102
+ end
117
103
 
118
- def h2 title
119
- text title&.upcase, style: :normal, size: 12, leading: 5
120
- line_width(2)
121
- stroke_color "000000"
122
- horizontal_rule
123
- move_down 15
124
- stroke
125
- end
104
+ bounding_box([180, bounds.top], width: 353, background_color: light_gray) do
105
+ text(elem["job"], size: 9, leading: 7)
126
106
 
127
- def h3 title
128
- text title, style: :bold, size: 11
129
- end
107
+ elem["description_list"]&.each do |item|
108
+ text_box("•", at: [0, cursor], size: 8, color: dark_gray)
109
+ indent(10) { text(item, size: 8, color: dark_gray, style: :light) }
110
+ end
130
111
 
131
- def h4 title
132
- text title, style: :normal, size: 9
133
- end
112
+ move_down(10)
113
+ last_cursor -= bounds.top
114
+ end
115
+ end
116
+ end
117
+
118
+ end_cursor = cursor
119
+ stroke_color(light_gray)
120
+ line_width(0.5)
121
+ line([0, start_cursor + 5], [0, end_cursor + 10])
122
+ stroke
134
123
 
135
- def paragaph text
136
- text text, style: :normal, size: 9, color: "515151"
124
+ move_down(10)
125
+ stroke_color(light_gray)
126
+ line_width(0.5)
127
+ line([0, cursor], [523, cursor])
128
+ stroke
129
+ move_down(20)
137
130
  end
138
131
 
139
- def contact_table
140
- line_width(1)
141
- stroke_color "c6c6c6"
132
+ def education
133
+ h2("education")
134
+ start_cursor = cursor
135
+
136
+ config["education"]&.each_with_index do |elem, index|
137
+ bounding_box([12 + (index * 180), start_cursor], width: 180) do
138
+ text(elem["subject"], size: 9)
139
+ text(elem["institution"], size: 9, style: :light)
140
+ text(elem["date"], size: 7.5, color: dark_gray, style: :light)
141
+ move_down(10)
142
+ end
142
143
 
143
- @config.contact&.each_with_index do |elem, index|
144
- icon, value = elem
144
+ stroke_color(black)
145
+ line_width(3)
146
+ line([index * 180, start_cursor], [index * 180, cursor + 10])
147
+ stroke
148
+ end
145
149
 
146
- path = path = File.join(File.expand_path(File.dirname(__FILE__)), "..", "icons", "#{icon}.svg")
147
- if File.exist?(path)
148
- File.open(path, "r") do |icon|
149
- svg icon.read, svg_fit(icon.read, 10, 10)
150
- end
150
+ move_down(20)
151
+ stroke_color(light_gray)
152
+ line_width(0.5)
153
+ line([0, cursor], [523, cursor])
154
+ stroke
155
+ move_down(20)
156
+ end
151
157
 
152
- line 20, cursor+10, 20, cursor
153
- stroke
158
+ def certification
159
+ h2("certification")
160
+ last_cursor = start_cursor = cursor
154
161
 
155
- move_up 10
162
+ config["certification"]&.each do |elem|
163
+ bounding_box([15, cursor], width: 523) do
164
+ text(elem["subject"], size: 9)
165
+ text(elem["institution"], size: 9, style: :light)
166
+ text(elem["date"], size: 7.5, color: dark_gray, style: :light)
167
+ move_down(20)
156
168
  end
157
169
 
158
- text value, style: :normal, size: 9, align: :right, width: 170, leading: 9
159
-
160
- if index+1 < @config.contact.count
161
- horizontal_line 0, 170, at: cursor+5
162
- stroke
163
- end
170
+ stroke_color(black)
171
+ line_width(3)
172
+ line([2, start_cursor], [2, cursor + 20])
173
+ stroke
164
174
  end
165
175
  end
166
176
 
167
- def skill_table
168
- move_down 5
169
- line_width(3)
170
-
171
- @config.skills&.each do |skill, value|
172
- text skill || " ", size: 9, leading: 5
177
+ private
173
178
 
174
- if value
175
- stroke_color "c6c6c6"
176
- horizontal_line 110, 170, at: cursor+11
177
- stroke
179
+ def default_font_files
180
+ {
181
+ light: File.join("lib", "font", "Lato-Light.ttf"),
182
+ normal: File.join("lib", "font", "Lato-Medium.ttf"),
183
+ bold: File.join("lib", "font", "Lato-Bold.ttf")
184
+ }
185
+ end
178
186
 
179
- stroke_color "000000"
180
- horizontal_line 110, 110+(60*value/100), at: cursor+11
181
- stroke
182
- end
183
- end
187
+ def h2(title)
188
+ text(title&.upcase, style: :bold, size: 10, leading: 7, character_spacing: 1.9)
189
+ line_width(1)
190
+ stroke_color("000000")
191
+ line([0, cursor], [35, cursor])
192
+ move_down(15)
193
+ stroke
194
+ move_down(10)
184
195
  end
185
196
 
186
197
  # Shrink svg images
@@ -201,5 +212,11 @@ module SimpleCV
201
212
  end
202
213
  end
203
214
 
215
+ def print_current_bounds
216
+ text("top: #{bounds.top}")
217
+ text("left: #{bounds.left}")
218
+ text("right: #{bounds.right}")
219
+ text("bottom: #{bounds.bottom}")
220
+ end
204
221
  end
205
222
  end
@@ -1,3 +1,3 @@
1
1
  module SimpleCV
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.1"
3
3
  end
data/lib/simple_cv.rb CHANGED
@@ -1,5 +1,10 @@
1
- require "simple_cv/version"
2
- require "simple_cv/basic"
1
+ # frozen_string_literal: true
2
+
3
+ require "prawn"
4
+ require "prawn/table"
5
+
6
+ require "lib/simple_cv/version"
7
+ require "lib/simple_cv/basic"
3
8
 
4
9
  module SimpleCV
5
10
  end
data/simple_cv.gemspec CHANGED
@@ -1,26 +1,20 @@
1
1
  # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'simple_cv/version'
2
+
3
+ $LOAD_PATH.unshift(".")
4
+
5
+ require "lib/simple_cv/version"
5
6
 
6
7
  Gem::Specification.new do |spec|
7
8
  spec.name = "simple_cv"
8
9
  spec.version = SimpleCV::VERSION
9
10
  spec.authors = ["Frederic Walch"]
10
- spec.email = ["fredericwalch@me.com"]
11
+ spec.email = ["github@frederic.tech"]
11
12
 
12
13
  spec.summary = %q{This Gem helps you to generate a awesome CV!}
13
14
  spec.homepage = "https://github.com/freder1c"
14
15
  spec.license = "MIT"
15
16
 
16
- # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
- # to allow pushing to a single host or delete this section to allow pushing to any host.
18
- # if spec.respond_to?(:metadata)
19
- # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
20
- # else
21
- # raise "RubyGems 2.0 or newer is required to protect against " \
22
- # "public gem pushes."
23
- # end
17
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
24
18
 
25
19
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
26
20
  f.match(%r{^(test|spec|features)/})
@@ -29,13 +23,12 @@ Gem::Specification.new do |spec|
29
23
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
24
  spec.require_paths = ["lib"]
31
25
 
32
- spec.add_dependency "prawn", "2.2.2"
33
- spec.add_dependency "prawn-svg", "0.27.1"
34
- spec.add_dependency "hashugar", "1.0.1"
26
+ spec.add_dependency "prawn"
27
+ spec.add_dependency "prawn-table"
35
28
 
36
- spec.add_development_dependency "bundler", "~> 1.14"
37
- spec.add_development_dependency "rake", "~> 10.0"
38
- spec.add_development_dependency "rspec", "~> 3.0"
29
+ spec.add_development_dependency "bundler"
30
+ spec.add_development_dependency "rake"
31
+ spec.add_development_dependency "rspec"
39
32
 
40
33
  spec.add_development_dependency "pry"
41
34
  spec.add_development_dependency "pry-nav"
metadata CHANGED
@@ -1,99 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_cv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frederic Walch
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-09-29 00:00:00.000000000 Z
11
+ date: 2023-12-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prawn
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '='
18
- - !ruby/object:Gem::Version
19
- version: 2.2.2
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - '='
25
- - !ruby/object:Gem::Version
26
- version: 2.2.2
27
- - !ruby/object:Gem::Dependency
28
- name: prawn-svg
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - '='
17
+ - - ">="
32
18
  - !ruby/object:Gem::Version
33
- version: 0.27.1
19
+ version: '0'
34
20
  type: :runtime
35
21
  prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
- - - '='
24
+ - - ">="
39
25
  - !ruby/object:Gem::Version
40
- version: 0.27.1
26
+ version: '0'
41
27
  - !ruby/object:Gem::Dependency
42
- name: hashugar
28
+ name: prawn-table
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
- - - '='
31
+ - - ">="
46
32
  - !ruby/object:Gem::Version
47
- version: 1.0.1
33
+ version: '0'
48
34
  type: :runtime
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
- - - '='
38
+ - - ">="
53
39
  - !ruby/object:Gem::Version
54
- version: 1.0.1
40
+ version: '0'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: bundler
57
43
  requirement: !ruby/object:Gem::Requirement
58
44
  requirements:
59
- - - "~>"
45
+ - - ">="
60
46
  - !ruby/object:Gem::Version
61
- version: '1.14'
47
+ version: '0'
62
48
  type: :development
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
- - - "~>"
52
+ - - ">="
67
53
  - !ruby/object:Gem::Version
68
- version: '1.14'
54
+ version: '0'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: rake
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
- - - "~>"
59
+ - - ">="
74
60
  - !ruby/object:Gem::Version
75
- version: '10.0'
61
+ version: '0'
76
62
  type: :development
77
63
  prerelease: false
78
64
  version_requirements: !ruby/object:Gem::Requirement
79
65
  requirements:
80
- - - "~>"
66
+ - - ">="
81
67
  - !ruby/object:Gem::Version
82
- version: '10.0'
68
+ version: '0'
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: rspec
85
71
  requirement: !ruby/object:Gem::Requirement
86
72
  requirements:
87
- - - "~>"
73
+ - - ">="
88
74
  - !ruby/object:Gem::Version
89
- version: '3.0'
75
+ version: '0'
90
76
  type: :development
91
77
  prerelease: false
92
78
  version_requirements: !ruby/object:Gem::Requirement
93
79
  requirements:
94
- - - "~>"
80
+ - - ">="
95
81
  - !ruby/object:Gem::Version
96
- version: '3.0'
82
+ version: '0'
97
83
  - !ruby/object:Gem::Dependency
98
84
  name: pry
99
85
  requirement: !ruby/object:Gem::Requirement
@@ -124,31 +110,21 @@ dependencies:
124
110
  version: '0'
125
111
  description:
126
112
  email:
127
- - fredericwalch@me.com
113
+ - github@frederic.tech
128
114
  executables: []
129
115
  extensions: []
130
116
  extra_rdoc_files: []
131
117
  files:
132
- - ".gitignore"
133
118
  - ".rspec"
134
119
  - Gemfile
135
- - LICENSE.txt
136
- - README.md
120
+ - Gemfile.lock
137
121
  - Rakefile
138
- - SimleCV.pdf
139
- - bin/console
140
- - bin/setup
141
- - circle.yml
142
122
  - examples/example.json
143
123
  - examples/example.yml
144
124
  - lib/font/Lato-Bold.ttf
145
125
  - lib/font/Lato-Light.ttf
146
126
  - lib/font/Lato-Medium.ttf
147
127
  - lib/font/SIL Open Font License.txt
148
- - lib/icons/address.svg
149
- - lib/icons/email.svg
150
- - lib/icons/phone.svg
151
- - lib/icons/website.svg
152
128
  - lib/simple_cv.rb
153
129
  - lib/simple_cv/basic.rb
154
130
  - lib/simple_cv/layout.rb
@@ -157,7 +133,8 @@ files:
157
133
  homepage: https://github.com/freder1c
158
134
  licenses:
159
135
  - MIT
160
- metadata: {}
136
+ metadata:
137
+ allowed_push_host: https://rubygems.org
161
138
  post_install_message:
162
139
  rdoc_options: []
163
140
  require_paths:
@@ -173,8 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
173
150
  - !ruby/object:Gem::Version
174
151
  version: '0'
175
152
  requirements: []
176
- rubyforge_project:
177
- rubygems_version: 2.6.11
153
+ rubygems_version: 3.0.3.1
178
154
  signing_key:
179
155
  specification_version: 4
180
156
  summary: This Gem helps you to generate a awesome CV!
data/.gitignore DELETED
@@ -1,15 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
-
11
- # rspec failure tracking
12
- .rspec_status
13
-
14
- # OS Artifacts
15
- .DS_Store
data/LICENSE.txt DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2017 TODO: Write your name
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
data/README.md DELETED
@@ -1,54 +0,0 @@
1
- # SimpleCV
2
-
3
- SimpleCV creates beautiful CVs simple and fast with just a config file! Example configuration files can be found in examples folder.
4
-
5
- ## Installation
6
-
7
- Add this line to your application's Gemfile:
8
-
9
- ```ruby
10
- gem 'simple_cv'
11
- ```
12
-
13
- And then execute:
14
-
15
- $ bundle
16
-
17
- Or install it yourself as:
18
-
19
- $ gem install simple_cv
20
-
21
- ## Usage
22
-
23
- ```ruby
24
- cv = SimpleCV::Basic.new(config_path: "path/to/config_file.json")
25
-
26
- # Will render file to current location
27
- cv.render_file
28
-
29
- # Will render file to a specific location with a specific filename
30
- cv.render_file(path: "path/to/output", filename: "file")
31
- ```
32
-
33
- ## Development
34
-
35
- Further planned functionalities:
36
-
37
- - Dynamin layout calculations depending on content for better look
38
- - More icons for contact topics
39
- - Dynamic calculation for size of skill bars depending on skill name lengths
40
- - Display page count, when experience / education section reaches second page
41
- - Different layout templates
42
-
43
- ## Contributing
44
-
45
- Bug reports and pull requests are welcome on GitHub at [https://github.com/freder1c/simple_cv](https://github.com/freder1c/simple_cv).
46
-
47
- ## License
48
-
49
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
50
-
51
- Mail Icon made by [Freepik](http://www.freepik.com) from [www.flaticon.com](www.flaticon.com)
52
- Location Icon made by [Freepik](http://www.freepik.com) from [www.flaticon.com](www.flaticon.com)
53
- Globe made by [Designerz Base](http://www.finest.graphics) from [www.flaticon.com](www.flaticon.com)
54
- Phone made by [Freepik](http://www.freepik.com) from [www.flaticon.com](www.flaticon.com)