docile 1.1.2 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -9
- data/Gemfile +0 -13
- data/HISTORY.md +7 -1
- data/LICENSE +1 -1
- data/README.md +1 -1
- data/docile.gemspec +15 -7
- data/lib/docile/fallback_context_proxy.rb +5 -3
- data/lib/docile/version.rb +1 -1
- data/spec/docile_spec.rb +52 -36
- data/spec/spec_helper.rb +6 -0
- metadata +26 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c44867934d111581943bda83d1716d24ca318c5a
|
4
|
+
data.tar.gz: 189fc9c1bcb9b5c15259047850215ac021ee6e61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4615db6a39f3e4a9245b9d2668fd8ce83f6718498b1451622cd875a0fee325bc56dbbf03502a3a54298ef5a47e5ef0df0ea7f2a5d57e2cae8a1d024cf8e7bcca
|
7
|
+
data.tar.gz: 898dc1e784a4ccfa69a5893b8bdecfa46963aacf9d104f15f66485f4ccbdc99674587d50dff6c55d8075367b5230b23785999476e2c2777ac82486d0fe0da5c1
|
data/.travis.yml
CHANGED
@@ -1,12 +1,5 @@
|
|
1
1
|
language: ruby
|
2
|
-
|
3
|
-
# NOTE (2013-12-30): Temporary workaround for Rubygems-Bundler
|
4
|
-
# incompatibility on Travis CI for 1.8 builds, see also:
|
5
|
-
# * https://github.com/rubygems/rubygems/pull/763
|
6
|
-
# * https://github.com/freerange/mocha/commit/66bab2a8f4e7cd8734bf88e6f32157c0d5153125
|
7
|
-
before_install:
|
8
|
-
- gem update --system 2.1.11
|
9
|
-
- gem --version
|
2
|
+
cache: bundler
|
10
3
|
rvm:
|
11
4
|
- 2.1.0
|
12
5
|
- 2.0.0
|
@@ -16,4 +9,4 @@ rvm:
|
|
16
9
|
- ree
|
17
10
|
- jruby-18mode
|
18
11
|
- jruby-19mode
|
19
|
-
- rbx
|
12
|
+
- rbx
|
data/Gemfile
CHANGED
@@ -2,16 +2,3 @@ source 'https://rubygems.org'
|
|
2
2
|
|
3
3
|
# Specify gem's dependencies in docile.gemspec
|
4
4
|
gemspec
|
5
|
-
|
6
|
-
# Explicitly require test gems for Travis CI, since we're excluding dev dependencies
|
7
|
-
group :test do
|
8
|
-
gem 'rake', '~> 0.9.2'
|
9
|
-
gem 'rspec', '~> 2.11.0'
|
10
|
-
gem 'mime-types', '~> 1.25.1'
|
11
|
-
gem 'coveralls', :require => false
|
12
|
-
|
13
|
-
platform :rbx do
|
14
|
-
gem 'rubysl' # Since 2.2.0, Rubinius needs Ruby standard lib as gem
|
15
|
-
gem 'rubinius-coverage' # Coverage tooling for SimpleCov on Rubinius
|
16
|
-
end
|
17
|
-
end
|
data/HISTORY.md
CHANGED
@@ -1,8 +1,14 @@
|
|
1
1
|
# HISTORY
|
2
2
|
|
3
|
+
## [v1.1.3 (Feb 4, 2014)](http://github.com/ms-ati/docile/compare/v1.1.2...v1.1.3)
|
4
|
+
|
5
|
+
- Special thanks to Alexey Vasiliev (@le0pard):
|
6
|
+
- fix problem to catch NoMethodError from non receiver object
|
7
|
+
- upgrade rspec format to new "expect" syntax
|
8
|
+
|
3
9
|
## [v1.1.2 (Jan 10, 2014)](http://github.com/ms-ati/docile/compare/v1.1.1...v1.1.2)
|
4
10
|
|
5
|
-
- remove unnecessarily nested proxy objects (thanks @Ajedi32!
|
11
|
+
- remove unnecessarily nested proxy objects (thanks @Ajedi32)!
|
6
12
|
- documentation updates and corrections
|
7
13
|
|
8
14
|
## [v1.1.1 (Nov 26, 2013)](http://github.com/ms-ati/docile/compare/v1.1.0...v1.1.1)
|
data/LICENSE
CHANGED
data/README.md
CHANGED
data/docile.gemspec
CHANGED
@@ -19,14 +19,22 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.require_paths = %w(lib)
|
20
20
|
|
21
21
|
# Running rspec tests from rake
|
22
|
-
s.add_development_dependency 'rake', '~>
|
23
|
-
s.add_development_dependency 'rspec', '~> 2.
|
22
|
+
s.add_development_dependency 'rake', '~> 10.1.1'
|
23
|
+
s.add_development_dependency 'rspec', '~> 2.14.0'
|
24
|
+
s.add_development_dependency 'mime-types', '~> 1.25.1'
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
if defined?(RUBY_ENGINE) && 'rbx' == RUBY_ENGINE
|
27
|
+
s.add_development_dependency 'rubysl'
|
28
|
+
s.add_development_dependency 'rubinius-coverage'
|
29
|
+
end
|
30
|
+
|
31
|
+
if !(defined?(RUBY_ENGINE) && 'jruby' == RUBY_ENGINE)
|
32
|
+
# Github flavored markdown in YARD documentation
|
33
|
+
# http://blog.nikosd.com/2011/11/github-flavored-markdown-in-yard.html
|
34
|
+
s.add_development_dependency 'yard'
|
35
|
+
s.add_development_dependency 'redcarpet', '2.3.0' # because 1.8
|
36
|
+
s.add_development_dependency 'github-markup'
|
37
|
+
end
|
30
38
|
|
31
39
|
# Coveralls test coverage tool
|
32
40
|
s.add_development_dependency 'coveralls'
|
@@ -53,9 +53,11 @@ module Docile
|
|
53
53
|
# Proxy all methods, excluding {NON_PROXIED_METHODS}, first to `receiver`
|
54
54
|
# and then to `fallback` if not found.
|
55
55
|
def method_missing(method, *args, &block)
|
56
|
-
@__receiver__.
|
57
|
-
|
58
|
-
|
56
|
+
if @__receiver__.respond_to?(method.to_sym)
|
57
|
+
@__receiver__.__send__(method.to_sym, *args, &block)
|
58
|
+
else
|
59
|
+
@__fallback__.__send__(method.to_sym, *args, &block)
|
60
|
+
end
|
59
61
|
end
|
60
62
|
end
|
61
63
|
end
|
data/lib/docile/version.rb
CHANGED
data/spec/docile_spec.rb
CHANGED
@@ -18,15 +18,15 @@ describe Docile do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'executes the block against the DSL context object' do
|
21
|
-
array.
|
21
|
+
expect(array).to eq([1, 3])
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'returns the DSL object after executing block against it' do
|
25
|
-
result.
|
25
|
+
expect(result).to eq(array)
|
26
26
|
end
|
27
27
|
|
28
28
|
it "doesn't proxy #__id__" do
|
29
|
-
Docile.dsl_eval(array) { __id__.
|
29
|
+
Docile.dsl_eval(array) { expect(__id__).not_to eq(array.__id__) }
|
30
30
|
end
|
31
31
|
|
32
32
|
it "raises NoMethodError if the DSL object doesn't implement the method" do
|
@@ -60,7 +60,7 @@ describe Docile do
|
|
60
60
|
end
|
61
61
|
|
62
62
|
it 'returns correctly built object' do
|
63
|
-
result.
|
63
|
+
expect(result).to eq(Pizza.new(true, false, true, :extra))
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
@@ -93,88 +93,104 @@ describe Docile do
|
|
93
93
|
|
94
94
|
it 'passes parameters to the block' do
|
95
95
|
parameterized(1,2,3) do |x,y,z|
|
96
|
-
x.
|
97
|
-
y.
|
98
|
-
z.
|
96
|
+
expect(x).to eq(1)
|
97
|
+
expect(y).to eq(2)
|
98
|
+
expect(z).to eq(3)
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
102
102
|
it 'finds parameters before methods' do
|
103
|
-
parameterized(1) { |a| a.
|
103
|
+
parameterized(1) { |a| expect(a).to eq(1) }
|
104
104
|
end
|
105
105
|
|
106
106
|
it 'find outer dsl parameters in inner dsl scope' do
|
107
107
|
parameterized(1,2,3) do |a,b,c|
|
108
108
|
inner_with_params(c) do |d,e|
|
109
|
-
a.
|
110
|
-
b.
|
111
|
-
c.
|
112
|
-
d.
|
113
|
-
e.
|
109
|
+
expect(a).to eq(1)
|
110
|
+
expect(b).to eq(2)
|
111
|
+
expect(c).to eq(3)
|
112
|
+
expect(d).to eq(c)
|
113
|
+
expect(e).to eq(:foo)
|
114
114
|
end
|
115
115
|
end
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|
119
|
+
class DSLWithNoMethod
|
120
|
+
def initialize(b); @b = b; end
|
121
|
+
attr_accessor :b
|
122
|
+
def push_element
|
123
|
+
@b.push 1
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
context 'when DSL have NoMethod error inside' do
|
128
|
+
it 'raise error from nil' do
|
129
|
+
Docile.dsl_eval(DSLWithNoMethod.new(nil)) do
|
130
|
+
expect { push_element }.to raise_error(NoMethodError, /undefined method `push' (for|on) nil:NilClass/)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
119
135
|
context 'when DSL blocks are nested' do
|
120
136
|
|
121
137
|
context 'method lookup' do
|
122
138
|
it 'finds method of outer dsl in outer dsl scope' do
|
123
|
-
outer { a.
|
139
|
+
outer { expect(a).to eq('a') }
|
124
140
|
end
|
125
141
|
|
126
142
|
it 'finds method of inner dsl in inner dsl scope' do
|
127
|
-
outer { inner { b.
|
143
|
+
outer { inner { expect(b).to eq('b') } }
|
128
144
|
end
|
129
145
|
|
130
146
|
it 'finds method of outer dsl in inner dsl scope' do
|
131
|
-
outer { inner { a.
|
147
|
+
outer { inner { expect(a).to eq('a') } }
|
132
148
|
end
|
133
149
|
|
134
150
|
it "finds method of block's context in outer dsl scope" do
|
135
151
|
def c; 'c'; end
|
136
|
-
outer { c.
|
152
|
+
outer { expect(c).to eq('c') }
|
137
153
|
end
|
138
154
|
|
139
155
|
it "finds method of block's context in inner dsl scope" do
|
140
156
|
def c; 'c'; end
|
141
|
-
outer { inner { c.
|
157
|
+
outer { inner { expect(c).to eq('c') } }
|
142
158
|
end
|
143
159
|
|
144
160
|
it 'finds method of outer dsl in preference to block context' do
|
145
161
|
def a; 'not a'; end
|
146
|
-
outer { a.
|
147
|
-
outer { inner { a.
|
162
|
+
outer { expect(a).to eq('a') }
|
163
|
+
outer { inner { expect(a).to eq('a') } }
|
148
164
|
end
|
149
165
|
end
|
150
166
|
|
151
167
|
context 'local variable lookup' do
|
152
168
|
it 'finds local variable from block context in outer dsl scope' do
|
153
169
|
foo = 'foo'
|
154
|
-
outer { foo.
|
170
|
+
outer { expect(foo).to eq('foo') }
|
155
171
|
end
|
156
172
|
|
157
173
|
it 'finds local variable from block definition in inner dsl scope' do
|
158
174
|
bar = 'bar'
|
159
|
-
outer { inner { bar.
|
175
|
+
outer { inner { expect(bar).to eq('bar') } }
|
160
176
|
end
|
161
177
|
end
|
162
178
|
|
163
179
|
context 'instance variable lookup' do
|
164
180
|
it 'finds instance variable from block definition in outer dsl scope' do
|
165
|
-
@iv1 = 'iv1'; outer { @iv1.
|
181
|
+
@iv1 = 'iv1'; outer { expect(@iv1).to eq('iv1') }
|
166
182
|
end
|
167
183
|
|
168
184
|
it "proxies instance variable assignments in block in outer dsl scope back into block's context" do
|
169
|
-
@iv1 = 'foo'; outer { @iv1 = 'bar' }; @iv1.
|
185
|
+
@iv1 = 'foo'; outer { @iv1 = 'bar' }; expect(@iv1).to eq('bar')
|
170
186
|
end
|
171
187
|
|
172
188
|
it 'finds instance variable from block definition in inner dsl scope' do
|
173
|
-
@iv2 = 'iv2'; outer { inner { @iv2.
|
189
|
+
@iv2 = 'iv2'; outer { inner { expect(@iv2).to eq('iv2') } }
|
174
190
|
end
|
175
191
|
|
176
192
|
it "proxies instance variable assignments in block in inner dsl scope back into block's context" do
|
177
|
-
@iv2 = 'foo'; outer { inner { @iv2 = 'bar' } }; @iv2.
|
193
|
+
@iv2 = 'foo'; outer { inner { @iv2 = 'bar' } }; expect(@iv2).to eq('bar')
|
178
194
|
end
|
179
195
|
end
|
180
196
|
|
@@ -224,7 +240,7 @@ describe Docile do
|
|
224
240
|
|
225
241
|
def x(y) ; "Got a #{y}"; end
|
226
242
|
respond '/third' do |third|
|
227
|
-
x(third).
|
243
|
+
expect(x(third)).to eq('Got a third thing')
|
228
244
|
end
|
229
245
|
|
230
246
|
fourth = nil
|
@@ -237,9 +253,9 @@ describe Docile do
|
|
237
253
|
send_request '/third', 'third thing'
|
238
254
|
send_request '/params', :b
|
239
255
|
|
240
|
-
@first.
|
241
|
-
@second.
|
242
|
-
fourth.
|
256
|
+
expect(@first).to eq(1)
|
257
|
+
expect(@second).to eq('Got a new ten speed')
|
258
|
+
expect(fourth).to eq(2)
|
243
259
|
end
|
244
260
|
|
245
261
|
end
|
@@ -260,11 +276,11 @@ describe Docile do
|
|
260
276
|
end
|
261
277
|
|
262
278
|
it "doesn't modify the original string" do
|
263
|
-
original.
|
279
|
+
expect(original).to eq("I'm immutable!")
|
264
280
|
end
|
265
281
|
|
266
282
|
it 'chains the commands in the block against the DSL context object' do
|
267
|
-
result.
|
283
|
+
expect(result).to eq("!ELBATUMMI M'I")
|
268
284
|
end
|
269
285
|
end
|
270
286
|
|
@@ -280,7 +296,7 @@ describe Docile do
|
|
280
296
|
end
|
281
297
|
|
282
298
|
it 'chains the commands in the block against the DSL context object' do
|
283
|
-
result.
|
299
|
+
expect(result).to eq(42)
|
284
300
|
end
|
285
301
|
end
|
286
302
|
end
|
@@ -307,15 +323,15 @@ describe Docile::FallbackContextProxy do
|
|
307
323
|
end
|
308
324
|
|
309
325
|
it 'returns proxied instance variables' do
|
310
|
-
subject.map(&:to_sym).
|
326
|
+
expect(subject.map(&:to_sym)).to include(:@foo)
|
311
327
|
end
|
312
328
|
|
313
329
|
it "doesn't return non-proxied instance variables" do
|
314
|
-
subject.map(&:to_sym).
|
330
|
+
expect(subject.map(&:to_sym)).not_to include(*excluded)
|
315
331
|
end
|
316
332
|
|
317
333
|
it 'preserves the type (String or Symbol) of names on this ruby version' do
|
318
|
-
actual_type_of_names.
|
334
|
+
expect(actual_type_of_names).to eq(expected_type_of_names)
|
319
335
|
end
|
320
336
|
end
|
321
337
|
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: docile
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marc Siegel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -16,28 +16,42 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 10.1.1
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 10.1.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 2.
|
33
|
+
version: 2.14.0
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 2.
|
40
|
+
version: 2.14.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: mime-types
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.25.1
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.25.1
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: yard
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -56,16 +70,16 @@ dependencies:
|
|
56
70
|
name: redcarpet
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
|
-
- - '
|
73
|
+
- - '='
|
60
74
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
75
|
+
version: 2.3.0
|
62
76
|
type: :development
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
|
-
- - '
|
80
|
+
- - '='
|
67
81
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
82
|
+
version: 2.3.0
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: github-markup
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -146,6 +160,5 @@ rubygems_version: 2.1.11
|
|
146
160
|
signing_key:
|
147
161
|
specification_version: 4
|
148
162
|
summary: Docile keeps your Ruby DSLs tame and well-behaved
|
149
|
-
test_files:
|
150
|
-
|
151
|
-
- spec/spec_helper.rb
|
163
|
+
test_files: []
|
164
|
+
has_rdoc:
|