docile 1.3.0 → 1.3.5
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/.travis.yml +12 -15
- data/Gemfile +1 -1
- data/HISTORY.md +33 -2
- data/LICENSE +1 -1
- data/README.md +8 -4
- data/docile.gemspec +1 -0
- data/lib/docile.rb +7 -0
- data/lib/docile/backtrace_filter.rb +22 -0
- data/lib/docile/chaining_fallback_context_proxy.rb +2 -0
- data/lib/docile/execution.rb +3 -0
- data/lib/docile/fallback_context_proxy.rb +16 -2
- data/lib/docile/version.rb +1 -1
- data/on_what.rb +4 -0
- metadata +21 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3293fa913b3cac5e74f72a8c434b99917a9f7f131fd4afd29688a9dc000bb7dc
|
4
|
+
data.tar.gz: 4134e1db62d390e98d06752586a17d39d60417ec32eafb4b41f8f03ce9e8b510
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ceb48adefed44844c52059c3daebb27d1c5a23d729c9d8a17fa6b54093e374c6856e5bc2bfeff702cc1a315d511542be012b72f306a2cfb2c69252a1229ec45
|
7
|
+
data.tar.gz: 6f1c8e2bc1ed5f66510402454173147f951753d5161095e43894e66ffe689ea0045bbb4c02558ef142bfd54a7bd898acf637c49b4bdfa497a11b4298871d78fb
|
data/.travis.yml
CHANGED
@@ -1,34 +1,31 @@
|
|
1
1
|
language: ruby
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
# See https://docs.travis-ci.com/user/languages/ruby/#Rubinius
|
7
|
-
dist: trusty
|
3
|
+
branches:
|
4
|
+
only:
|
5
|
+
- master
|
8
6
|
|
9
7
|
rvm:
|
10
8
|
# MRI
|
11
9
|
- ruby-head
|
10
|
+
- 2.7
|
11
|
+
- 2.6
|
12
12
|
- 2.5
|
13
13
|
- 2.4
|
14
14
|
- 2.3
|
15
15
|
- 2.2
|
16
16
|
- 2.1
|
17
17
|
- 1.9.3
|
18
|
-
- 1.8.7
|
19
|
-
- ree
|
20
18
|
# JRuby
|
21
19
|
- jruby-head
|
22
|
-
- jruby-9.
|
23
|
-
|
24
|
-
-
|
25
|
-
-
|
26
|
-
# Rubinius
|
27
|
-
- rubinius-3
|
20
|
+
- jruby-9.2
|
21
|
+
# Truffleruby
|
22
|
+
- truffleruby-head
|
23
|
+
- truffleruby-20.3.0
|
28
24
|
|
29
|
-
|
25
|
+
jobs:
|
30
26
|
allow_failures:
|
31
27
|
- rvm: ruby-head
|
32
28
|
- rvm: jruby-head
|
33
|
-
- rvm:
|
29
|
+
- rvm: truffleruby-head
|
30
|
+
|
34
31
|
fast_finish: true
|
data/Gemfile
CHANGED
@@ -2,7 +2,7 @@ require File.expand_path("on_what", File.dirname(__FILE__))
|
|
2
2
|
source "https://rubygems.org"
|
3
3
|
|
4
4
|
# Travis-only dependencies go here
|
5
|
-
if on_travis? && !
|
5
|
+
if on_travis? && !on_less_than_2_3? && !on_rubinius?
|
6
6
|
group :test do
|
7
7
|
gem "codecov", ">= 0.0.9", :require => false
|
8
8
|
end
|
data/HISTORY.md
CHANGED
@@ -1,8 +1,39 @@
|
|
1
1
|
# HISTORY
|
2
2
|
|
3
|
-
## [Unreleased changes](http://github.com/ms-ati/docile/compare/v1.3.
|
3
|
+
## [Unreleased changes](http://github.com/ms-ati/docile/compare/v1.3.5...master)
|
4
4
|
|
5
|
-
|
5
|
+
...
|
6
|
+
|
7
|
+
## [v1.3.5 (Jan 13, 2021)](http://github.com/ms-ati/docile/compare/v1.3.4...v1.3.5)
|
8
|
+
|
9
|
+
- Special thanks to Jochen Seeber (@jochenseeber):
|
10
|
+
- Fix remaining delegation on Ruby 2.7 (PR #62)
|
11
|
+
- Remove support for Ruby 1.8.7 and REE, because they
|
12
|
+
[are no longer runnable on Travis CI](https://travis-ci.community/t/ruby-1-8-7-and-ree-builds-broken-by-ssl-certificate-failure/10866)
|
13
|
+
- Announce that continued support for any EOL Ruby versions (that is, versions
|
14
|
+
prior to Ruby 2.5 as of Jan 13 2021) will be decided on **Feb 1, 2021**
|
15
|
+
based on comments to [issue #58](https://github.com/ms-ati/docile/issues/58)
|
16
|
+
|
17
|
+
## [v1.3.4 (Dec 22, 2020)](http://github.com/ms-ati/docile/compare/v1.3.3...v1.3.4)
|
18
|
+
|
19
|
+
- Special thanks to Benoit Daloze (@eregon):
|
20
|
+
- Fix delegation on Ruby 2.7 (issues #45 and #44, PR #52)
|
21
|
+
|
22
|
+
## [v1.3.3 (Dec 18, 2020)](http://github.com/ms-ati/docile/compare/v1.3.2...v1.3.3)
|
23
|
+
|
24
|
+
- Special thanks (again!) to Taichi Ishitani (@taichi-ishitani):
|
25
|
+
- Fix keyword arg warnings on Ruby 2.7 (issue #44, PR #45)
|
26
|
+
- Filter Docile's source files from backtrace (issue #35, PR #36)
|
27
|
+
|
28
|
+
## [v1.3.2 (Jun 12, 2019)](http://github.com/ms-ati/docile/compare/v1.3.1...v1.3.2)
|
29
|
+
|
30
|
+
- Special thanks (again!) to Taichi Ishitani (@taichi-ishitani):
|
31
|
+
- Fix for DSL object is replaced when #dsl_eval is nested (#33, PR #34)
|
32
|
+
|
33
|
+
## [v1.3.1 (May 24, 2018)](http://github.com/ms-ati/docile/compare/v1.3.0...v1.3.1)
|
34
|
+
|
35
|
+
- Special thanks to Taichi Ishitani (@taichi-ishitani):
|
36
|
+
- Fix for when DSL object is also the block's context (#30)
|
6
37
|
|
7
38
|
## [v1.3.0 (Feb 7, 2018)](http://github.com/ms-ati/docile/compare/v1.2.0...v1.3.0)
|
8
39
|
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## ⚠️WARNING⚠️, 🔴IMPORTANT❗🔴
|
2
|
+
### Using Docile on an [end-of-life Ruby version (< **2.5**)](https://www.ruby-lang.org/en/downloads/branches/)?
|
3
|
+
#### Please comment on [issue #58](https://github.com/ms-ati/docile/issues/58) this month 📅!
|
4
|
+
We'll decide which Ruby versions to continue supporting on **Feb 1st 2021**.
|
5
|
+
|
1
6
|
# Docile
|
2
7
|
|
3
8
|
[](https://rubygems.org/gems/docile)
|
@@ -9,7 +14,6 @@
|
|
9
14
|
|
10
15
|
[](https://travis-ci.org/ms-ati/docile)
|
11
16
|
[](https://codecov.io/github/ms-ati/docile)
|
12
|
-
[](https://gemnasium.com/ms-ati/docile)
|
13
17
|
[](https://codeclimate.com/github/ms-ati/docile/maintainability)
|
14
18
|
|
15
19
|
Ruby makes it possible to create very expressive **Domain Specific
|
@@ -82,7 +86,7 @@ In short: **No**.
|
|
82
86
|
Not if you want the code in the block to be able to refer to anything
|
83
87
|
the block would normally have access to from the surrounding context.
|
84
88
|
|
85
|
-
Let's be very specific. Docile internally uses `instance_exec` (see [execution.rb#
|
89
|
+
Let's be very specific. Docile internally uses `instance_exec` (see [execution.rb#26](lib/docile/execution.rb#L26)), adding a small layer to support referencing *local variables*, *instance variables*, and *methods* from the _block's context_ **or** the target _object's context_, interchangeably. This is "**the hard part**", where most folks making a DSL in Ruby throw up their hands.
|
86
90
|
|
87
91
|
For example:
|
88
92
|
|
@@ -352,7 +356,7 @@ $ gem install docile
|
|
352
356
|
|
353
357
|
## Status
|
354
358
|
|
355
|
-
Works on [all ruby versions since 1.
|
359
|
+
Works on [all ruby versions since 1.9.3](https://github.com/ms-ati/docile/blob/master/.travis.yml), or so Travis CI [tells us](https://travis-ci.org/ms-ati/docile).
|
356
360
|
|
357
361
|
Used by some pretty cool gems to implement their DSLs, notably including [SimpleCov](https://github.com/colszowka/simplecov). Keep an eye out for new gems using Docile at the [Ruby Toolbox](https://www.ruby-toolbox.com/projects/docile).
|
358
362
|
|
@@ -375,7 +379,7 @@ Docile releases follow [Semantic Versioning 2.0.0](https://semver.org/spec/v2.0.
|
|
375
379
|
|
376
380
|
## Copyright & License
|
377
381
|
|
378
|
-
Copyright (c) 2012-
|
382
|
+
Copyright (c) 2012-2021 Marc Siegel.
|
379
383
|
|
380
384
|
Licensed under the [MIT License](http://choosealicense.com/licenses/mit/), see [LICENSE](LICENSE) for details.
|
381
385
|
|
data/docile.gemspec
CHANGED
@@ -31,6 +31,7 @@ Gem::Specification.new do |s|
|
|
31
31
|
s.add_development_dependency "rake", "~> 10.5" if on_less_than_1_9_3? # Pin compatible rake on old rubies, see: https://github.com/travis-ci/travis.rb/issues/380
|
32
32
|
s.add_development_dependency "rake", "< 11.0" unless on_less_than_1_9_3? # See http://stackoverflow.com/questions/35893584/nomethoderror-undefined-method-last-comment-after-upgrading-to-rake-11
|
33
33
|
s.add_development_dependency "rspec", "~> 3.0"
|
34
|
+
s.add_development_dependency "rspec-expectations", "!= 3.8.3" # Workaround for RSpec's issue, see: https://github.com/rspec/rspec-expectations/issues/1111
|
34
35
|
|
35
36
|
# Run code coverage where possible - not on Rubinius
|
36
37
|
unless on_rubinius?
|
data/lib/docile.rb
CHANGED
@@ -2,6 +2,7 @@ require "docile/version"
|
|
2
2
|
require "docile/execution"
|
3
3
|
require "docile/fallback_context_proxy"
|
4
4
|
require "docile/chaining_fallback_context_proxy"
|
5
|
+
require "docile/backtrace_filter"
|
5
6
|
|
6
7
|
# Docile keeps your Ruby DSLs tame and well-behaved.
|
7
8
|
module Docile
|
@@ -43,6 +44,8 @@ module Docile
|
|
43
44
|
exec_in_proxy_context(dsl, FallbackContextProxy, *args, &block)
|
44
45
|
dsl
|
45
46
|
end
|
47
|
+
|
48
|
+
ruby2_keywords :dsl_eval if respond_to?(:ruby2_keywords, true)
|
46
49
|
module_function :dsl_eval
|
47
50
|
|
48
51
|
# Execute a block in the context of an object whose methods represent the
|
@@ -82,6 +85,8 @@ module Docile
|
|
82
85
|
def dsl_eval_with_block_return(dsl, *args, &block)
|
83
86
|
exec_in_proxy_context(dsl, FallbackContextProxy, *args, &block)
|
84
87
|
end
|
88
|
+
|
89
|
+
ruby2_keywords :dsl_eval_with_block_return if respond_to?(:ruby2_keywords, true)
|
85
90
|
module_function :dsl_eval_with_block_return
|
86
91
|
|
87
92
|
# Execute a block in the context of an immutable object whose methods,
|
@@ -119,5 +124,7 @@ module Docile
|
|
119
124
|
def dsl_eval_immutable(dsl, *args, &block)
|
120
125
|
exec_in_proxy_context(dsl, ChainingFallbackContextProxy, *args, &block)
|
121
126
|
end
|
127
|
+
|
128
|
+
ruby2_keywords :dsl_eval_immutable if respond_to?(:ruby2_keywords, true)
|
122
129
|
module_function :dsl_eval_immutable
|
123
130
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Docile
|
2
|
+
# @api private
|
3
|
+
#
|
4
|
+
# This is used to remove entries pointing to Docile's source files
|
5
|
+
# from {Exception#backtrace} and {Exception#backtrace_locations}.
|
6
|
+
#
|
7
|
+
# If {NoMethodError} is caught then the exception object will be extended
|
8
|
+
# by this module to add filter functionalities.
|
9
|
+
module BacktraceFilter
|
10
|
+
FILTER_PATTERN = /lib\/docile/
|
11
|
+
|
12
|
+
def backtrace
|
13
|
+
super.select { |trace| trace !~ FILTER_PATTERN }
|
14
|
+
end
|
15
|
+
|
16
|
+
if ::Exception.public_method_defined?(:backtrace_locations)
|
17
|
+
def backtrace_locations
|
18
|
+
super.select { |location| location.absolute_path !~ FILTER_PATTERN }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/docile/execution.rb
CHANGED
@@ -30,11 +30,14 @@ module Docile
|
|
30
30
|
end
|
31
31
|
|
32
32
|
block_context.instance_variables.each do |ivar|
|
33
|
+
next unless proxy_context.instance_variables.include?(ivar)
|
33
34
|
value_from_dsl_proxy = proxy_context.instance_variable_get(ivar)
|
34
35
|
block_context.instance_variable_set(ivar, value_from_dsl_proxy)
|
35
36
|
end
|
36
37
|
end
|
37
38
|
end
|
39
|
+
|
40
|
+
ruby2_keywords :exec_in_proxy_context if respond_to?(:ruby2_keywords, true)
|
38
41
|
module_function :exec_in_proxy_context
|
39
42
|
end
|
40
43
|
end
|
@@ -21,6 +21,10 @@ module Docile
|
|
21
21
|
:instance_variable_get, :instance_variable_set,
|
22
22
|
:remove_instance_variable]
|
23
23
|
|
24
|
+
# The set of methods which will **not** fallback from the block's context
|
25
|
+
# to the dsl object.
|
26
|
+
NON_FALLBACK_METHODS = Set[:class, :self, :respond_to?, :instance_of?]
|
27
|
+
|
24
28
|
# The set of instance variables which are local to this object and hidden.
|
25
29
|
# All other instance variables will be copied in and out of this object
|
26
30
|
# from the scope in which this proxy was created.
|
@@ -49,13 +53,16 @@ module Docile
|
|
49
53
|
# contain calls to methods on the DSL object.
|
50
54
|
singleton_class.
|
51
55
|
send(:define_method, :method_missing) do |method, *args, &block|
|
52
|
-
|
56
|
+
m = method.to_sym
|
57
|
+
if !NON_FALLBACK_METHODS.include?(m) && !fallback.respond_to?(m) && receiver.respond_to?(m)
|
53
58
|
receiver.__send__(method.to_sym, *args, &block)
|
54
59
|
else
|
55
60
|
super(method, *args, &block)
|
56
61
|
end
|
57
62
|
end
|
58
63
|
|
64
|
+
singleton_class.send(:ruby2_keywords, :method_missing) if singleton_class.respond_to?(:ruby2_keywords, true)
|
65
|
+
|
59
66
|
# instrument a helper method to remove the above instrumentation
|
60
67
|
singleton_class.
|
61
68
|
send(:define_method, :__docile_undo_fallback__) do
|
@@ -81,8 +88,15 @@ module Docile
|
|
81
88
|
if @__receiver__.respond_to?(method.to_sym)
|
82
89
|
@__receiver__.__send__(method.to_sym, *args, &block)
|
83
90
|
else
|
84
|
-
|
91
|
+
begin
|
92
|
+
@__fallback__.__send__(method.to_sym, *args, &block)
|
93
|
+
rescue NoMethodError => e
|
94
|
+
e.extend(BacktraceFilter)
|
95
|
+
raise e
|
96
|
+
end
|
85
97
|
end
|
86
98
|
end
|
99
|
+
|
100
|
+
ruby2_keywords :method_missing if respond_to?(:ruby2_keywords, true)
|
87
101
|
end
|
88
102
|
end
|
data/lib/docile/version.rb
CHANGED
data/on_what.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.3.
|
4
|
+
version: 1.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marc Siegel
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '3.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec-expectations
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "!="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.8.3
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "!="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.8.3
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: yard
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,6 +114,7 @@ files:
|
|
100
114
|
- Rakefile
|
101
115
|
- docile.gemspec
|
102
116
|
- lib/docile.rb
|
117
|
+
- lib/docile/backtrace_filter.rb
|
103
118
|
- lib/docile/chaining_fallback_context_proxy.rb
|
104
119
|
- lib/docile/execution.rb
|
105
120
|
- lib/docile/fallback_context_proxy.rb
|
@@ -109,7 +124,7 @@ homepage: https://ms-ati.github.io/docile/
|
|
109
124
|
licenses:
|
110
125
|
- MIT
|
111
126
|
metadata: {}
|
112
|
-
post_install_message:
|
127
|
+
post_install_message:
|
113
128
|
rdoc_options: []
|
114
129
|
require_paths:
|
115
130
|
- lib
|
@@ -124,9 +139,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
139
|
- !ruby/object:Gem::Version
|
125
140
|
version: '0'
|
126
141
|
requirements: []
|
127
|
-
|
128
|
-
|
129
|
-
signing_key:
|
142
|
+
rubygems_version: 3.1.4
|
143
|
+
signing_key:
|
130
144
|
specification_version: 4
|
131
145
|
summary: Docile keeps your Ruby DSLs tame and well-behaved.
|
132
146
|
test_files: []
|