resulang 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/examples/my_resume/resume.rb +27 -6
- data/examples/my_resume/templates/_hobbies.html.erb +2 -2
- data/examples/my_resume/templates/_skills.html.erb +1 -1
- data/examples/my_resume/templates/resume.html.erb +3 -0
- data/lib/resulang/exec.rb +0 -1
- data/lib/resulang/fields.rb +26 -24
- data/lib/resulang/section.rb +0 -2
- data/lib/resulang/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f77e7c4836d3b5579f4ab1389d961a70425894353419b91d4b41927a37581c25
|
4
|
+
data.tar.gz: fdeb85325dc87404c955436154b388445e823ac44c10b044eb53833b513dbb2f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50dd554e11fccd5775d4be9da95aac13baf6e6eea07668d346940ad76ab26a2e3a950e288f974eb515088c53746adc6e01eb4123029eb7e0fb737871d4d3bc7b
|
7
|
+
data.tar.gz: 3ca3093dec8e3873b6986ff8cd073acb8134908a070129bd178a7a1f6229a19675718b14bdb1e063cf3aef332131968893211fa32fadc375f34569107bc8be4d
|
@@ -14,7 +14,13 @@ structure do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
section :hobbies do
|
17
|
-
|
17
|
+
list :points
|
18
|
+
end
|
19
|
+
|
20
|
+
section :other do
|
21
|
+
list :things do
|
22
|
+
string :name, :description
|
23
|
+
end
|
18
24
|
end
|
19
25
|
end
|
20
26
|
|
@@ -33,14 +39,29 @@ data do
|
|
33
39
|
end
|
34
40
|
|
35
41
|
skills do
|
36
|
-
|
42
|
+
thing %{foo bar baz qux}
|
37
43
|
end
|
38
44
|
|
39
45
|
hobbies do
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
46
|
+
point 'Reading about Haskell'
|
47
|
+
point 'Evangelizing monads'
|
48
|
+
point 'Making beer'
|
49
|
+
end
|
50
|
+
|
51
|
+
other do
|
52
|
+
thing do
|
53
|
+
name 'foo'
|
54
|
+
description 'foo desc'
|
55
|
+
end
|
56
|
+
|
57
|
+
thing do
|
58
|
+
name 'bar'
|
59
|
+
description 'bar desc'
|
60
|
+
end
|
61
|
+
|
62
|
+
thing do
|
63
|
+
name 'baz'
|
64
|
+
description 'baz desc'
|
44
65
|
end
|
45
66
|
end
|
46
67
|
end
|
@@ -1 +1 @@
|
|
1
|
-
<div><%= things.join('
|
1
|
+
<div><%= things.join(' // ') %></div>
|
data/lib/resulang/exec.rb
CHANGED
data/lib/resulang/fields.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'active_support/inflector'
|
2
|
+
|
1
3
|
module Resulang
|
2
4
|
module Fields
|
3
5
|
def self.included(base)
|
@@ -10,24 +12,6 @@ module Resulang
|
|
10
12
|
class Link < String
|
11
13
|
end
|
12
14
|
|
13
|
-
class PointList
|
14
|
-
attr_reader :points
|
15
|
-
|
16
|
-
def initialize(string: nil, &block)
|
17
|
-
@string = string
|
18
|
-
@points = [ ]
|
19
|
-
instance_eval(&block) if block
|
20
|
-
end
|
21
|
-
|
22
|
-
def point(string, &block)
|
23
|
-
points.push(PointList.new(string: string, &block))
|
24
|
-
end
|
25
|
-
|
26
|
-
def to_s
|
27
|
-
@string
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
15
|
module ClassMethods
|
32
16
|
protected def string(*attrs)
|
33
17
|
fields(*attrs) { |value| value }
|
@@ -41,18 +25,36 @@ module Resulang
|
|
41
25
|
fields(*attrs) { |value| Link.new(value) }
|
42
26
|
end
|
43
27
|
|
44
|
-
protected def list(*attrs)
|
45
|
-
|
28
|
+
protected def list(*attrs, &item_decl)
|
29
|
+
attrs.each do |name|
|
30
|
+
define_method(name) do |*args, &block|
|
31
|
+
field_get(name)
|
32
|
+
end
|
33
|
+
|
34
|
+
singular = ActiveSupport::Inflector.singularize(name)
|
35
|
+
|
36
|
+
define_method(singular) do |*args, &item_def|
|
37
|
+
if args.empty? && item_def.nil?
|
38
|
+
raise "no arguments or definition block given for list #{singular}"
|
39
|
+
end
|
40
|
+
|
41
|
+
items = field_get(name) || []
|
42
|
+
|
43
|
+
if item_def.nil?
|
44
|
+
args.each { |a| items.push(a) }
|
45
|
+
elsif
|
46
|
+
items.push(Class.new(Section, &item_decl).new(name: name, &item_def))
|
47
|
+
end
|
48
|
+
|
49
|
+
field_set(name, items)
|
50
|
+
end
|
51
|
+
end
|
46
52
|
end
|
47
53
|
|
48
54
|
protected def range(*attrs)
|
49
55
|
fields(*attrs) { |*values| (values.first..values.last) }
|
50
56
|
end
|
51
57
|
|
52
|
-
protected def pointlist(*attrs)
|
53
|
-
fields(*attrs) { |&block| PointList.new(&block) }
|
54
|
-
end
|
55
|
-
|
56
58
|
private def fields(*names, &block)
|
57
59
|
names.each do |name|
|
58
60
|
define_method(name) do |*args, &b|
|
data/lib/resulang/section.rb
CHANGED
data/lib/resulang/version.rb
CHANGED