simple_cv 0.1.0 → 0.2.0

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,205 +0,0 @@
1
- require "prawn"
2
- require "prawn-svg"
3
-
4
- module SimpleCV
5
- class Layout < ::Prawn::Document
6
-
7
- def initialize config:
8
- @config = config
9
-
10
- super({
11
- page_size: "A4",
12
- info: {
13
- Title: @config.title,
14
- Author: @config.author,
15
- Creator: "AwesomeCV",
16
- Producer: "AwesomeCV",
17
- CreationDate: Time.now
18
- }
19
- })
20
-
21
- font_families.update "Default" => default_font_files
22
- font "Default"
23
- stroke_color "000000"
24
- 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
-
33
- def main
34
- bounding_box([0, 770], width: 170) do
35
- job
36
- profile
37
- contact
38
- skills
39
- end
40
-
41
- bounding_box([200, 770], width: 320) do
42
- experience
43
- education
44
- end
45
- end
46
-
47
- def job
48
- h1 @config.profile&.name
49
- text @config.profile&.job, style: :normal, size: 11
50
- 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
-
60
- def contact
61
- h2 "contact"
62
- contact_table
63
- move_down 25
64
- end
65
-
66
- def skills
67
- h2 "skills"
68
- skill_table
69
- move_down 25
70
- end
71
-
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
81
- end
82
- end
83
-
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
92
- end
93
-
94
- private
95
-
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
101
-
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
- }
108
- end
109
-
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
117
-
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
126
-
127
- def h3 title
128
- text title, style: :bold, size: 11
129
- end
130
-
131
- def h4 title
132
- text title, style: :normal, size: 9
133
- end
134
-
135
- def paragaph text
136
- text text, style: :normal, size: 9, color: "515151"
137
- end
138
-
139
- def contact_table
140
- line_width(1)
141
- stroke_color "c6c6c6"
142
-
143
- @config.contact&.each_with_index do |elem, index|
144
- icon, value = elem
145
-
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
151
-
152
- line 20, cursor+10, 20, cursor
153
- stroke
154
-
155
- move_up 10
156
- end
157
-
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
164
- end
165
- end
166
-
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
173
-
174
- if value
175
- stroke_color "c6c6c6"
176
- horizontal_line 110, 170, at: cursor+11
177
- stroke
178
-
179
- stroke_color "000000"
180
- horizontal_line 110, 110+(60*value/100), at: cursor+11
181
- stroke
182
- end
183
- end
184
- end
185
-
186
- # Shrink svg images
187
- #
188
- # Helper method to resize given svg images to a specific width and height range.
189
-
190
- def svg_fit file, width, height
191
- viewBox = file[/(viewBox=)[\-\".0-9 ]*/]
192
- return { height: height } unless viewBox
193
-
194
- metric = viewBox.tr("viewBox=", "").tr("\"", "").split(" ")
195
- scale = metric.third.to_i / metric.fourth.to_i
196
-
197
- if (scale * height) > width
198
- { width: width }
199
- else
200
- { height: height }
201
- end
202
- end
203
-
204
- end
205
- end
@@ -1,3 +0,0 @@
1
- module SimpleCV
2
- VERSION = "0.1.0"
3
- end
data/lib/simple_cv.rb DELETED
@@ -1,5 +0,0 @@
1
- require "simple_cv/version"
2
- require "simple_cv/basic"
3
-
4
- module SimpleCV
5
- end
data/simple_cv.gemspec DELETED
@@ -1,42 +0,0 @@
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'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "simple_cv"
8
- spec.version = SimpleCV::VERSION
9
- spec.authors = ["Frederic Walch"]
10
- spec.email = ["fredericwalch@me.com"]
11
-
12
- spec.summary = %q{This Gem helps you to generate a awesome CV!}
13
- spec.homepage = "https://github.com/freder1c"
14
- spec.license = "MIT"
15
-
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
24
-
25
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
26
- f.match(%r{^(test|spec|features)/})
27
- end
28
- spec.bindir = "exe"
29
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
- spec.require_paths = ["lib"]
31
-
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"
35
-
36
- spec.add_development_dependency "bundler", "~> 1.14"
37
- spec.add_development_dependency "rake", "~> 10.0"
38
- spec.add_development_dependency "rspec", "~> 3.0"
39
-
40
- spec.add_development_dependency "pry"
41
- spec.add_development_dependency "pry-nav"
42
- end