dsl_block 1.0.0 → 2.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 +4 -4
- data/.gitignore +17 -17
- data/.rspec +2 -2
- data/Gemfile +4 -4
- data/LICENSE.txt +22 -22
- data/README.md +82 -82
- data/Rakefile +15 -15
- data/dsl_block.gemspec +29 -29
- data/lib/dsl_block.rb +168 -159
- data/lib/dsl_block/executor.rb +37 -37
- data/lib/dsl_block/version.rb +10 -10
- data/spec/lib/dsl_block/dsl_executor_spec.rb +60 -60
- data/spec/lib/dsl_block_spec.rb +251 -241
- data/spec/spec_helper.rb +114 -114
- metadata +3 -4
data/spec/spec_helper.rb
CHANGED
@@ -1,114 +1,114 @@
|
|
1
|
-
require 'simplecov'
|
2
|
-
SimpleCov.start('test_frameworks')
|
3
|
-
require 'rspec/autorun'
|
4
|
-
require 'dsl_block'
|
5
|
-
|
6
|
-
RSpec.configure do |config|
|
7
|
-
config.order = 'random'
|
8
|
-
end
|
9
|
-
|
10
|
-
# Due to the nature of these tests, the number of discreete classes involved, and scoping issues
|
11
|
-
# the memoizaton will occur here instead of the standard rspec 'let' statements. Feel free to
|
12
|
-
# move these back to standard let statements if the specs can be kept as clean or cleaner
|
13
|
-
|
14
|
-
|
15
|
-
# Generic dsl class. Used in the specs as the outermost block
|
16
|
-
def dsl_class1
|
17
|
-
@dsl_class1||= Class.new(DslBlock).tap do |klass|
|
18
|
-
def klass.name
|
19
|
-
'Dsl1'
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
# Generic dsl class. Used in the specs as the middle block
|
25
|
-
def dsl_class2
|
26
|
-
@dsl_class2 ||= Class.new(DslBlock).tap do |klass|
|
27
|
-
def klass.name
|
28
|
-
'Dsl2'
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
# Generic dsl class. Used in the specs as the innermst block
|
34
|
-
def dsl_class3
|
35
|
-
@dsl_class3 ||= Class.new(DslBlock).tap do |klass|
|
36
|
-
def klass.name
|
37
|
-
'Dsl3'
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
# The command the outermost dsl block is usually called by
|
43
|
-
def dsl_class1_command
|
44
|
-
dsl_class1.name.underscore.to_sym
|
45
|
-
end
|
46
|
-
|
47
|
-
# The command the middle dsl block is usually called by
|
48
|
-
def dsl_class2_command
|
49
|
-
dsl_class2.name.underscore.to_sym
|
50
|
-
end
|
51
|
-
|
52
|
-
# The command the innermost dsl block is usually called by
|
53
|
-
def dsl_class3_command
|
54
|
-
dsl_class3.name.underscore.to_sym
|
55
|
-
end
|
56
|
-
|
57
|
-
# Reset all of the classes for a new test
|
58
|
-
def dsl_reset
|
59
|
-
@dsl_class1 = nil
|
60
|
-
@dsl_class2 = nil
|
61
|
-
@dsl_class3 = nil
|
62
|
-
end
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
# The following are helpers to DRY up the tests.
|
68
|
-
# The numbers after 'dsl' are references to the order the dsl blocks are nested.
|
69
|
-
|
70
|
-
|
71
|
-
# No nested dsl. Block given is run at the ellipsis
|
72
|
-
# dsl_class1 do
|
73
|
-
# ...
|
74
|
-
# end
|
75
|
-
def dsl1(auto_yield=true, &block)
|
76
|
-
dsl = dsl_class1.new(&block)
|
77
|
-
auto_yield ? dsl.yield : dsl
|
78
|
-
end
|
79
|
-
|
80
|
-
# Nested dsl. Block given is run at the ellipsis
|
81
|
-
# dsl_class1 do
|
82
|
-
# dsl_class2 do
|
83
|
-
# ...
|
84
|
-
# end
|
85
|
-
# end
|
86
|
-
def dsl12(auto_yield=true,
|
87
|
-
dsl_class2.add_command_to(dsl_class1,
|
88
|
-
command = dsl_class2_command
|
89
|
-
dsl = dsl_class1.new do
|
90
|
-
self.send(command, &block)
|
91
|
-
end
|
92
|
-
auto_yield ? dsl.yield : dsl
|
93
|
-
end
|
94
|
-
|
95
|
-
# Double nested dsl. Block given is run at the ellipsis
|
96
|
-
# dsl_class1 do
|
97
|
-
# dsl_class2 do
|
98
|
-
# dsl_class3 do
|
99
|
-
# ...
|
100
|
-
# end
|
101
|
-
# end
|
102
|
-
# end
|
103
|
-
def dsl123(auto_yield=true,
|
104
|
-
dsl_class2.add_command_to(dsl_class1,
|
105
|
-
dsl_class3.add_command_to(dsl_class2,
|
106
|
-
command2 = dsl_class2_command
|
107
|
-
command3 = dsl_class3_command
|
108
|
-
dsl = dsl_class1.new do
|
109
|
-
self.send(command2) do
|
110
|
-
self.send(command3, &block)
|
111
|
-
end
|
112
|
-
end
|
113
|
-
auto_yield ? dsl.yield : dsl
|
114
|
-
end
|
1
|
+
require 'simplecov'
|
2
|
+
SimpleCov.start('test_frameworks')
|
3
|
+
require 'rspec/autorun'
|
4
|
+
require 'dsl_block'
|
5
|
+
|
6
|
+
RSpec.configure do |config|
|
7
|
+
config.order = 'random'
|
8
|
+
end
|
9
|
+
|
10
|
+
# Due to the nature of these tests, the number of discreete classes involved, and scoping issues
|
11
|
+
# the memoizaton will occur here instead of the standard rspec 'let' statements. Feel free to
|
12
|
+
# move these back to standard let statements if the specs can be kept as clean or cleaner
|
13
|
+
|
14
|
+
|
15
|
+
# Generic dsl class. Used in the specs as the outermost block
|
16
|
+
def dsl_class1
|
17
|
+
@dsl_class1||= Class.new(DslBlock).tap do |klass|
|
18
|
+
def klass.name
|
19
|
+
'Dsl1'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# Generic dsl class. Used in the specs as the middle block
|
25
|
+
def dsl_class2
|
26
|
+
@dsl_class2 ||= Class.new(DslBlock).tap do |klass|
|
27
|
+
def klass.name
|
28
|
+
'Dsl2'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# Generic dsl class. Used in the specs as the innermst block
|
34
|
+
def dsl_class3
|
35
|
+
@dsl_class3 ||= Class.new(DslBlock).tap do |klass|
|
36
|
+
def klass.name
|
37
|
+
'Dsl3'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# The command the outermost dsl block is usually called by
|
43
|
+
def dsl_class1_command
|
44
|
+
dsl_class1.name.underscore.to_sym
|
45
|
+
end
|
46
|
+
|
47
|
+
# The command the middle dsl block is usually called by
|
48
|
+
def dsl_class2_command
|
49
|
+
dsl_class2.name.underscore.to_sym
|
50
|
+
end
|
51
|
+
|
52
|
+
# The command the innermost dsl block is usually called by
|
53
|
+
def dsl_class3_command
|
54
|
+
dsl_class3.name.underscore.to_sym
|
55
|
+
end
|
56
|
+
|
57
|
+
# Reset all of the classes for a new test
|
58
|
+
def dsl_reset
|
59
|
+
@dsl_class1 = nil
|
60
|
+
@dsl_class2 = nil
|
61
|
+
@dsl_class3 = nil
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
# The following are helpers to DRY up the tests.
|
68
|
+
# The numbers after 'dsl' are references to the order the dsl blocks are nested.
|
69
|
+
|
70
|
+
|
71
|
+
# No nested dsl. Block given is run at the ellipsis
|
72
|
+
# dsl_class1 do
|
73
|
+
# ...
|
74
|
+
# end
|
75
|
+
def dsl1(auto_yield=true, &block)
|
76
|
+
dsl = dsl_class1.new(&block)
|
77
|
+
auto_yield ? dsl.yield : dsl
|
78
|
+
end
|
79
|
+
|
80
|
+
# Nested dsl. Block given is run at the ellipsis
|
81
|
+
# dsl_class1 do
|
82
|
+
# dsl_class2 do
|
83
|
+
# ...
|
84
|
+
# end
|
85
|
+
# end
|
86
|
+
def dsl12(auto_yield=true, propagate12=false, &block)
|
87
|
+
dsl_class2.add_command_to(dsl_class1, :propagate => propagate12)
|
88
|
+
command = dsl_class2_command
|
89
|
+
dsl = dsl_class1.new do
|
90
|
+
self.send(command, &block)
|
91
|
+
end
|
92
|
+
auto_yield ? dsl.yield : dsl
|
93
|
+
end
|
94
|
+
|
95
|
+
# Double nested dsl. Block given is run at the ellipsis
|
96
|
+
# dsl_class1 do
|
97
|
+
# dsl_class2 do
|
98
|
+
# dsl_class3 do
|
99
|
+
# ...
|
100
|
+
# end
|
101
|
+
# end
|
102
|
+
# end
|
103
|
+
def dsl123(auto_yield=true, propagate12=false, propagate23=false, &block)
|
104
|
+
dsl_class2.add_command_to(dsl_class1, :propagate => propagate12)
|
105
|
+
dsl_class3.add_command_to(dsl_class2, :propagate => propagate23)
|
106
|
+
command2 = dsl_class2_command
|
107
|
+
command3 = dsl_class3_command
|
108
|
+
dsl = dsl_class1.new do
|
109
|
+
self.send(command2) do
|
110
|
+
self.send(command3, &block)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
auto_yield ? dsl.yield : dsl
|
114
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dsl_block
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Frank Hall
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -134,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
134
|
version: '0'
|
135
135
|
requirements: []
|
136
136
|
rubyforge_project:
|
137
|
-
rubygems_version: 2.0.
|
137
|
+
rubygems_version: 2.0.14
|
138
138
|
signing_key:
|
139
139
|
specification_version: 4
|
140
140
|
summary: Quick and simple DSL creator.
|
@@ -142,4 +142,3 @@ test_files:
|
|
142
142
|
- spec/lib/dsl_block/dsl_executor_spec.rb
|
143
143
|
- spec/lib/dsl_block_spec.rb
|
144
144
|
- spec/spec_helper.rb
|
145
|
-
has_rdoc:
|