lipa 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/NEWS.md CHANGED
@@ -1,6 +1,11 @@
1
+ 2011-10-20 Release-0.2.2
2
+
3
+ - Fixed issue [#1](https://github.com/flipback/lipa/issues/1) in template functional.
4
+ Lambda expressions is not supporting. Use `Proc.new {}` for added calculation in your trees
5
+
1
6
  2011-10-19 Release-0.2.1
2
7
 
3
- - Fixed bug in Lipa::Node class. Now is working:
8
+ - Fixed bug in Lipa::Bunch class. Now is working:
4
9
 
5
10
  ```Ruby
6
11
  t = Lipa::Tree.new("1") do
data/lib/lipa/kind.rb CHANGED
@@ -39,6 +39,19 @@ module Lipa
39
39
  #
40
40
  # alias #kind is #template
41
41
  class Kind < Node
42
+ def method_missing(name, *args, &block)
43
+ unless Node.add_node(name, self, *args, &block)
44
+ # only assigment
45
+ if args.size == 1
46
+ name = name.to_s
47
+ name["="] = "" if name["="]
48
+ @attrs[name.to_sym] = args[0]
49
+ else
50
+ super
51
+ end
52
+ end
53
+ end
54
+
42
55
  end
43
56
  end
44
57
 
data/lib/lipa/node.rb CHANGED
@@ -46,7 +46,6 @@ module Lipa
46
46
 
47
47
  def initialize(name, attrs = {}, &block)
48
48
  @attrs = {}
49
- @attrs[:name] = name.to_s
50
49
 
51
50
  #init attrs from template
52
51
  if attrs[:kind]
@@ -55,6 +54,7 @@ module Lipa
55
54
  end
56
55
 
57
56
  @attrs.merge! attrs
57
+ @attrs[:name] = name.to_s
58
58
  instance_eval &block if block_given?
59
59
  end
60
60
 
@@ -67,7 +67,7 @@ module Lipa
67
67
 
68
68
  val = @attrs[name]
69
69
  if val.class == Proc
70
- val.call
70
+ instance_eval &(val)
71
71
  else
72
72
  val
73
73
  end
@@ -150,7 +150,12 @@ module Lipa
150
150
  if init_class
151
151
  args[1] ||= {}
152
152
  args[1][:parent] = parent
153
- parent.attrs[:children][args[0].to_sym] = init_class.send(:new, *args, &block )
153
+ child_name = args[0].to_sym
154
+
155
+ existen_child = parent.attrs[:children][child_name]
156
+ args[1] = existen_child.attrs.merge(args[1]) if existen_child
157
+
158
+ parent.attrs[:children][child_name] = init_class.send(:new, *args, &block )
154
159
  else
155
160
  nil
156
161
  end
data/lib/lipa/version.rb CHANGED
@@ -24,5 +24,5 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
24
  =end
25
25
 
26
26
  module Lipa
27
- VERSION = "0.2.1"
27
+ VERSION = "0.2.2"
28
28
  end
data/spec/kind_spec.rb CHANGED
@@ -2,15 +2,24 @@ require File.dirname(__FILE__) + "/spec_helper"
2
2
 
3
3
  describe Lipa::Kind do
4
4
  it 'should create brunch from template' do
5
- tree["group_3/obj_y"].attr_1.should eql("from_kind")
5
+ tree.group_3.obj_x.attr_0.should eql("from_kind")
6
6
  end
7
7
 
8
8
  it 'should support local changing in instances' do
9
- tree["group_3/obj_x"].attr_1.should eql("from_instance")
9
+ tree.group_3.obj_x.attr_1.should eql("from_instance")
10
10
  end
11
11
 
12
12
  it 'should create init method with name template' do
13
13
  tree.folder_1.some_file.size.should eql(1024)
14
14
  tree.folder_1.some_file.ext.should eql("txt")
15
15
  end
16
+
17
+ it 'should create node with your name' do
18
+ tree.folder_1.name.should eql("folder_1")
19
+ end
20
+
21
+ it 'should have lazy calculation' do
22
+ tree.group_3.obj_x.attr_2.should eql(2)
23
+ tree.group_3.obj_x.attr_3.should eql(4)
24
+ end
16
25
  end
data/spec/node_spec.rb CHANGED
@@ -23,6 +23,8 @@ describe Lipa::Node do
23
23
 
24
24
  it 'should have descripted attr_3 eql sum of attr_1 and attr_2' do
25
25
  @node.attr_3.should eql(8)
26
+ @node.attr_2 = 10
27
+ @node.attr_3.should eql(15)
26
28
  end
27
29
 
28
30
  it 'should support write access for attrs' do
data/spec/spec_helper.rb CHANGED
@@ -6,7 +6,7 @@ TREE ||= Lipa::Tree.new "lipa" do
6
6
 
7
7
  node :obj_1, :attr_1 => 5 do
8
8
  attr_2 3
9
- attr_3 lambda{attr_1 + attr_2}
9
+ attr_3 Proc.new{attr_1 + attr_2}
10
10
 
11
11
  node :obj_2
12
12
  node :obj_3
@@ -21,15 +21,18 @@ TREE ||= Lipa::Tree.new "lipa" do
21
21
 
22
22
  # Template
23
23
  kind :kind_group do
24
- node :obj_x
25
- node :obj_y do
24
+ node :obj_x do
25
+ attr_0 "from_kind"
26
26
  attr_1 "from_kind"
27
+ attr_2 0
28
+ attr_3 Proc.new{ attr_2 * 2}
27
29
  end
28
30
  end
29
31
 
30
32
  node :group_3, :kind => :kind_group do
31
33
  node :obj_x do
32
34
  attr_1 "from_instance"
35
+ attr_2 2
33
36
  end
34
37
  end
35
38
  #or
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.1
4
+ version: 0.2.2
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-19 00:00:00.000000000Z
12
+ date: 2011-10-20 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &9989380 !ruby/object:Gem::Requirement
16
+ requirement: &11366740 !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: *9989380
24
+ version_requirements: *11366740
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bundler
27
- requirement: &9988620 !ruby/object:Gem::Requirement
27
+ requirement: &11366060 !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: *9988620
35
+ version_requirements: *11366060
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &9987980 !ruby/object:Gem::Requirement
38
+ requirement: &11362040 !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: *9987980
46
+ version_requirements: *11362040
47
47
  description:
48
48
  email: atimin@gmail.com
49
49
  executables: []