docile 0.9.2 → 1.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.
- data/.travis.yml +11 -0
- data/.yardopts +1 -1
- data/Gemfile +8 -2
- data/LICENSE +1 -1
- data/README.md +11 -3
- data/Rakefile +18 -9
- data/docile.gemspec +4 -2
- data/lib/docile.rb +3 -3
- data/lib/docile/fallback_context_proxy.rb +2 -1
- data/lib/docile/version.rb +1 -1
- data/spec/docile_spec.rb +3 -2
- metadata +92 -61
data/.travis.yml
ADDED
data/.yardopts
CHANGED
data/Gemfile
CHANGED
@@ -1,4 +1,10 @@
|
|
1
|
-
source "
|
1
|
+
source "https://rubygems.org"
|
2
2
|
|
3
|
-
# Specify
|
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
|
+
end
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -8,12 +8,15 @@ 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
|
+
[](https://travis-ci.org/ms-ati/docile)
|
12
|
+
[](https://gemnasium.com/ms-ati/docile)
|
13
|
+
|
11
14
|
## Usage
|
12
15
|
|
13
16
|
Let's treat an Array's methods as its own DSL:
|
14
17
|
|
15
18
|
``` ruby
|
16
|
-
Docile.dsl_eval
|
19
|
+
Docile.dsl_eval([]) do
|
17
20
|
push 1
|
18
21
|
push 2
|
19
22
|
pop
|
@@ -36,7 +39,7 @@ Then you can use this same PizzaBuilder class as a DSL:
|
|
36
39
|
|
37
40
|
``` ruby
|
38
41
|
@sauce_level = :extra
|
39
|
-
pizza = Docile.dsl_eval
|
42
|
+
pizza = Docile.dsl_eval(PizzaBuilder.new) do
|
40
43
|
cheese
|
41
44
|
pepperoni
|
42
45
|
sauce @sauce_level
|
@@ -64,8 +67,13 @@ $ gem install docile
|
|
64
67
|
## Documentation
|
65
68
|
|
66
69
|
Documentation hosted on *rubydoc.info*: [Docile Documentation](http://rubydoc.info/gems/docile)
|
70
|
+
|
67
71
|
Or, read the code hosted on *github.com*: [Docile Code](https://github.com/ms-ati/docile)
|
68
72
|
|
73
|
+
## Status
|
74
|
+
|
75
|
+
Version 1.0 works on [all ruby versions](https://github.com/ms-ati/docile/blob/master/.travis.yml).
|
76
|
+
|
69
77
|
## Note on Patches/Pull Requests
|
70
78
|
|
71
79
|
* Fork the project.
|
@@ -79,4 +87,4 @@ Or, read the code hosted on *github.com*: [Docile Code](https://github.com/ms-at
|
|
79
87
|
|
80
88
|
## Copyright
|
81
89
|
|
82
|
-
Copyright (c)
|
90
|
+
Copyright (c) 2012 Marc Siegel. See LICENSE for details.
|
data/Rakefile
CHANGED
@@ -1,11 +1,20 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
|
-
require "
|
3
|
-
|
4
|
-
require
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
2
|
+
require "rspec/core/rake_task"
|
3
|
+
|
4
|
+
# Don't require doc generation gems on Travis
|
5
|
+
if ENV['CI'] != 'true'
|
6
|
+
require "github/markup"
|
7
|
+
require "redcarpet"
|
8
|
+
require "yard"
|
9
|
+
require "yard/rake/yardoc_task"
|
10
|
+
|
11
|
+
YARD::Rake::YardocTask.new do |t|
|
12
|
+
OTHER_PATHS = %w()
|
13
|
+
t.files = ['lib/**/*.rb', OTHER_PATHS]
|
14
|
+
t.options = %w(--markup-provider=redcarpet --markup=markdown --main=README.md)
|
15
|
+
end
|
11
16
|
end
|
17
|
+
|
18
|
+
RSpec::Core::RakeTask.new
|
19
|
+
|
20
|
+
task :default => [:spec]
|
data/docile.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.version = Docile::VERSION
|
8
8
|
s.authors = ["Marc Siegel"]
|
9
9
|
s.email = ["msiegel@usainnov.com"]
|
10
|
-
s.homepage = "http://
|
10
|
+
s.homepage = "http://ms-ati.github.com/docile/"
|
11
11
|
s.summary = "Docile keeps your Ruby DSL's tame and well-behaved"
|
12
12
|
s.description = "Docile turns any Ruby object into a DSL. Especially useful with the Builder pattern."
|
13
13
|
|
@@ -18,7 +18,9 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
|
21
|
-
|
21
|
+
# Running rspec tests from rake
|
22
|
+
s.add_development_dependency "rake", "~> 0.9.2"
|
23
|
+
s.add_development_dependency "rspec", "~> 2.11.0"
|
22
24
|
|
23
25
|
# Github flavored markdown in YARD documentation
|
24
26
|
# http://blog.nikosd.com/2011/11/github-flavored-markdown-in-yard.html
|
data/lib/docile.rb
CHANGED
@@ -14,9 +14,9 @@ module Docile
|
|
14
14
|
# end
|
15
15
|
# #=> [1, 3]
|
16
16
|
#
|
17
|
-
# @param dsl
|
18
|
-
# @param block [Proc]
|
19
|
-
# @return
|
17
|
+
# @param dsl [Object] an object whose methods represent a DSL
|
18
|
+
# @param block [Proc] a block to execute in the DSL context
|
19
|
+
# @return [Object] the dsl object, after execution of the block
|
20
20
|
def dsl_eval(dsl, &block)
|
21
21
|
block_context = eval("self", block.binding)
|
22
22
|
proxy_context = FallbackContextProxy.new(dsl, block_context)
|
@@ -30,7 +30,8 @@ module Docile
|
|
30
30
|
|
31
31
|
# Special case to allow proxy instance variables
|
32
32
|
def instance_variables
|
33
|
-
|
33
|
+
# Ruby 1.8.x returns string names, convert to symbols
|
34
|
+
super.map(&:to_sym) - NON_PROXIED_INSTANCE_VARIABLES.to_a
|
34
35
|
end
|
35
36
|
|
36
37
|
def method_missing(method, *args, &block)
|
data/lib/docile/version.rb
CHANGED
data/spec/docile_spec.rb
CHANGED
@@ -77,6 +77,7 @@ describe Docile do
|
|
77
77
|
it "should find method of outer dsl in preference to block context" do
|
78
78
|
def a; 'not a'; end
|
79
79
|
outer { a.should == 'a' }
|
80
|
+
outer { inner { a.should == 'a' } }
|
80
81
|
end
|
81
82
|
end
|
82
83
|
|
@@ -97,7 +98,7 @@ describe Docile do
|
|
97
98
|
@iv1 = 'iv1'; outer { @iv1.should == 'iv1' }
|
98
99
|
end
|
99
100
|
|
100
|
-
it "should
|
101
|
+
it "should proxy instance variable assignments in block in outer dsl scope back into block's context" do
|
101
102
|
@iv1 = 'foo'; outer { @iv1 = 'bar' }; @iv1.should == 'bar'
|
102
103
|
end
|
103
104
|
|
@@ -105,7 +106,7 @@ describe Docile do
|
|
105
106
|
@iv2 = 'iv2'; outer { inner { @iv2.should == 'iv2' } }
|
106
107
|
end
|
107
108
|
|
108
|
-
it "should
|
109
|
+
it "should proxy instance variable assignments in block in inner dsl scope back into block's context" do
|
109
110
|
@iv2 = 'foo'; outer { inner { @iv2 = 'bar' } }; @iv2.should == 'bar'
|
110
111
|
end
|
111
112
|
end
|
metadata
CHANGED
@@ -1,72 +1,106 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: docile
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
4
5
|
prerelease:
|
5
|
-
version: 0.9.2
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Marc Siegel
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
date: 2012-10-29 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.9.2
|
22
|
+
type: :development
|
17
23
|
prerelease: false
|
18
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.9.2
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
19
33
|
none: false
|
20
|
-
requirements:
|
34
|
+
requirements:
|
21
35
|
- - ~>
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 2.
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 2.11.0
|
24
38
|
type: :development
|
25
|
-
version_requirements: *id001
|
26
|
-
- !ruby/object:Gem::Dependency
|
27
|
-
name: yard
|
28
39
|
prerelease: false
|
29
|
-
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
41
|
none: false
|
31
|
-
requirements:
|
32
|
-
- -
|
33
|
-
- !ruby/object:Gem::Version
|
34
|
-
version:
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 2.11.0
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: yard
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
35
54
|
type: :development
|
36
|
-
version_requirements: *id002
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: redcarpet
|
39
55
|
prerelease: false
|
40
|
-
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
57
|
none: false
|
42
|
-
requirements:
|
43
|
-
- -
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version:
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: redcarpet
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
46
70
|
type: :development
|
47
|
-
version_requirements: *id003
|
48
|
-
- !ruby/object:Gem::Dependency
|
49
|
-
name: github-markup
|
50
71
|
prerelease: false
|
51
|
-
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
73
|
none: false
|
53
|
-
requirements:
|
54
|
-
- -
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
version:
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: github-markup
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
57
86
|
type: :development
|
58
|
-
|
59
|
-
|
60
|
-
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
description: Docile turns any Ruby object into a DSL. Especially useful with the Builder
|
95
|
+
pattern.
|
96
|
+
email:
|
61
97
|
- msiegel@usainnov.com
|
62
98
|
executables: []
|
63
|
-
|
64
99
|
extensions: []
|
65
|
-
|
66
100
|
extra_rdoc_files: []
|
67
|
-
|
68
|
-
files:
|
101
|
+
files:
|
69
102
|
- .gitignore
|
103
|
+
- .travis.yml
|
70
104
|
- .yardopts
|
71
105
|
- Gemfile
|
72
106
|
- LICENSE
|
@@ -78,34 +112,31 @@ files:
|
|
78
112
|
- lib/docile/version.rb
|
79
113
|
- spec/docile_spec.rb
|
80
114
|
- spec/spec_helper.rb
|
81
|
-
homepage: http://
|
115
|
+
homepage: http://ms-ati.github.com/docile/
|
82
116
|
licenses: []
|
83
|
-
|
84
117
|
post_install_message:
|
85
118
|
rdoc_options: []
|
86
|
-
|
87
|
-
require_paths:
|
119
|
+
require_paths:
|
88
120
|
- lib
|
89
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
121
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
90
122
|
none: false
|
91
|
-
requirements:
|
92
|
-
- -
|
93
|
-
- !ruby/object:Gem::Version
|
94
|
-
version:
|
95
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - ! '>='
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
127
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
128
|
none: false
|
97
|
-
requirements:
|
98
|
-
- -
|
99
|
-
- !ruby/object:Gem::Version
|
100
|
-
version:
|
129
|
+
requirements:
|
130
|
+
- - ! '>='
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
101
133
|
requirements: []
|
102
|
-
|
103
134
|
rubyforge_project: docile
|
104
|
-
rubygems_version: 1.8.
|
135
|
+
rubygems_version: 1.8.21
|
105
136
|
signing_key:
|
106
137
|
specification_version: 3
|
107
138
|
summary: Docile keeps your Ruby DSL's tame and well-behaved
|
108
|
-
test_files:
|
139
|
+
test_files:
|
109
140
|
- spec/docile_spec.rb
|
110
141
|
- spec/spec_helper.rb
|
111
142
|
has_rdoc:
|