resme 1.0.1 → 2.0.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.
- checksums.yaml +4 -4
- data/CHANGELOG.org +15 -0
- data/CODE_OF_CONDUCT.org +16 -0
- data/LICENSE.txt +1 -1
- data/README.org +19 -129
- data/Rakefile +11 -1
- data/TAGS +83 -0
- data/exe/resme +2 -2
- data/lib/resme/cli.rb +80 -0
- data/lib/resme/document.rb +37 -0
- data/lib/resme/document_validator.rb +308 -0
- data/lib/resme/executor.rb +90 -0
- data/lib/resme/helper.rb +211 -0
- data/lib/resme/json_resume.rb +156 -0
- data/lib/resme/version.rb +1 -2
- data/lib/resme.rb +20 -5
- data/sig/resme.rbs +4 -0
- data/templates/json.erb +1 -0
- data/templates/org.erb +217 -0
- data/{lib/resme/templates → templates}/resume.yml +38 -33
- metadata +22 -53
- data/.gitignore +0 -8
- data/Gemfile +0 -6
- data/Gemfile.lock +0 -20
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/lib/resme/cli/command_semantics.rb +0 -198
- data/lib/resme/cli/command_syntax.rb +0 -282
- data/lib/resme/cli/resume_structure_validator.rb +0 -293
- data/lib/resme/renderer/renderer.rb +0 -134
- data/lib/resme/templates/resume.json.erb +0 -155
- data/lib/resme/templates/resume.md.erb +0 -160
- data/lib/resme/templates/resume.org.erb +0 -205
- data/resme.gemspec +0 -34
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fc8089fb6322bfe0ad1563829fc2561a2bdb764efe06915ff5a3778b765d24fd
|
|
4
|
+
data.tar.gz: 8a9555ec7df7bd51b12ff20fd826b5c2e75fd83f36f33fcb61163d17a324424e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 60d455fbb2943111933b3ace506bd01e2beb1a594dd0095098250b8ff010be69ab07b8233a9c7c96d635bc96c3ea8779a80280922f5b2db8ddcf4149651b0547
|
|
7
|
+
data.tar.gz: 16f09e4d698179c59a25acc5e6894bd6632a431dfd46d84516455142f5ddf149ced3ef0cc22cf12303f1659532e5cc340d1f513eb287e3db1787fcf19fb54790
|
data/CHANGELOG.org
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
#+TITLE: CHANGELOG
|
|
2
2
|
#+AUTHOR: Adolfo Villafiorita
|
|
3
3
|
|
|
4
|
+
* Version 2.0.0
|
|
5
|
+
|
|
6
|
+
- Fully rewritten code
|
|
7
|
+
- Removed export to Markdown (which can be gotten from Org Mode)
|
|
8
|
+
- Fixed JSON Resume export
|
|
9
|
+
- Added new keys and renamed some existing keys to make them closer to JSON Resume.
|
|
10
|
+
- added url in education section
|
|
11
|
+
- added country_code and region to addresses
|
|
12
|
+
- renamed who -> name (in projects: stakeholder)
|
|
13
|
+
- renamed role -> position
|
|
14
|
+
- renamed from -> start_date
|
|
15
|
+
- renamed to -> end_date
|
|
16
|
+
- renamed website -> url
|
|
17
|
+
|
|
18
|
+
|
|
4
19
|
* Version 1.0.1
|
|
5
20
|
|
|
6
21
|
- Documentation updated
|
data/CODE_OF_CONDUCT.org
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#+TITLE: Code of Conduct
|
|
2
|
+
|
|
3
|
+
"resme" follows [[https://www.ruby-lang.org/en/conduct][The Ruby Community
|
|
4
|
+
Conduct Guideline]] in all "collaborative space", which is defined as community
|
|
5
|
+
communications channels (such as mailing lists, submitted patches, commit
|
|
6
|
+
comments, etc.):
|
|
7
|
+
|
|
8
|
+
- Participants will be tolerant of opposing views.
|
|
9
|
+
- Participants must ensure that their language and actions are free of personal
|
|
10
|
+
attacks and disparaging personal remarks.
|
|
11
|
+
- When interpreting the words and actions of others, participants should always
|
|
12
|
+
assume good intentions.
|
|
13
|
+
- Behaviour which can be reasonably considered harassment will not be tolerated.
|
|
14
|
+
|
|
15
|
+
If you have any concerns about behaviour within this project, please contact us
|
|
16
|
+
at [[mailto:"adolfo@shair.tech"][adolfo@shair.tech]].
|
data/LICENSE.txt
CHANGED
data/README.org
CHANGED
|
@@ -3,20 +3,13 @@
|
|
|
3
3
|
#+DATE: <2020-07-14 Tue>
|
|
4
4
|
#+STARTUP: showall
|
|
5
5
|
|
|
6
|
-
Keep your resume in YAML and output it
|
|
7
|
-
Org Mode
|
|
6
|
+
Keep your resume in YAML and output it Org Mode and JSON Resume formats.
|
|
7
|
+
Org Mode is flexible enough to export to various other formats.
|
|
8
8
|
|
|
9
9
|
The rendering engine is based on ERB. This simplifies the creation of
|
|
10
10
|
new output formats (and extending/modifying the YML structure to one's
|
|
11
11
|
needs).
|
|
12
12
|
|
|
13
|
-
#+BEGIN_QUOTE
|
|
14
|
-
Support for the Europass XML format has been dropped in version 1.0.0, as the
|
|
15
|
-
version generated by resme (Europass schema version 3.3.0) is no longer
|
|
16
|
-
supported by the Europasss website and documentation about the changes to make
|
|
17
|
-
it working again are kind of difficult to retrieve.
|
|
18
|
-
#+END_QUOTE
|
|
19
|
-
|
|
20
13
|
** Installation
|
|
21
14
|
:PROPERTIES:
|
|
22
15
|
:CUSTOM_ID: installation
|
|
@@ -59,42 +52,31 @@ are not relevant for your resume.
|
|
|
59
52
|
You can now generate a resume using one of the existing formats:
|
|
60
53
|
|
|
61
54
|
#+begin_example sh
|
|
62
|
-
resme --
|
|
55
|
+
resme --format org --build resume.yml
|
|
63
56
|
#+end_example
|
|
64
57
|
|
|
65
|
-
Supported formats include:
|
|
66
|
-
|
|
67
|
-
- =org=: Org Mode format
|
|
68
|
-
- =md=: Markdown format
|
|
69
|
-
- =json=: JSON format (https://jsonresume.org/)
|
|
70
|
-
|
|
71
58
|
If you are not satisfied with the provided templates, you can write your own
|
|
72
59
|
(see below).
|
|
73
60
|
|
|
74
|
-
Notice that you can specify more than one YML file in input. This allows you to
|
|
75
|
-
store data about your resume in different files, if you like to do so (e.g.,
|
|
76
|
-
work experiences could be in one file and talks in another). The YML files are
|
|
77
|
-
merged before processing them.
|
|
78
|
-
|
|
79
61
|
Full syntax:
|
|
80
62
|
|
|
81
63
|
#+begin_src sh :results raw output :wrap example
|
|
82
|
-
resme help
|
|
64
|
+
resme --help
|
|
83
65
|
#+end_src
|
|
84
66
|
|
|
85
67
|
#+RESULTS:
|
|
86
68
|
#+begin_example
|
|
87
|
-
resme
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
69
|
+
resme [options] - Format and manage a resume in YAML
|
|
70
|
+
--format FORMAT Output format
|
|
71
|
+
--init Init a new resume
|
|
72
|
+
--validate FILENAME Validate the resume
|
|
73
|
+
--build FILENAME Build the resume in FILENAME
|
|
74
|
+
--sections FILENAME List sections in FILENAME
|
|
75
|
+
--list List available templates
|
|
76
|
+
--except x,y,z Excluded section
|
|
77
|
+
--cat TEMPLATE View a template
|
|
78
|
+
--version
|
|
79
|
+
-h, --help Print this help
|
|
98
80
|
#+end_example
|
|
99
81
|
|
|
100
82
|
** Checking validity
|
|
@@ -102,11 +84,11 @@ Available commands:
|
|
|
102
84
|
:CUSTOM_ID: checking-validity
|
|
103
85
|
:END:
|
|
104
86
|
|
|
105
|
-
Use the =
|
|
87
|
+
Use the =--validate= option to verify whether your YAML file conforms with
|
|
106
88
|
the intended syntax.
|
|
107
89
|
|
|
108
90
|
#+begin_example sh
|
|
109
|
-
resme
|
|
91
|
+
resme --validate resume.yaml
|
|
110
92
|
#+end_example
|
|
111
93
|
|
|
112
94
|
** Dates in the resume
|
|
@@ -124,79 +106,6 @@ Enter dates in the resume in one of the following formats:
|
|
|
124
106
|
The third and the forth format allows you to enter "partial" dates
|
|
125
107
|
(e.g., when the month or the day have been forgotten or are irrelevant).
|
|
126
108
|
|
|
127
|
-
** Creating your own templates
|
|
128
|
-
:PROPERTIES:
|
|
129
|
-
:CUSTOM_ID: creating-your-own-templates
|
|
130
|
-
:END:
|
|
131
|
-
|
|
132
|
-
The resumes are generated from the YML matter using ERB templates. The
|
|
133
|
-
provided output formats should support different back ends. Org Mode
|
|
134
|
-
and Markdown, for instance, easily allow for generation of PDFs, HTML,
|
|
135
|
-
and ODT, to mention a few.
|
|
136
|
-
|
|
137
|
-
However, if you want, you can define your own templates.
|
|
138
|
-
|
|
139
|
-
Use the command =view= to print one of the templates used by =resme=
|
|
140
|
-
and build from that.
|
|
141
|
-
|
|
142
|
-
#+begin_example sh
|
|
143
|
-
resme view --template md
|
|
144
|
-
#+end_example
|
|
145
|
-
|
|
146
|
-
Notice that all the data in the resume is made available in the =data=
|
|
147
|
-
variable. Thus, for instance, the following code snippets generates a
|
|
148
|
-
list of all the work experiences:
|
|
149
|
-
|
|
150
|
-
#+begin_example xml
|
|
151
|
-
<% data["work"] each do |exp| %>
|
|
152
|
-
- <%= exp["who"] %>
|
|
153
|
-
From: <%= exp["from"] %> till: <%= exp["till"] %>
|
|
154
|
-
<% end %>
|
|
155
|
-
#+end_example
|
|
156
|
-
|
|
157
|
-
To specify your own ERB template to build your resume use the option
|
|
158
|
-
=-e= (=--erb=). Thus, for instance:
|
|
159
|
-
|
|
160
|
-
#+begin_example sh
|
|
161
|
-
resme render -e template.md.erb [-o output_filename] file.yaml ...
|
|
162
|
-
#+end_example
|
|
163
|
-
|
|
164
|
-
uses =template.md.erb= to generate the resume.
|
|
165
|
-
|
|
166
|
-
Some functions can be used in the templates to better control the
|
|
167
|
-
output.
|
|
168
|
-
|
|
169
|
-
String manipulation functions:
|
|
170
|
-
|
|
171
|
-
- =clean string= removes any space at the beginning of =string=
|
|
172
|
-
- =reflow string, n= makes =string= into an array of strings of length
|
|
173
|
-
lower or equal to =n= (useful if you are outputting a textual format,
|
|
174
|
-
for instance.
|
|
175
|
-
|
|
176
|
-
Dates manipulation functions:
|
|
177
|
-
|
|
178
|
-
- =period= generates a string recapping a period. The function abstracts
|
|
179
|
-
different syntax you can use for entries (i.e., =date= or =from= and
|
|
180
|
-
=till=) and different values for the entries (e.g., a missing value
|
|
181
|
-
for =till=)
|
|
182
|
-
- =year string=, =month string=, =day string= return, respectively the
|
|
183
|
-
year, month and day from strings in the format =YYYY-MM-DD=s
|
|
184
|
-
- =has_month input= returns true if =input= has a month, that is, it is
|
|
185
|
-
a date or it is in the form =YYYY-MM=
|
|
186
|
-
- =has_day input= returns true if =input= has a day, that is, it is a
|
|
187
|
-
date or it is in the form =YYYY-MM-DD=
|
|
188
|
-
|
|
189
|
-
You can find the templates in =lib/resme/templates=. These might be good
|
|
190
|
-
starting points if you want to develop your own.
|
|
191
|
-
|
|
192
|
-
** Contributing your templates
|
|
193
|
-
:PROPERTIES:
|
|
194
|
-
:CUSTOM_ID: contributing-your-templates
|
|
195
|
-
:END:
|
|
196
|
-
|
|
197
|
-
If you develop an output template and want to make it available, please
|
|
198
|
-
let me know, so that I can include it in future releases of this gem.
|
|
199
|
-
|
|
200
109
|
** Development
|
|
201
110
|
:PROPERTIES:
|
|
202
111
|
:CUSTOM_ID: development
|
|
@@ -225,35 +134,16 @@ https://github.com/avillafiorita/resme.
|
|
|
225
134
|
:CUSTOM_ID: license
|
|
226
135
|
:END:
|
|
227
136
|
|
|
228
|
-
The gem is available as open source under the terms of the [[http://opensource.org/licenses/MIT][MIT License]].
|
|
137
|
+
The gem is available as open source under the terms of the [[http://opensource.org/licenses/MIT.txt][MIT License]].
|
|
229
138
|
|
|
230
139
|
** Change Log
|
|
231
140
|
|
|
232
141
|
In [[file:./CHANGELOG.org][CHANGELOG.org]]
|
|
233
142
|
|
|
234
|
-
** Roadmap
|
|
235
|
-
:PROPERTIES:
|
|
236
|
-
:CUSTOM_ID: roadmap
|
|
237
|
-
:END:
|
|
238
|
-
|
|
239
|
-
In [[file:./doc/todo.org][todo.org]] ... guess what is my preferred editor!
|
|
240
|
-
|
|
241
143
|
** Bugs
|
|
242
144
|
:PROPERTIES:
|
|
243
145
|
:CUSTOM_ID: bugs
|
|
244
146
|
:END:
|
|
245
147
|
|
|
246
|
-
|
|
247
|
-
way in which the information is formatted in various output formats.
|
|
248
|
-
|
|
249
|
-
*Entries are not sorted by date before outputting them. Make sure you
|
|
250
|
-
put them in the order you want them to appear in your resume.*
|
|
251
|
-
|
|
252
|
-
Unknown number of unknown bugs.
|
|
253
|
-
|
|
254
|
-
** Release History
|
|
255
|
-
:PROPERTIES:
|
|
256
|
-
:CUSTOM_ID: release-history
|
|
257
|
-
:END:
|
|
148
|
+
An unknown number of unknown bugs.
|
|
258
149
|
|
|
259
|
-
Moved to [[file:./CHANGELOG.org][CHANGELOG.org]].
|
data/Rakefile
CHANGED
data/TAGS
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
|
|
2
|
+
/home/adolfo/Sources/ruby/resme/lib/resme/document.rb,292
|
|
3
|
+
module ResmeResme3,31
|
|
4
|
+
class DocumentDocument7,88
|
|
5
|
+
attr_reader :filename, :datafilename8,105
|
|
6
|
+
attr_reader :filename, :datadata8,105
|
|
7
|
+
def initialize(filename)initialize10,139
|
|
8
|
+
def dig(*keys)dig16,292
|
|
9
|
+
def fetch(*keys, default)fetch21,422
|
|
10
|
+
def loadload27,502
|
|
11
|
+
|
|
12
|
+
/home/adolfo/Sources/ruby/resme/test/test_helper.rb,0
|
|
13
|
+
|
|
14
|
+
/home/adolfo/Sources/ruby/resme/test/test_resme.rb,200
|
|
15
|
+
class TestResme < Minitest::TestTestResme5,54
|
|
16
|
+
def test_that_it_has_a_version_numbertest_that_it_has_a_version_number6,87
|
|
17
|
+
def test_it_does_something_usefultest_it_does_something_useful10,166
|
|
18
|
+
|
|
19
|
+
/home/adolfo/Sources/ruby/resme/templates/org.erb,0
|
|
20
|
+
|
|
21
|
+
/home/adolfo/Sources/ruby/resme/lib/resme.rb,0
|
|
22
|
+
|
|
23
|
+
/home/adolfo/Sources/ruby/resme/templates/json.erb,0
|
|
24
|
+
|
|
25
|
+
/home/adolfo/Sources/ruby/resme/lib/resme/document_validator.rb,421
|
|
26
|
+
module ResmeResme3,31
|
|
27
|
+
class DocumentValidatorDocumentValidator7,76
|
|
28
|
+
def initialize(document)initialize8,102
|
|
29
|
+
def validatevalidate12,167
|
|
30
|
+
OPTIONAL_STRING = [:optional, String, NilClass]OPTIONAL_STRING32,626
|
|
31
|
+
OPTIONAL_PARTIAL_DATE = [:optional, Date, String, Integer, NilClass]OPTIONAL_PARTIAL_DATE33,678
|
|
32
|
+
PARTIAL_DATE = [Date, String, Integer]PARTIAL_DATE34,751
|
|
33
|
+
SCHEMA = {SCHEMA40,891
|
|
34
|
+
|
|
35
|
+
/home/adolfo/Sources/ruby/resme/lib/resme/helper.rb,990
|
|
36
|
+
module ResmeResme3,31
|
|
37
|
+
module HelperHelper7,87
|
|
38
|
+
def clean(string)clean9,178
|
|
39
|
+
def full_name(data)full_name13,250
|
|
40
|
+
def reflow_a(string, line_break: 78)reflow_a33,855
|
|
41
|
+
def blank?(char)blank?68,2023
|
|
42
|
+
def reflow_s(string, line_break: 75, delimiter: "\n", indent: 3)reflow_s75,2256
|
|
43
|
+
def period(entry, date: :date, from: :start_date, to: :end_date, separator: "--")period100,3229
|
|
44
|
+
def itemize(entry, header: %i[role who address], summary_key: :summary)itemize125,3984
|
|
45
|
+
def propertify(entry, except: %i[summary details], indent: 3)propertify136,4430
|
|
46
|
+
def select(contacts, label: :email)select146,4731
|
|
47
|
+
def format_date(date, format: "%Y-%m-%d")format_date162,5262
|
|
48
|
+
def complete_date(incomplete_date, format: "%Y-%m-%d")complete_date166,5376
|
|
49
|
+
def year(input)year181,5784
|
|
50
|
+
def month(input)month186,5902
|
|
51
|
+
def day(input)day191,6019
|
|
52
|
+
def y?(input)y?196,6161
|
|
53
|
+
def ym?(input)ym?201,6280
|
|
54
|
+
def ymd?(input)ymd?206,6398
|
|
55
|
+
|
|
56
|
+
/home/adolfo/Sources/ruby/resme/lib/resme/json_resume.rb,196
|
|
57
|
+
module ResmeResme3,31
|
|
58
|
+
class JsonResumeJsonResume7,78
|
|
59
|
+
def initialize(document)initialize10,121
|
|
60
|
+
def buildbuild15,214
|
|
61
|
+
def split_highlights(highlights)split_highlights150,4552
|
|
62
|
+
|
|
63
|
+
/home/adolfo/Sources/ruby/resme/lib/resme/version.rb,57
|
|
64
|
+
module ResmeResme3,31
|
|
65
|
+
VERSION = "2.0.0"VERSION4,44
|
|
66
|
+
|
|
67
|
+
/home/adolfo/Sources/ruby/resme/lib/resme/cli.rb,218
|
|
68
|
+
module ResmeResme3,31
|
|
69
|
+
class CliCli7,75
|
|
70
|
+
attr_reader :optionsoptions8,87
|
|
71
|
+
def initialize(arguments)initialize10,113
|
|
72
|
+
def parseparse15,257
|
|
73
|
+
def commandcommand20,332
|
|
74
|
+
def parserparser26,391
|
|
75
|
+
|
|
76
|
+
/home/adolfo/Sources/ruby/resme/lib/resme/executor.rb,294
|
|
77
|
+
module ResmeResme3,31
|
|
78
|
+
class ExecutorExecutor4,44
|
|
79
|
+
def initialize(input)initialize8,124
|
|
80
|
+
def executeexecute14,234
|
|
81
|
+
def output_filename(format)output_filename76,2176
|
|
82
|
+
def backup(filename)backup80,2264
|
|
83
|
+
def backup_and_write(filename, content)backup_and_write85,2405
|
data/exe/resme
CHANGED
data/lib/resme/cli.rb
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Resme
|
|
4
|
+
#
|
|
5
|
+
# Parse command line
|
|
6
|
+
#
|
|
7
|
+
class Cli
|
|
8
|
+
attr_reader :options
|
|
9
|
+
|
|
10
|
+
def initialize(arguments)
|
|
11
|
+
# no arguments is equivalent to --help
|
|
12
|
+
@arguments = arguments == [] ? ["--help"] : arguments
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def parse
|
|
16
|
+
@options = {}
|
|
17
|
+
parser.parse!(@arguments)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def command
|
|
21
|
+
@options[:cmd]
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
private
|
|
25
|
+
|
|
26
|
+
def parser
|
|
27
|
+
OptionParser.new do |parser|
|
|
28
|
+
parser.banner = "resme [options] - Format and manage a resume in YAML"
|
|
29
|
+
|
|
30
|
+
# parser.on("-o", "--output FILENAME", String, "Output filename") do |v|
|
|
31
|
+
# @options[:output] = v
|
|
32
|
+
# end
|
|
33
|
+
|
|
34
|
+
parser.on("--format FORMAT", String, "Output format") do |v|
|
|
35
|
+
@options[:format] = v
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
parser.on("--init", "Init a new resume") do |v|
|
|
39
|
+
@options[:cmd] = :init
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
parser.on("--validate FILENAME", "Validate the resume") do |v|
|
|
43
|
+
@options[:cmd] = :validate
|
|
44
|
+
@options[:filename] = v
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
parser.on("--build FILENAME", "Build the resume in FILENAME") do |v|
|
|
48
|
+
@options[:cmd] = :build
|
|
49
|
+
@options[:filename] = v
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
parser.on("--sections FILENAME", "List sections in FILENAME") do |v|
|
|
53
|
+
@options[:cmd] = :sections
|
|
54
|
+
@options[:filename] = v
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
parser.on("--list", "List available templates") do |v|
|
|
58
|
+
@options[:cmd] = :list
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
parser.on("--except x,y,z", Array, "Excluded section") do |v|
|
|
62
|
+
@options[:except] = v.map { |x| x.to_sym }
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
parser.on("--cat TEMPLATE", "View a template") do |v|
|
|
66
|
+
@options[:cmd] = :cat
|
|
67
|
+
@options[:template] = v
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
parser.on("--version") do |_|
|
|
71
|
+
@options[:cmd] = :version
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
parser.on("-h", "--help", "Print this help") do
|
|
75
|
+
puts parser
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Resme
|
|
4
|
+
#
|
|
5
|
+
# Wrap the YAML data into a class
|
|
6
|
+
#
|
|
7
|
+
class Document
|
|
8
|
+
attr_reader :filename, :data
|
|
9
|
+
|
|
10
|
+
def initialize(filename)
|
|
11
|
+
@filename = filename
|
|
12
|
+
@data = load
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Access values references by *keys. Keys are Symbols or Strings
|
|
16
|
+
def dig(*keys)
|
|
17
|
+
@data.dig keys.map { |x| x.to_s }
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Access values references by *keys. Default to "default"
|
|
21
|
+
def fetch(*keys, default)
|
|
22
|
+
dig(*keys) || default
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
private
|
|
26
|
+
|
|
27
|
+
def load
|
|
28
|
+
begin
|
|
29
|
+
YAML.load_file @filename, permitted_classes: [Date], symbolize_names: true
|
|
30
|
+
rescue Psych::SyntaxError => ex
|
|
31
|
+
puts "#{@filename} has an invalid structure."
|
|
32
|
+
puts ex.message
|
|
33
|
+
exit 1
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|