lipa 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/NEWS.md ADDED
@@ -0,0 +1,3 @@
1
+ Release-0.1.0
2
+ ---------------------
3
+ Initial relese!
data/README.md ADDED
@@ -0,0 +1,40 @@
1
+ Lipa - DSL for description treelike structures in Ruby
2
+ =======================================================
3
+
4
+ Features
5
+ ------------------------------------------------------
6
+ - Dynamic creating treelike structures for Ruby
7
+ - Flexible syntax
8
+ - Supporting templates and scope initialization
9
+ - Supporting Proc object as attributes
10
+
11
+ Installation
12
+ -----------------------------------------------------
13
+ `gem install lipa`
14
+
15
+ Example
16
+ ------------------------------------------------------
17
+ ```Ruby
18
+ require 'lipa'
19
+
20
+ tree = Lipa::Tree.new :tree do
21
+ kind :red_leaf do
22
+ color "red"
23
+ end
24
+
25
+ branch :branch do
26
+ bunch :color => "green", do
27
+ leaf :leaf_green
28
+ leaf :leaf_yelow, :color => "yelow"
29
+ end
30
+ end
31
+
32
+ leaf :red_leaf, :kind => :red_leaf
33
+ end
34
+
35
+
36
+ puts tree["branch/leaf_green"].color
37
+ puts tree["branch/leaf_yelow"].color
38
+ puts tree["red_leaf"].color
39
+ ```
40
+
data/Rakefile ADDED
@@ -0,0 +1,20 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+
13
+ require 'rake'
14
+ require 'rspec/core'
15
+ require 'rspec/core/rake_task'
16
+ RSpec::Core::RakeTask.new(:spec) do |spec|
17
+ spec.pattern = FileList['spec/**/*_spec.rb']
18
+ end
19
+
20
+ task :default => :spec
@@ -0,0 +1,93 @@
1
+ =begin
2
+ Lipa - DSL for description treelike structures in Ruby
3
+
4
+ Copyright (c) 2011 Aleksey Timin
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining
7
+ a copy of this software and associated documentation files (the
8
+ 'Software'), to deal in the Software without restriction, including
9
+ without limitation the rights to use, copy, modify, merge, publish,
10
+ distribute, sublicense, and/or sell copies of the Software, and to
11
+ permit persons to whom the Software is furnished to do so, subject to
12
+ the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be
15
+ included in all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
18
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
+ =end
25
+
26
+ module Lipa
27
+ # Implemenation of branch (conteiner) for description
28
+ #
29
+ # @example
30
+ #
31
+ # tree = Lipa::Tree.new :tree do
32
+ # branch :group_1 do
33
+ # leaf :obj_1, :param_1 => "some_param"
34
+ # end
35
+ # end
36
+ # tree["group_1/obj_1"].param_1 #=> "some_param"
37
+ #
38
+ # alias #branch is #group, #dir
39
+
40
+ class Branch < Leaf
41
+ init_methods :branch, :dir, :group
42
+
43
+ def method_missing(name, *args, &block)
44
+ @attrs[:leafs] ||= {}
45
+ init_class = @@init_methods[name.to_s]
46
+ if init_class
47
+ args[1] ||= {}
48
+ args[1][:branch] = self
49
+ @attrs[:leafs][args[0].to_s] = init_class.send(:new, *args, &block )
50
+ else
51
+ super
52
+ end
53
+ end
54
+
55
+ # Accessor for entry by path
56
+ # @param [String] path to entry
57
+ # @return entry
58
+ #
59
+ # @example
60
+ # tree["dir_1/dir_2/searched_obj"]
61
+ def [](path)
62
+ split_path = path.split("/")
63
+ obj = @attrs[:leafs][split_path[0]]
64
+ if obj
65
+ if split_path.size > 1
66
+ obj[split_path[1..-1].join("/")]
67
+ else
68
+ obj
69
+ end
70
+ end
71
+ end
72
+
73
+ # Initial method for group description
74
+ #
75
+ # @example
76
+ # tree = Lipa::Tree.new :tree do
77
+ # bunch :param_1 => "some_param" do
78
+ # leaf :obj_1
79
+ # leaf :obj_2
80
+ # end
81
+ # end
82
+ #
83
+ # tree["obj_1"].param_1 #=> "some_param"
84
+ # tree["obj_2"].param_1 #=> "some_param"
85
+ def bunch(attrs = {}, &block)
86
+ if block_given?
87
+ Lipa::Bunch.new(self, attrs, &block)
88
+ end
89
+ end
90
+
91
+ alias_method :with, :bunch
92
+ end
93
+ end
data/lib/lipa/bunch.rb ADDED
@@ -0,0 +1,60 @@
1
+ =begin
2
+ Lipa - DSL for description treelike structures in Ruby
3
+
4
+ Copyright (c) 2011 Aleksey Timin
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining
7
+ a copy of this software and associated documentation files (the
8
+ 'Software'), to deal in the Software without restriction, including
9
+ without limitation the rights to use, copy, modify, merge, publish,
10
+ distribute, sublicense, and/or sell copies of the Software, and to
11
+ permit persons to whom the Software is furnished to do so, subject to
12
+ the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be
15
+ included in all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
18
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
+ =end
25
+
26
+ module Lipa
27
+ # Implementation of group description
28
+ #
29
+ # @example
30
+ # tree = Lipa::Tree.new :tree do
31
+ # bunch :param_1 => "some_param" do
32
+ # leaf :obj_1
33
+ # leaf :obj_2
34
+ # end
35
+ # end
36
+ #
37
+ # tree["obj_1"].param_1 #=> "some_param"
38
+ # tree["obj_2"].param_1 #=> "some_param"
39
+ class Bunch
40
+ def initialize(branch, attrs = {}, &block)
41
+ @attrs = attrs
42
+ @branch = branch
43
+ @branch.attrs[:leafs] ||= {}
44
+
45
+ instance_eval &block if block_given?
46
+ end
47
+
48
+ def method_missing(name, *args, &block)
49
+ init_class = Lipa::Leaf.init_methods[name.to_s]
50
+ if init_class and init_class.class == Class
51
+ args[1] ||= {}
52
+ args[1] = @attrs.merge(args[1]) #to save local attrs
53
+ args[1][:branch] = @branch
54
+ @branch.attrs[:leafs][args[0].to_s] = init_class.send(:new, *args, &block )
55
+ else
56
+ super
57
+ end
58
+ end
59
+ end
60
+ end
data/lib/lipa/kind.rb ADDED
@@ -0,0 +1,44 @@
1
+ =begin
2
+ Lipa - DSL for description treelike structures in Ruby
3
+
4
+ Copyright (c) 2011 Aleksey Timin
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining
7
+ a copy of this software and associated documentation files (the
8
+ 'Software'), to deal in the Software without restriction, including
9
+ without limitation the rights to use, copy, modify, merge, publish,
10
+ distribute, sublicense, and/or sell copies of the Software, and to
11
+ permit persons to whom the Software is furnished to do so, subject to
12
+ the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be
15
+ included in all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
18
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
+ =end
25
+
26
+ module Lipa
27
+ # Implemenation of kind(template) for description
28
+ #
29
+ # @example
30
+ #
31
+ # tree = Lipa::Tree.new :tree do
32
+ # kind :some_kind do
33
+ # param1 "some_param"
34
+ # end
35
+ #
36
+ # leaf :some_instance, :kind => :some_kind
37
+ # end
38
+ # tree["some_instance"].param_1 #=> "some_param"
39
+ #
40
+ # alias #kind is #template
41
+ class Kind < Branch
42
+ end
43
+ end
44
+
data/lib/lipa/leaf.rb ADDED
@@ -0,0 +1,89 @@
1
+ =begin
2
+ Lipa - DSL for description treelike structures in Ruby
3
+
4
+ Copyright (c) 2011 Aleksey Timin
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining
7
+ a copy of this software and associated documentation files (the
8
+ 'Software'), to deal in the Software without restriction, including
9
+ without limitation the rights to use, copy, modify, merge, publish,
10
+ distribute, sublicense, and/or sell copies of the Software, and to
11
+ permit persons to whom the Software is furnished to do so, subject to
12
+ the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be
15
+ included in all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
18
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
+ =end
25
+
26
+
27
+ module Lipa
28
+ # Base object for all nested object of tree
29
+ # It supports initialization
30
+ # attributes by constant, variable or Proc object
31
+ #
32
+ # @example
33
+ # tree = Lipa::Tree.new :tree do
34
+ # leaf :object, :param_1 => 4 do
35
+ # param_2 "some_param"
36
+ # param_3 lambda{1+param_3}
37
+ # end
38
+ # end
39
+ # tree["object"].param_1 #=> 4
40
+ # tree["object"].param_2 #=> "some_param"
41
+ # tree["object"].param_3 #=> 5
42
+
43
+ class Leaf
44
+ attr_accessor :attrs
45
+ @@init_methods = {"leaf" => self, "object" => self}
46
+ @@kinds = {}
47
+
48
+ def initialize(name, attrs = {}, &block)
49
+ @attrs = attrs
50
+ @attrs[:name] = name.to_s
51
+
52
+ if attrs[:kind]
53
+ @kind = @@kinds[attrs[:kind].to_sym]
54
+
55
+ @attrs.merge! @kind.attrs
56
+ end
57
+
58
+ instance_eval &block if block_given?
59
+ end
60
+
61
+ def method_missing(name, *args, &block)
62
+ case args.size
63
+ when 0
64
+ val = @attrs[name]
65
+ if val.class == Proc
66
+ val.call
67
+ else
68
+ val
69
+ end
70
+ when 1
71
+ name = name.to_s
72
+ name["="] = "" if name["="]
73
+ @attrs[name.to_sym] = args[0]
74
+ else
75
+ super
76
+ end
77
+ end
78
+
79
+ def self.init_methods(*names)
80
+ if names.size > 0
81
+ names.each do |name|
82
+ @@init_methods[name.to_s] = self
83
+ end
84
+ else
85
+ @@init_methods
86
+ end
87
+ end
88
+ end
89
+ end
data/lib/lipa/tree.rb ADDED
@@ -0,0 +1,61 @@
1
+ =begin
2
+ Lipa - DSL for description treelike structures in Ruby
3
+
4
+ Copyright (c) 2011 Aleksey Timin
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining
7
+ a copy of this software and associated documentation files (the
8
+ 'Software'), to deal in the Software without restriction, including
9
+ without limitation the rights to use, copy, modify, merge, publish,
10
+ distribute, sublicense, and/or sell copies of the Software, and to
11
+ permit persons to whom the Software is furnished to do so, subject to
12
+ the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be
15
+ included in all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
18
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
+ =end
25
+
26
+ module Lipa
27
+ # Implementaion of root of description
28
+ # @example
29
+ #
30
+ # tree = Lipa::Tree.new :tree do
31
+ # leaf :object do
32
+ # param_1 "some_param"
33
+ # param_2 lambda{1+2}
34
+ # end
35
+ # end
36
+ #
37
+ # tree["object"].param_1 #=> "some_param"
38
+ # tree["object"].param_2 #=> 3
39
+ class Tree < Branch
40
+ attr_reader :kinds
41
+
42
+ # Initialize of kind
43
+ # @see Lipa::Kind
44
+ #
45
+ # @example
46
+ #
47
+ # kind :some_kind do
48
+ # param1 "some_param"
49
+ # end
50
+ #
51
+ # leaf :some_instance, :kind => :some_kind
52
+ def kind(name, attrs = {}, &block)
53
+ if block_given?
54
+ @@kinds ||= {}
55
+ @@kinds[name.to_sym] = Lipa::Kind.new(name, attrs, &block)
56
+ end
57
+ end
58
+
59
+ alias_method :template, :kind
60
+ end
61
+ end
@@ -0,0 +1,28 @@
1
+ =begin
2
+ Lipa - DSL for description treelike structures in Ruby
3
+
4
+ Copyright (c) 2011 Aleksey Timin
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining
7
+ a copy of this software and associated documentation files (the
8
+ 'Software'), to deal in the Software without restriction, including
9
+ without limitation the rights to use, copy, modify, merge, publish,
10
+ distribute, sublicense, and/or sell copies of the Software, and to
11
+ permit persons to whom the Software is furnished to do so, subject to
12
+ the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be
15
+ included in all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
18
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
+ =end
25
+
26
+ module Lipa
27
+ VERSION = "0.1.0"
28
+ end
data/lib/lipa.rb ADDED
@@ -0,0 +1,31 @@
1
+ =begin
2
+ Lipa - DSL for description treelike structures in Ruby
3
+
4
+ Copyright (c) 2011 Aleksey Timin
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining
7
+ a copy of this software and associated documentation files (the
8
+ 'Software'), to deal in the Software without restriction, including
9
+ without limitation the rights to use, copy, modify, merge, publish,
10
+ distribute, sublicense, and/or sell copies of the Software, and to
11
+ permit persons to whom the Software is furnished to do so, subject to
12
+ the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be
15
+ included in all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
18
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
+ =end
25
+
26
+ require "lipa/version"
27
+ require "lipa/leaf"
28
+ require "lipa/branch"
29
+ require "lipa/bunch"
30
+ require "lipa/kind"
31
+ require "lipa/tree"
@@ -0,0 +1,30 @@
1
+ require File.dirname(__FILE__) + "/spec_helper"
2
+
3
+ describe Lipa::Branch do
4
+ before :each do
5
+ @grp = tree["group_1"]
6
+ end
7
+
8
+ it 'should have leafs (children)' do
9
+ @grp.leafs["obj_1"].should eql(tree["group_1/obj_1"])
10
+ @grp.leafs["obj_2"].should eql(tree["group_1/obj_2"])
11
+ end
12
+
13
+ it 'should have [] for access entry by path' do
14
+ @grp["group_2/obj_3"].should eql(tree["group_1/group_2/obj_3"])
15
+ end
16
+
17
+ it 'should have any attrs also as leaf (Lipa::Leaf)' do
18
+ @grp.any_attr.should eql("any attr")
19
+ end
20
+
21
+ it 'should have "dir" initial method' do
22
+ t = Lipa::Tree.new(nil) { dir :dir_1 }
23
+ t["dir_1"].class.should eql(Lipa::Branch)
24
+ end
25
+
26
+ it 'should have "object" initial method' do
27
+ t = Lipa::Tree.new(nil) { group :group_1 }
28
+ t["group_1"].class.should eql(Lipa::Branch)
29
+ end
30
+ end
@@ -0,0 +1,22 @@
1
+ require File.dirname(__FILE__) + "/spec_helper"
2
+
3
+ describe Lipa::Bunch do
4
+ it 'should create some object with any attributes' do
5
+ tree["obj_4"].attr_1.should eql(100)
6
+ tree["obj_5"].attr_1.should eql(100)
7
+ tree["obj_6"].attr_1.should eql(200)
8
+
9
+ tree["obj_4"].attr_2.should eql("attr_2")
10
+ tree["obj_5"].attr_2.should eql("attr_2")
11
+ tree["obj_6"].attr_2.should eql("")
12
+ end
13
+
14
+ it 'should have "with" initial method' do
15
+ t = Lipa::Tree.new("1") do
16
+ with :attr_1 => 999 do
17
+ leaf :obj_1
18
+ end
19
+ end
20
+ t["obj_1"].attr_1.should eql(999)
21
+ end
22
+ end
data/spec/kind_spec.rb ADDED
@@ -0,0 +1,11 @@
1
+ require File.dirname(__FILE__) + "/spec_helper"
2
+
3
+ describe Lipa::Kind do
4
+ it 'should create brunch from template' do
5
+ tree["group_3/obj_y"].attr_1.should eql("from_kind")
6
+ end
7
+
8
+ it 'should support local changing in instances' do
9
+ tree["group_3/obj_x"].attr_1.should eql("from_instance")
10
+ end
11
+ end
data/spec/leaf_spec.rb ADDED
@@ -0,0 +1,43 @@
1
+ require File.dirname(__FILE__) + "/spec_helper"
2
+
3
+ describe Lipa::Leaf do
4
+ before :each do
5
+ @obj = tree["group_1/obj_1"]
6
+ end
7
+
8
+ it 'should have name' do
9
+ @obj.name.should eql("obj_1")
10
+ end
11
+
12
+ it 'should have branch (parent)' do
13
+ @obj.branch.should eql(tree["group_1"])
14
+ end
15
+
16
+ it 'should have descripted attr_1 eql 5' do
17
+ @obj.attr_1.should eql(5)
18
+ end
19
+
20
+ it 'should have descripted attr_2 eql 4' do
21
+ @obj.attr_2.should eql(3)
22
+ end
23
+
24
+ it 'should have descripted attr_3 eql sum of attr_1 and attr_2' do
25
+ @obj.attr_3.should eql(8)
26
+ end
27
+
28
+ it 'should support write access for attrs' do
29
+ @obj.attr_1 = 8
30
+ @obj.attr_1.should eql(8)
31
+ end
32
+
33
+ it 'should have hash access for attrs' do
34
+ @obj.attrs[:attr_1].should eql(8)
35
+ @obj.attrs[:attr_1] = 9
36
+ @obj.attrs[:attr_1].should eql(9)
37
+ end
38
+
39
+ it 'should have "object" initial method' do
40
+ t = Lipa::Tree.new(nil) { object :obj }
41
+ t["obj"].class.should eql(Lipa::Leaf)
42
+ end
43
+ end
@@ -0,0 +1,41 @@
1
+ require "lipa"
2
+
3
+ TREE ||= Lipa::Tree.new "lipa" do
4
+ branch :group_1 do
5
+ any_attr "any attr"
6
+
7
+ leaf :obj_1, :attr_1 => 5 do
8
+ attr_2 3
9
+ attr_3 lambda{attr_1 + attr_2}
10
+ end
11
+
12
+ leaf :obj_2
13
+
14
+ branch :group_2 do
15
+ leaf :obj_3
16
+ end
17
+ end
18
+
19
+ bunch :attr_1 => 100, :attr_2 => "attr_2" do
20
+ leaf :obj_4
21
+ leaf :obj_5
22
+ leaf :obj_6, :attr_1 => 200, :attr_2 => ""
23
+ end
24
+
25
+ kind :kind_group do
26
+ leaf :obj_x
27
+ leaf :obj_y do
28
+ attr_1 "from_kind"
29
+ end
30
+ end
31
+
32
+ branch :group_3, :kind => :kind_group do
33
+ leaf :obj_x do
34
+ attr_1 "from_instance"
35
+ end
36
+ end
37
+ end
38
+
39
+ def tree
40
+ TREE
41
+ end
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lipa
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - A.Timin
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-10-16 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: &16006520 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *16006520
25
+ - !ruby/object:Gem::Dependency
26
+ name: bundler
27
+ requirement: &16005820 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *16005820
36
+ - !ruby/object:Gem::Dependency
37
+ name: rspec
38
+ requirement: &16004980 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *16004980
47
+ description:
48
+ email: atimin@gmail.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files:
52
+ - README.md
53
+ - NEWS.md
54
+ files:
55
+ - lib/lipa.rb
56
+ - lib/lipa/version.rb
57
+ - lib/lipa/kind.rb
58
+ - lib/lipa/leaf.rb
59
+ - lib/lipa/bunch.rb
60
+ - lib/lipa/tree.rb
61
+ - lib/lipa/branch.rb
62
+ - spec/kind_spec.rb
63
+ - spec/spec_helper.rb
64
+ - spec/branch_spec.rb
65
+ - spec/bunch_spec.rb
66
+ - spec/leaf_spec.rb
67
+ - Rakefile
68
+ - README.md
69
+ - NEWS.md
70
+ homepage: http://xpca.org
71
+ licenses: []
72
+ post_install_message:
73
+ rdoc_options:
74
+ - --title
75
+ - Lipa
76
+ - --inline-source
77
+ - --main
78
+ - README.md
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ! '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubyforge_project:
95
+ rubygems_version: 1.8.11
96
+ signing_key:
97
+ specification_version: 3
98
+ summary: Lipa - DSL for description treelike structures in Ruby
99
+ test_files: []