lipa 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/NEWS.md +16 -0
- data/lib/lipa/bunch.rb +3 -8
- data/lib/lipa/node.rb +30 -19
- data/lib/lipa/version.rb +1 -1
- data/spec/bunch_spec.rb +13 -0
- metadata +8 -8
data/NEWS.md
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
2011-10-19 Release-0.2.1
|
2
|
+
|
3
|
+
- Fixed bug in Lipa::Node class. Now is working:
|
4
|
+
|
5
|
+
```Ruby
|
6
|
+
t = Lipa::Tree.new("1") do
|
7
|
+
kind :some_kind, :for => :node
|
8
|
+
|
9
|
+
with :attr_1 => 999 do
|
10
|
+
some_kind :obj_1
|
11
|
+
end
|
12
|
+
end
|
13
|
+
```
|
14
|
+
|
15
|
+
- Refactoring. Added method Node#init_node for making cnildren nodes
|
16
|
+
|
1
17
|
2011-10-17 Release-0.2.0
|
2
18
|
------------------------
|
3
19
|
- New clear API with one general class ```Lipa::Node```. Classes ```Lipa::Leaf``` and ```Lipa::Branch```
|
data/lib/lipa/bunch.rb
CHANGED
@@ -40,19 +40,14 @@ module Lipa
|
|
40
40
|
def initialize(parent, attrs = {}, &block)
|
41
41
|
@attrs = attrs
|
42
42
|
@parent = parent
|
43
|
-
@parent.attrs[:children] ||= {}
|
44
43
|
|
45
44
|
instance_eval &block if block_given?
|
46
45
|
end
|
47
46
|
|
48
47
|
def method_missing(name, *args, &block)
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
args[1] = @attrs.merge(args[1]) #to save local attrs
|
53
|
-
args[1][:parent] = @parent
|
54
|
-
@parent.attrs[:children][args[0].to_sym] = init_class.send(:new, *args, &block )
|
55
|
-
else
|
48
|
+
args[1] ||= {}
|
49
|
+
args[1] = @attrs.merge(args[1])
|
50
|
+
unless Node.add_node(name, @parent, *args, &block)
|
56
51
|
super
|
57
52
|
end
|
58
53
|
end
|
data/lib/lipa/node.rb
CHANGED
@@ -59,25 +59,7 @@ module Lipa
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def method_missing(name, *args, &block)
|
62
|
-
|
63
|
-
|
64
|
-
# Init from kind
|
65
|
-
kind = @@kinds[name]
|
66
|
-
if kind and kind.for
|
67
|
-
init_class = @@init_methods[kind.for]
|
68
|
-
args[1] ||= {}
|
69
|
-
args[1][:kind] = kind.name
|
70
|
-
else
|
71
|
-
#from init methods
|
72
|
-
init_class = @@init_methods[name]
|
73
|
-
end
|
74
|
-
|
75
|
-
if init_class
|
76
|
-
# Making children objects
|
77
|
-
args[1] ||= {}
|
78
|
-
args[1][:parent] = self
|
79
|
-
@attrs[:children][args[0].to_sym] = init_class.send(:new, *args, &block )
|
80
|
-
else
|
62
|
+
unless Node.add_node(name, self, *args, &block)
|
81
63
|
case args.size
|
82
64
|
when 0
|
83
65
|
child = @attrs[:children][name]
|
@@ -145,6 +127,35 @@ module Lipa
|
|
145
127
|
end
|
146
128
|
end
|
147
129
|
|
130
|
+
# Making children node
|
131
|
+
#
|
132
|
+
# @param [String] name of initial method or kind
|
133
|
+
# @param [Node] parent node
|
134
|
+
# @param args of node
|
135
|
+
# @param block for node
|
136
|
+
def self.add_node(name, parent, *args, &block)
|
137
|
+
parent.attrs[:children] ||= {}
|
138
|
+
|
139
|
+
# Init from kind
|
140
|
+
kind = @@kinds[name]
|
141
|
+
if kind and kind.for
|
142
|
+
init_class = @@init_methods[kind.for]
|
143
|
+
args[1] ||= {}
|
144
|
+
args[1][:kind] = kind.name
|
145
|
+
else
|
146
|
+
#from init methods
|
147
|
+
init_class = @@init_methods[name]
|
148
|
+
end
|
149
|
+
|
150
|
+
if init_class
|
151
|
+
args[1] ||= {}
|
152
|
+
args[1][:parent] = parent
|
153
|
+
parent.attrs[:children][args[0].to_sym] = init_class.send(:new, *args, &block )
|
154
|
+
else
|
155
|
+
nil
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
148
159
|
#Deprecated methods
|
149
160
|
def bunch(attrs = {}, &block)
|
150
161
|
warn "#{__FILE__}:#{__LINE__} Deprecated method. Please use Lipa::Node. It is removing in 0.3.0 version"
|
data/lib/lipa/version.rb
CHANGED
data/spec/bunch_spec.rb
CHANGED
@@ -19,4 +19,17 @@ describe Lipa::Bunch do
|
|
19
19
|
end
|
20
20
|
t["obj_1"].attr_1.should eql(999)
|
21
21
|
end
|
22
|
+
|
23
|
+
it 'should work with kinds' do
|
24
|
+
t = Lipa::Tree.new("1") do
|
25
|
+
kind :some_kind, :for => :node
|
26
|
+
|
27
|
+
with :attr_1 => 999 do
|
28
|
+
some_kind :obj_1
|
29
|
+
end
|
30
|
+
end
|
31
|
+
t["obj_1"].attr_1.should eql(999)
|
32
|
+
end
|
33
|
+
|
34
|
+
|
22
35
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lipa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-10-
|
12
|
+
date: 2011-10-19 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
|
-
requirement: &
|
16
|
+
requirement: &9989380 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *9989380
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bundler
|
27
|
-
requirement: &
|
27
|
+
requirement: &9988620 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *9988620
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &9987980 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *9987980
|
47
47
|
description:
|
48
48
|
email: atimin@gmail.com
|
49
49
|
executables: []
|