docile 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.coveralls.yml +2 -0
- data/.gitignore +1 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +2 -1
- data/Gemfile +2 -1
- data/HISTORY.md +4 -0
- data/README.md +3 -0
- data/docile.gemspec +3 -0
- data/lib/docile/fallback_context_proxy.rb +1 -14
- data/lib/docile/version.rb +1 -1
- data/spec/docile_spec.rb +13 -2
- data/spec/spec_helper.rb +9 -0
- metadata +110 -89
- data/.rvmrc +0 -48
data/.coveralls.yml
ADDED
data/.gitignore
CHANGED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
docile
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.0.0-p247
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/HISTORY.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# HISTORY
|
2
2
|
|
3
|
+
## [v1.0.3 (Jul 6, 2013)](http://github.com/ms-ati/docile/compare/v1.0.2...v1.0.3)
|
4
|
+
|
5
|
+
- instrument code coverage via SimpleCov and publish to Coveralls.io
|
6
|
+
|
3
7
|
## [v1.0.2 (Apr 1, 2013)](http://github.com/ms-ati/docile/compare/v1.0.1...v1.0.2)
|
4
8
|
|
5
9
|
- allow passing parameters to DSL blocks (thanks @dslh!)
|
data/README.md
CHANGED
@@ -8,8 +8,11 @@ Let's make our Ruby DSLs more docile...
|
|
8
8
|
|
9
9
|
[1]: http://www.google.com/search?q=docile+definition "Google"
|
10
10
|
|
11
|
+
[![Gem Version](https://badge.fury.io/rb/docile.png)](http://badge.fury.io/rb/docile)
|
11
12
|
[![Build Status](https://travis-ci.org/ms-ati/docile.png)](https://travis-ci.org/ms-ati/docile)
|
12
13
|
[![Dependency Status](https://gemnasium.com/ms-ati/docile.png)](https://gemnasium.com/ms-ati/docile)
|
14
|
+
[![Code Climate](https://codeclimate.com/github/ms-ati/docile.png)](https://codeclimate.com/github/ms-ati/docile)
|
15
|
+
[![Coverage Status](https://coveralls.io/repos/ms-ati/docile/badge.png)](https://coveralls.io/r/ms-ati/docile)
|
13
16
|
|
14
17
|
## Basic Usage
|
15
18
|
|
data/docile.gemspec
CHANGED
@@ -19,15 +19,6 @@ module Docile
|
|
19
19
|
@__fallback__ = fallback
|
20
20
|
end
|
21
21
|
|
22
|
-
def id
|
23
|
-
@__receiver__.__send__(:id)
|
24
|
-
end
|
25
|
-
|
26
|
-
# Special case due to `Kernel#sub`'s existence
|
27
|
-
def sub(*args, &block)
|
28
|
-
__proxy_method__(:sub, *args, &block)
|
29
|
-
end
|
30
|
-
|
31
22
|
# Special case to allow proxy instance variables
|
32
23
|
def instance_variables
|
33
24
|
# Ruby 1.8.x returns string names, convert to symbols
|
@@ -42,11 +33,7 @@ module Docile
|
|
42
33
|
begin
|
43
34
|
@__receiver__.__send__(method.to_sym, *args, &block)
|
44
35
|
rescue ::NoMethodError => e
|
45
|
-
|
46
|
-
@__fallback__.__send__(method.to_sym, *args, &block)
|
47
|
-
rescue ::NoMethodError
|
48
|
-
raise(e)
|
49
|
-
end
|
36
|
+
@__fallback__.__send__(method.to_sym, *args, &block)
|
50
37
|
end
|
51
38
|
end
|
52
39
|
end
|
data/lib/docile/version.rb
CHANGED
data/spec/docile_spec.rb
CHANGED
@@ -13,6 +13,15 @@ describe Docile do
|
|
13
13
|
end.should == [1, 3]
|
14
14
|
end
|
15
15
|
|
16
|
+
it "should use the __id__ method of the proxy object" do
|
17
|
+
arr = []
|
18
|
+
Docile.dsl_eval(arr) { __id__.should_not == arr.__id__ }
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should raise NoMethodError if the DSL object doesn't implement the method" do
|
22
|
+
expect { Docile.dsl_eval([]) { no_such_method } }.to raise_error(NoMethodError)
|
23
|
+
end
|
24
|
+
|
16
25
|
Pizza = Struct.new(:cheese, :pepperoni, :bacon, :sauce)
|
17
26
|
|
18
27
|
class PizzaBuilder
|
@@ -42,11 +51,12 @@ describe Docile do
|
|
42
51
|
class OuterDSL
|
43
52
|
def initialize; @a = 'a'; end
|
44
53
|
attr_accessor :a
|
54
|
+
|
45
55
|
def inner(&block)
|
46
56
|
Docile.dsl_eval(InnerDSL.new, &block)
|
47
57
|
end
|
48
58
|
|
49
|
-
def inner_with_params(param
|
59
|
+
def inner_with_params(param, &block)
|
50
60
|
Docile.dsl_eval(InnerDSL.new, param, :foo, &block)
|
51
61
|
end
|
52
62
|
end
|
@@ -55,7 +65,7 @@ describe Docile do
|
|
55
65
|
Docile.dsl_eval(OuterDSL.new, &block)
|
56
66
|
end
|
57
67
|
|
58
|
-
def parameterized(*args
|
68
|
+
def parameterized(*args, &block)
|
59
69
|
Docile.dsl_eval(OuterDSL.new, *args, &block)
|
60
70
|
end
|
61
71
|
|
@@ -204,6 +214,7 @@ describe Docile do
|
|
204
214
|
@second.should == 'Got a new ten speed'
|
205
215
|
fourth.should == 2
|
206
216
|
end
|
217
|
+
|
207
218
|
end
|
208
219
|
|
209
220
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,6 +1,15 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'rspec'
|
3
3
|
require 'singleton'
|
4
|
+
require 'simplecov'
|
5
|
+
require 'coveralls'
|
6
|
+
|
7
|
+
# Both local SimpleCov and publish to Coveralls.io
|
8
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
9
|
+
SimpleCov::Formatter::HTMLFormatter,
|
10
|
+
Coveralls::SimpleCov::Formatter
|
11
|
+
]
|
12
|
+
SimpleCov.start
|
4
13
|
|
5
14
|
test_dir = File.dirname(__FILE__)
|
6
15
|
$LOAD_PATH.unshift test_dir unless $LOAD_PATH.include?(test_dir)
|
metadata
CHANGED
@@ -1,106 +1,124 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: docile
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 3
|
10
|
+
version: 1.0.3
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Marc Siegel
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
17
|
+
|
18
|
+
date: 2013-07-06 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
15
21
|
name: rake
|
16
|
-
|
22
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
17
23
|
none: false
|
18
|
-
requirements:
|
19
|
-
- -
|
20
|
-
- !ruby/object:Gem::Version
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
hash: 63
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
- 9
|
31
|
+
- 2
|
21
32
|
version: 0.9.2
|
22
|
-
type: :development
|
23
33
|
prerelease: false
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
- - ! '>='
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: 0.9.2
|
30
|
-
- !ruby/object:Gem::Dependency
|
34
|
+
type: :development
|
35
|
+
requirement: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
31
37
|
name: rspec
|
32
|
-
|
38
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
33
39
|
none: false
|
34
|
-
requirements:
|
35
|
-
- -
|
36
|
-
- !ruby/object:Gem::Version
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 35
|
44
|
+
segments:
|
45
|
+
- 2
|
46
|
+
- 11
|
47
|
+
- 0
|
37
48
|
version: 2.11.0
|
38
|
-
type: :development
|
39
49
|
prerelease: false
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
- - ! '>='
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: 2.11.0
|
46
|
-
- !ruby/object:Gem::Dependency
|
50
|
+
type: :development
|
51
|
+
requirement: *id002
|
52
|
+
- !ruby/object:Gem::Dependency
|
47
53
|
name: yard
|
48
|
-
|
54
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
49
55
|
none: false
|
50
|
-
requirements:
|
51
|
-
- -
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
|
54
|
-
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 3
|
60
|
+
segments:
|
61
|
+
- 0
|
62
|
+
version: "0"
|
55
63
|
prerelease: false
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
- - ! '>='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
- !ruby/object:Gem::Dependency
|
64
|
+
type: :development
|
65
|
+
requirement: *id003
|
66
|
+
- !ruby/object:Gem::Dependency
|
63
67
|
name: redcarpet
|
64
|
-
|
68
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
65
69
|
none: false
|
66
|
-
requirements:
|
67
|
-
- -
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
|
70
|
-
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
hash: 3
|
74
|
+
segments:
|
75
|
+
- 0
|
76
|
+
version: "0"
|
71
77
|
prerelease: false
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
- - ! '>='
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: '0'
|
78
|
-
- !ruby/object:Gem::Dependency
|
78
|
+
type: :development
|
79
|
+
requirement: *id004
|
80
|
+
- !ruby/object:Gem::Dependency
|
79
81
|
name: github-markup
|
80
|
-
|
82
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
81
83
|
none: false
|
82
|
-
requirements:
|
83
|
-
- -
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
|
86
|
-
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
hash: 3
|
88
|
+
segments:
|
89
|
+
- 0
|
90
|
+
version: "0"
|
87
91
|
prerelease: false
|
88
|
-
|
92
|
+
type: :development
|
93
|
+
requirement: *id005
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: coveralls
|
96
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
89
97
|
none: false
|
90
|
-
requirements:
|
91
|
-
- -
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
hash: 3
|
102
|
+
segments:
|
103
|
+
- 0
|
104
|
+
version: "0"
|
105
|
+
prerelease: false
|
106
|
+
type: :development
|
107
|
+
requirement: *id006
|
108
|
+
description: Docile turns any Ruby object into a DSL. Especially useful with the Builder pattern.
|
109
|
+
email:
|
97
110
|
- msiegel@usainnov.com
|
98
111
|
executables: []
|
112
|
+
|
99
113
|
extensions: []
|
114
|
+
|
100
115
|
extra_rdoc_files: []
|
101
|
-
|
116
|
+
|
117
|
+
files:
|
118
|
+
- .coveralls.yml
|
102
119
|
- .gitignore
|
103
|
-
- .
|
120
|
+
- .ruby-gemset
|
121
|
+
- .ruby-version
|
104
122
|
- .travis.yml
|
105
123
|
- .yardopts
|
106
124
|
- Gemfile
|
@@ -116,35 +134,38 @@ files:
|
|
116
134
|
- spec/spec_helper.rb
|
117
135
|
homepage: http://ms-ati.github.com/docile/
|
118
136
|
licenses: []
|
137
|
+
|
119
138
|
post_install_message:
|
120
139
|
rdoc_options: []
|
121
|
-
|
140
|
+
|
141
|
+
require_paths:
|
122
142
|
- lib
|
123
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
143
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
124
144
|
none: false
|
125
|
-
requirements:
|
126
|
-
- -
|
127
|
-
- !ruby/object:Gem::Version
|
128
|
-
|
129
|
-
segments:
|
145
|
+
requirements:
|
146
|
+
- - ">="
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
hash: 3
|
149
|
+
segments:
|
130
150
|
- 0
|
131
|
-
|
132
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
|
+
version: "0"
|
152
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
153
|
none: false
|
134
|
-
requirements:
|
135
|
-
- -
|
136
|
-
- !ruby/object:Gem::Version
|
137
|
-
|
138
|
-
segments:
|
154
|
+
requirements:
|
155
|
+
- - ">="
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
hash: 3
|
158
|
+
segments:
|
139
159
|
- 0
|
140
|
-
|
160
|
+
version: "0"
|
141
161
|
requirements: []
|
162
|
+
|
142
163
|
rubyforge_project: docile
|
143
164
|
rubygems_version: 1.8.25
|
144
165
|
signing_key:
|
145
166
|
specification_version: 3
|
146
167
|
summary: Docile keeps your Ruby DSL's tame and well-behaved
|
147
|
-
test_files:
|
168
|
+
test_files:
|
148
169
|
- spec/docile_spec.rb
|
149
170
|
- spec/spec_helper.rb
|
150
171
|
has_rdoc:
|
data/.rvmrc
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
|
3
|
-
# This is an RVM Project .rvmrc file, used to automatically load the ruby
|
4
|
-
# development environment upon cd'ing into the directory
|
5
|
-
|
6
|
-
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
|
7
|
-
# Only full ruby name is supported here, for short names use:
|
8
|
-
# echo "rvm use 1.9.3" > .rvmrc
|
9
|
-
environment_id="ruby-1.9.3-p385@docile"
|
10
|
-
|
11
|
-
# Uncomment the following lines if you want to verify rvm version per project
|
12
|
-
# rvmrc_rvm_version="1.18.8 (stable)" # 1.10.1 seams as a safe start
|
13
|
-
# eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
|
14
|
-
# echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
|
15
|
-
# return 1
|
16
|
-
# }
|
17
|
-
|
18
|
-
# First we attempt to load the desired environment directly from the environment
|
19
|
-
# file. This is very fast and efficient compared to running through the entire
|
20
|
-
# CLI and selector. If you want feedback on which environment was used then
|
21
|
-
# insert the word 'use' after --create as this triggers verbose mode.
|
22
|
-
if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
|
23
|
-
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
|
24
|
-
then
|
25
|
-
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
|
26
|
-
[[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
|
27
|
-
\. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
|
28
|
-
else
|
29
|
-
# If the environment file has not yet been created, use the RVM CLI to select.
|
30
|
-
rvm --create "$environment_id" || {
|
31
|
-
echo "Failed to create RVM environment '${environment_id}'."
|
32
|
-
return 1
|
33
|
-
}
|
34
|
-
fi
|
35
|
-
|
36
|
-
# If you use bundler, this might be useful to you:
|
37
|
-
# if [[ -s Gemfile ]] && {
|
38
|
-
# ! builtin command -v bundle >/dev/null ||
|
39
|
-
# builtin command -v bundle | GREP_OPTIONS= \grep $rvm_path/bin/bundle >/dev/null
|
40
|
-
# }
|
41
|
-
# then
|
42
|
-
# printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
|
43
|
-
# gem install bundler
|
44
|
-
# fi
|
45
|
-
# if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
|
46
|
-
# then
|
47
|
-
# bundle install | GREP_OPTIONS= \grep -vE '^Using|Your bundle is complete'
|
48
|
-
# fi
|