resulang 0.0.1 → 1.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 +5 -5
- data/.ruby-version +1 -1
- data/README.md +15 -10
- data/examples/my_resume/resume.html +9 -20
- data/examples/my_resume/resume.rb +46 -0
- data/examples/my_resume/server.ru +2 -2
- data/lib/resulang/app.rb +3 -16
- data/lib/resulang/dsl.rb +20 -19
- data/lib/resulang/exec.rb +15 -13
- data/lib/resulang/resume.rb +16 -1
- data/lib/resulang/section.rb +4 -5
- data/lib/resulang/server.rb +1 -1
- data/lib/resulang/version.rb +1 -1
- data/resulang.gemspec +3 -3
- metadata +10 -15
- data/examples/my_resume/data/resume.rb +0 -25
- data/examples/my_resume/data/sections/background.rb +0 -4
- data/examples/my_resume/data/sections/hobbies.rb +0 -3
- data/examples/my_resume/data/sections/personal.rb +0 -5
- data/examples/my_resume/data/sections/skills.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e9f8ee4aa6b963ea749c10954d042c71f2099c9b7ad9267921ce99099223ba0c
|
4
|
+
data.tar.gz: 54cd1b85136bd67d37de5ad8c7b9ab222ca3341bd937e1d5e543ab0b8113a73d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa6c3890faa19934257f5547c40564c5a44c0efb22c8cb49034d499be7ca8893aa36efbd69009685cf418423b71411bb1bd272a823aa43781f53e89d4a475ec5
|
7
|
+
data.tar.gz: b16d1895f0b89839d5bda160952006c77e9b50f5d2e27b4064c576cd11d59469c6cd7d2a5d75577f55065a135e907890da4246f5ee658b866c9fbdb30973956a
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2.7.1
|
data/README.md
CHANGED
@@ -5,7 +5,7 @@ create other kinds of documents with structured data. It works by separating
|
|
5
5
|
the data from the html template, which means the data could theoretically be
|
6
6
|
used to generate other kinds of output in the future, not just html.
|
7
7
|
|
8
|
-
## TODO: write tests
|
8
|
+
## TODO: write tests
|
9
9
|
|
10
10
|
## Installation
|
11
11
|
|
@@ -21,15 +21,16 @@ resulang new my_resume
|
|
21
21
|
This will generate the basic structure of a resulang app as well as a few key files:
|
22
22
|
|
23
23
|
* `my_resume/data/resume.rb`
|
24
|
-
|
25
|
-
This is where you define your resume.
|
24
|
+
|
25
|
+
This is where you define your resume.
|
26
26
|
|
27
27
|
* `my_resume/templates/resume.html.erb`
|
28
28
|
|
29
|
-
This is where you write your resume html which has access to the data in
|
29
|
+
This is where you write your resume html which has access to the data in
|
30
|
+
my_resume/data/resume.rb
|
30
31
|
|
31
32
|
|
32
|
-
|
33
|
+
A resume is broken into named sections. For example:
|
33
34
|
```ruby
|
34
35
|
personal do
|
35
36
|
name 'Peter Brindisi'
|
@@ -84,7 +85,8 @@ A template for the above data might look like this:
|
|
84
85
|
|
85
86
|
`render_section(:section_name)` looks for a template partial named
|
86
87
|
`my_resume/templates/_section_name.html.erb`. A partial has direct access to
|
87
|
-
the data within the data section. For example, the partial for the "personal"
|
88
|
+
the data within the data section. For example, the partial for the "personal"
|
89
|
+
and "hobbies" sections might look like:
|
88
90
|
|
89
91
|
```html
|
90
92
|
<!-- my_resume/templates/_personal.html.erb -->
|
@@ -125,14 +127,18 @@ class Hobbies < Resulang::Section
|
|
125
127
|
end
|
126
128
|
```
|
127
129
|
|
128
|
-
To easily view changes to the resume as you make them, you can run a local
|
130
|
+
To easily view changes to the resume as you make them, you can run a local
|
131
|
+
server with:
|
129
132
|
```sh
|
130
133
|
resulang server
|
131
134
|
```
|
132
135
|
|
133
|
-
However, if you make any changes to the classes in `my_resume/data/sections`
|
136
|
+
However, if you make any changes to the classes in `my_resume/data/sections`
|
137
|
+
you must restart the server.
|
134
138
|
|
135
|
-
You can put assets like images and stylesheets in directories off `my_resume`,
|
139
|
+
You can put assets like images and stylesheets in directories off `my_resume`,
|
140
|
+
like `css` and `images` or `assets/css` and `assets/images`. These can be
|
141
|
+
referenced in `resume.html.erb`.
|
136
142
|
|
137
143
|
To generate a static html page, run:
|
138
144
|
```sh
|
@@ -142,4 +148,3 @@ resulang make
|
|
142
148
|
This will output `./resume.html`
|
143
149
|
|
144
150
|
Please see the `exmaples` directory of this project for a working example.
|
145
|
-
|
@@ -6,33 +6,22 @@
|
|
6
6
|
<body>
|
7
7
|
<div class="section">
|
8
8
|
<div>Name: Peter Brindisi</div>
|
9
|
-
<div>Phone: 555-555-5555</div>
|
10
|
-
<div>Email: superduperprivate@example.com</div>
|
11
|
-
<div><a href="https://github.com/npj" target="_blank">https://github.com/npj</a></div>
|
12
|
-
|
9
|
+
<div>Phone: 555-555-5555</div>
|
10
|
+
<div>Email: superduperprivate@example.com</div>
|
11
|
+
<div><a href="https://github.com/npj" target="_blank">https://github.com/npj</a></div>
|
13
12
|
</div>
|
14
13
|
<div class="section">
|
15
|
-
<div>
|
16
|
-
</div>
|
17
|
-
|
14
|
+
<div>I am a guy that does things. Things are awesome and they are also cool.</div>
|
18
15
|
</div>
|
19
16
|
<div class="section">
|
20
17
|
<div>foo bar baz qux</div>
|
21
|
-
|
22
18
|
</div>
|
23
19
|
<div class="section">
|
24
20
|
<ul>
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
<li>Making beer</li>
|
31
|
-
|
32
|
-
</ul>
|
33
|
-
|
34
|
-
|
21
|
+
<li>Reading about Haskell</li>
|
22
|
+
<li>Evangelizing monads</li>
|
23
|
+
<li>Making beer</li>
|
24
|
+
</ul>
|
35
25
|
</div>
|
36
26
|
</body>
|
37
|
-
</html>
|
38
|
-
|
27
|
+
</html>
|
@@ -0,0 +1,46 @@
|
|
1
|
+
structure do
|
2
|
+
section :personal do
|
3
|
+
string :name, :phone
|
4
|
+
email :email
|
5
|
+
link :github
|
6
|
+
end
|
7
|
+
|
8
|
+
section :background do
|
9
|
+
string :description
|
10
|
+
end
|
11
|
+
|
12
|
+
section :skills do
|
13
|
+
list :things
|
14
|
+
end
|
15
|
+
|
16
|
+
section :hobbies do
|
17
|
+
pointlist :info
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
data do
|
22
|
+
personal do
|
23
|
+
name 'Peter Brindisi'
|
24
|
+
phone '555-555-5555'
|
25
|
+
email 'superduperprivate@example.com'
|
26
|
+
github 'https://github.com/npj'
|
27
|
+
end
|
28
|
+
|
29
|
+
background do
|
30
|
+
description <<-DESCRIPTION
|
31
|
+
I am a guy that does things. Things are awesome and they are also cool.
|
32
|
+
DESCRIPTION
|
33
|
+
end
|
34
|
+
|
35
|
+
skills do
|
36
|
+
things %{foo bar baz qux}
|
37
|
+
end
|
38
|
+
|
39
|
+
hobbies do
|
40
|
+
info do
|
41
|
+
point 'Reading about Haskell'
|
42
|
+
point 'Evangelizing monads'
|
43
|
+
point 'Making beer'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -1,2 +1,2 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require "resulang/server"
|
2
|
+
run Resulang::Server
|
data/lib/resulang/app.rb
CHANGED
@@ -44,32 +44,19 @@ module Resulang
|
|
44
44
|
private
|
45
45
|
|
46
46
|
def load_app
|
47
|
-
unless File.directory?('
|
48
|
-
raise "no Resulang app found at #{path.inspect}"
|
47
|
+
unless File.directory?('templates')
|
48
|
+
raise "no Resulang app found at #{path.inspect}: 'templates' directory not found."
|
49
49
|
end
|
50
50
|
|
51
|
-
load_sections
|
52
51
|
load_resume
|
53
52
|
end
|
54
53
|
|
55
|
-
def load_sections
|
56
|
-
section_paths.each { |section| require section }
|
57
|
-
end
|
58
|
-
|
59
54
|
def load_resume
|
60
55
|
@resume = Resulang::Dsl.new(resume_path).resume
|
61
56
|
end
|
62
57
|
|
63
|
-
def sections_dir
|
64
|
-
File.join(path, 'data', 'sections')
|
65
|
-
end
|
66
|
-
|
67
|
-
def section_paths
|
68
|
-
Dir[File.join(sections_dir, '**', '*.rb')]
|
69
|
-
end
|
70
|
-
|
71
58
|
def resume_path
|
72
|
-
File.join(path, '
|
59
|
+
File.join(path, 'resume.rb')
|
73
60
|
end
|
74
61
|
end
|
75
62
|
end
|
data/lib/resulang/dsl.rb
CHANGED
@@ -1,31 +1,32 @@
|
|
1
1
|
module Resulang
|
2
2
|
class Dsl
|
3
|
-
attr_reader :path
|
4
|
-
|
5
|
-
def self.register_section!(section, klass)
|
6
|
-
define_section_method(section, klass)
|
7
|
-
end
|
3
|
+
attr_reader :path, :resume
|
8
4
|
|
9
5
|
def initialize(path)
|
10
|
-
@
|
11
|
-
@
|
12
|
-
|
13
|
-
|
14
|
-
def resume
|
15
|
-
unless @evaluated
|
16
|
-
instance_eval(File.read(path))
|
17
|
-
@evaluated = true
|
18
|
-
end
|
19
|
-
|
20
|
-
@resume
|
6
|
+
@resume = nil
|
7
|
+
@path = path
|
8
|
+
instance_eval(File.read(path))
|
21
9
|
end
|
22
10
|
|
23
11
|
private
|
24
12
|
|
25
|
-
|
26
|
-
|
27
|
-
|
13
|
+
# defines the sections and their typed fields
|
14
|
+
class Structure
|
15
|
+
def initialize(&block)
|
16
|
+
instance_eval(&block)
|
28
17
|
end
|
18
|
+
|
19
|
+
def section(name, &block)
|
20
|
+
Resume.declare_section!(name, &block)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def structure(&block)
|
25
|
+
Structure.new(&block)
|
26
|
+
end
|
27
|
+
|
28
|
+
def data(&block)
|
29
|
+
@resume = Resume.new(&block)
|
29
30
|
end
|
30
31
|
end
|
31
32
|
end
|
data/lib/resulang/exec.rb
CHANGED
@@ -11,24 +11,26 @@ module Resulang
|
|
11
11
|
empty_directory(name)
|
12
12
|
inside(name) do
|
13
13
|
create_file "server.ru" do
|
14
|
-
|
15
|
-
require "resulang/server"
|
16
|
-
run Resulang::Server
|
17
|
-
|
14
|
+
contents = [
|
15
|
+
%Q{require "resulang/server"},
|
16
|
+
%Q{run Resulang::Server}
|
17
|
+
]
|
18
|
+
contents.join("\n")
|
18
19
|
end
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
options[:sections].inject([]) { |list, s| list.push("#{s} do\n\nend") }.join("\n\n")
|
21
|
+
create_file('resume.rb') do
|
22
|
+
declarations = options[:sections].inject([]) do |list, s|
|
23
|
+
list.push("section(:#{s}) do\n\n end")
|
24
24
|
end
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
options[:sections].each do |s|
|
29
|
-
create_file("#{s}.rb", "class #{ActiveSupport::Inflector.camelize(s)} < Resulang::Section\n\nend")
|
30
|
-
end
|
26
|
+
sections = options[:sections].inject([]) do |list, s|
|
27
|
+
list.push("#{s} do\n\n end")
|
31
28
|
end
|
29
|
+
|
30
|
+
structure = "structure do\n " + declarations.join(" \n\n ") + "\nend"
|
31
|
+
data = "data do\n " + sections.join(" \n\n ") + "\nend"
|
32
|
+
|
33
|
+
structure + "\n\n" + data
|
32
34
|
end
|
33
35
|
|
34
36
|
empty_directory 'templates'
|
data/lib/resulang/resume.rb
CHANGED
@@ -1,8 +1,23 @@
|
|
1
1
|
module Resulang
|
2
2
|
class Resume
|
3
|
+
@@declared_sections = { }
|
4
|
+
|
3
5
|
attr_reader :sections
|
4
|
-
|
6
|
+
|
7
|
+
def initialize(&block)
|
5
8
|
@sections = { }
|
9
|
+
instance_eval(&block)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.declare_section!(name, &declaration_block)
|
13
|
+
@@declared_sections[name] = Class.new(Section, &declaration_block)
|
14
|
+
|
15
|
+
define_method(name) do |&instance_block|
|
16
|
+
unless @@declared_sections[name]
|
17
|
+
raise "Section \"#{name}\" not found"
|
18
|
+
end
|
19
|
+
@sections[name] = @@declared_sections[name].new(name: name, &instance_block)
|
20
|
+
end
|
6
21
|
end
|
7
22
|
end
|
8
23
|
end
|
data/lib/resulang/section.rb
CHANGED
@@ -2,14 +2,13 @@ require 'active_support/inflector'
|
|
2
2
|
|
3
3
|
module Resulang
|
4
4
|
class Section
|
5
|
+
attr_reader :name
|
6
|
+
|
5
7
|
include Fields
|
6
8
|
include Rendering
|
7
9
|
|
8
|
-
def
|
9
|
-
|
10
|
-
end
|
11
|
-
|
12
|
-
def initialize(&block)
|
10
|
+
def initialize(name:, &block)
|
11
|
+
@name = name
|
13
12
|
instance_eval(&block)
|
14
13
|
end
|
15
14
|
|
data/lib/resulang/server.rb
CHANGED
data/lib/resulang/version.rb
CHANGED
data/resulang.gemspec
CHANGED
@@ -19,10 +19,10 @@ Gem::Specification.new do |spec|
|
|
19
19
|
|
20
20
|
spec.add_dependency "thor", "~> 0.19.1"
|
21
21
|
spec.add_dependency "activesupport", "~> 4.2.6"
|
22
|
-
spec.add_dependency "rack", "~> 1.
|
22
|
+
spec.add_dependency "rack", "~> 2.1.4"
|
23
23
|
spec.add_dependency "mime-types", "~> 3.0"
|
24
24
|
|
25
|
-
spec.add_development_dependency "bundler", "~> 1.
|
26
|
-
spec.add_development_dependency "rake", "~>
|
25
|
+
spec.add_development_dependency "bundler", "~> 2.1.4"
|
26
|
+
spec.add_development_dependency "rake", "~> 12.3.3"
|
27
27
|
spec.add_development_dependency "rspec", "~> 3.4.0"
|
28
28
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resulang
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Brindisi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 1.
|
47
|
+
version: 2.1.4
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.
|
54
|
+
version: 2.1.4
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: mime-types
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,28 +72,28 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 2.1.4
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 2.1.4
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rake
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 12.3.3
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: 12.3.3
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: rspec
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -125,12 +125,8 @@ files:
|
|
125
125
|
- Rakefile
|
126
126
|
- bin/resulang
|
127
127
|
- examples/my_resume/assets/css/style.css
|
128
|
-
- examples/my_resume/data/resume.rb
|
129
|
-
- examples/my_resume/data/sections/background.rb
|
130
|
-
- examples/my_resume/data/sections/hobbies.rb
|
131
|
-
- examples/my_resume/data/sections/personal.rb
|
132
|
-
- examples/my_resume/data/sections/skills.rb
|
133
128
|
- examples/my_resume/resume.html
|
129
|
+
- examples/my_resume/resume.rb
|
134
130
|
- examples/my_resume/server.ru
|
135
131
|
- examples/my_resume/templates/_background.html.erb
|
136
132
|
- examples/my_resume/templates/_hobbies.html.erb
|
@@ -168,8 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
164
|
- !ruby/object:Gem::Version
|
169
165
|
version: '0'
|
170
166
|
requirements: []
|
171
|
-
|
172
|
-
rubygems_version: 2.4.6
|
167
|
+
rubygems_version: 3.1.2
|
173
168
|
signing_key:
|
174
169
|
specification_version: 4
|
175
170
|
summary: Resulang is a simple DSL to help create html resumes.
|
@@ -1,25 +0,0 @@
|
|
1
|
-
personal do
|
2
|
-
name 'Peter Brindisi'
|
3
|
-
phone '555-555-5555'
|
4
|
-
email 'superduperprivate@example.com'
|
5
|
-
github 'https://github.com/npj'
|
6
|
-
end
|
7
|
-
|
8
|
-
background do
|
9
|
-
description <<-DESCRIPTION
|
10
|
-
I am a guy that does things. Things are awesome and they are also cool.
|
11
|
-
DESCRIPTION
|
12
|
-
end
|
13
|
-
|
14
|
-
skills do
|
15
|
-
things %{foo bar baz qux}
|
16
|
-
end
|
17
|
-
|
18
|
-
hobbies do
|
19
|
-
info do
|
20
|
-
point 'Reading about Haskell'
|
21
|
-
point 'Evangelizing monads'
|
22
|
-
point 'Making beer'
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|