docile 1.3.5 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +15 -0
- data/.github/workflows/main.yml +31 -0
- data/.rubocop.yml +2 -0
- data/Gemfile +20 -6
- data/HISTORY.md +20 -3
- data/README.md +40 -16
- data/Rakefile +3 -17
- data/SECURITY.md +18 -0
- data/docile.gemspec +7 -33
- data/lib/docile.rb +6 -2
- data/lib/docile/backtrace_filter.rb +5 -3
- data/lib/docile/chaining_fallback_context_proxy.rb +6 -1
- data/lib/docile/execution.rb +11 -1
- data/lib/docile/fallback_context_proxy.rb +14 -9
- data/lib/docile/version.rb +3 -1
- metadata +9 -91
- data/.travis.yml +0 -31
- data/on_what.rb +0 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4c79b9041a97cfbf6ee0a6d93a9e98a30cc188918d0916ed6b1321f8ac9dca6
|
4
|
+
data.tar.gz: 772048f651fadb4277aaa0cb0b91b45e1b95be9f36b3654a9eb5db1a0bb143ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4e3e7a9fcc953aed658c154dd6a4e43bc258e0895b6a5457f34a93dbcfd1d13808dc2a7d558b133515af695a9283f276d0f744dc57ed7caeae7394bb1ebe3c1
|
7
|
+
data.tar.gz: 218c14f2cf80913d370376415f6c650e6c8d8eebfe8405f4529e820d3b2a46bf656ce45ca22ccb36a4409fffb31f823cea49515e1e21ed5c1584d66e55a9a550
|
@@ -0,0 +1,15 @@
|
|
1
|
+
version: 2
|
2
|
+
|
3
|
+
updates:
|
4
|
+
|
5
|
+
# Maintain dependencies for GitHub Actions
|
6
|
+
- package-ecosystem: "github-actions"
|
7
|
+
directory: "/"
|
8
|
+
schedule:
|
9
|
+
interval: "daily"
|
10
|
+
|
11
|
+
# Maintain dependencies for Ruby's Bundler
|
12
|
+
- package-ecosystem: "bundler"
|
13
|
+
directory: "/"
|
14
|
+
schedule:
|
15
|
+
interval: "daily"
|
@@ -0,0 +1,31 @@
|
|
1
|
+
name: Main
|
2
|
+
on:
|
3
|
+
push:
|
4
|
+
branches:
|
5
|
+
- main
|
6
|
+
pull_request:
|
7
|
+
branches:
|
8
|
+
- main
|
9
|
+
jobs:
|
10
|
+
test:
|
11
|
+
name: 'CI Tests'
|
12
|
+
strategy:
|
13
|
+
fail-fast: false
|
14
|
+
matrix:
|
15
|
+
os: [ubuntu-latest]
|
16
|
+
# Due to https://github.com/actions/runner/issues/849, we have to use quotes for '3.0'
|
17
|
+
ruby: [jruby, truffleruby, 2.5, 2.6, 2.7, '3.0', head]
|
18
|
+
runs-on: ${{ matrix.os }}
|
19
|
+
steps:
|
20
|
+
- uses: actions/checkout@v2.3.4
|
21
|
+
- uses: ruby/setup-ruby@v1
|
22
|
+
with:
|
23
|
+
ruby-version: ${{ matrix.ruby }}
|
24
|
+
bundler-cache: true
|
25
|
+
- run: bundle exec rspec
|
26
|
+
- uses: codecov/codecov-action@v1.5.0
|
27
|
+
with:
|
28
|
+
name: ${{ matrix.ruby }}
|
29
|
+
file: ./coverage/coverage.xml
|
30
|
+
- run: bundle exec rubocop
|
31
|
+
if: matrix.ruby == '3.0'
|
data/.rubocop.yml
ADDED
data/Gemfile
CHANGED
@@ -1,12 +1,26 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
source "https://rubygems.org"
|
3
4
|
|
4
|
-
#
|
5
|
-
if
|
6
|
-
group
|
7
|
-
gem "codecov", ">= 0.0.9", :require => false
|
8
|
-
end
|
5
|
+
# CI-only dependencies go here
|
6
|
+
if ENV["CI"] == "true" # rubocop:disable Style/IfUnlessModifier
|
7
|
+
gem "simplecov-cobertura", require: false, group: "test"
|
9
8
|
end
|
10
9
|
|
11
10
|
# Specify gem's dependencies in docile.gemspec
|
12
11
|
gemspec
|
12
|
+
|
13
|
+
group :test do
|
14
|
+
gem "rspec", "~> 3.10"
|
15
|
+
gem "simplecov", require: false
|
16
|
+
end
|
17
|
+
|
18
|
+
# Excluded from CI except on latest MRI Ruby, to reduce compatibility burden
|
19
|
+
group :checks do
|
20
|
+
gem "panolint", github: "panorama-ed/panolint", branch: "main"
|
21
|
+
end
|
22
|
+
|
23
|
+
# Optional, only used locally to release to rubygems.org
|
24
|
+
group :release, optional: true do
|
25
|
+
gem "rake"
|
26
|
+
end
|
data/HISTORY.md
CHANGED
@@ -1,8 +1,25 @@
|
|
1
1
|
# HISTORY
|
2
2
|
|
3
|
-
## [Unreleased changes](http://github.com/ms-ati/docile/compare/v1.
|
4
|
-
|
5
|
-
|
3
|
+
## [Unreleased changes](http://github.com/ms-ati/docile/compare/v1.4.0...main)
|
4
|
+
|
5
|
+
## [v1.4.0 (May 12, 2021)](http://github.com/ms-ati/docile/compare/v1.3.5...v1.4.0)
|
6
|
+
|
7
|
+
- Special thanks to Matt Schreiber (@tomeon):
|
8
|
+
- Short-circuit to calling #instance_exec directly on the DSL object (prior to
|
9
|
+
constructing a proxy object) when the DSL object and block context object are
|
10
|
+
identical (*Sorry it took over a year to review and merge this!*)
|
11
|
+
- Renamed default branch from master to main, see: https://github.com/github/renaming
|
12
|
+
- Temporarily removed YARD doc configuration, to replace after
|
13
|
+
migration to Github Actions
|
14
|
+
- Removed support for all EOL Rubies < 2.6
|
15
|
+
- Migrated CI from Travis to Github Actions
|
16
|
+
- Special thanks (again!) to Taichi Ishitani (@taichi-ishitani):
|
17
|
+
- Use more reliable codecov github action (via simplecov-cobertura)
|
18
|
+
rather than less reliable codecov gem
|
19
|
+
- Enable bundle caching in github action setup-ruby
|
20
|
+
- Added Rubocop, and configured it to run in CI
|
21
|
+
- Added Dependabot, and configured it to run daily
|
22
|
+
- Added SECURITY.md for vulnerability reporting policy
|
6
23
|
|
7
24
|
## [v1.3.5 (Jan 13, 2021)](http://github.com/ms-ati/docile/compare/v1.3.4...v1.3.5)
|
8
25
|
|
data/README.md
CHANGED
@@ -1,8 +1,3 @@
|
|
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
|
-
|
6
1
|
# Docile
|
7
2
|
|
8
3
|
[![Gem Version](https://img.shields.io/gem/v/docile.svg)](https://rubygems.org/gems/docile)
|
@@ -12,7 +7,7 @@ We'll decide which Ruby versions to continue supporting on **Feb 1st 2021**.
|
|
12
7
|
[![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](http://rubydoc.info/github/ms-ati/docile)
|
13
8
|
[![Docs Coverage](http://inch-ci.org/github/ms-ati/docile.png)](http://inch-ci.org/github/ms-ati/docile)
|
14
9
|
|
15
|
-
[![Build Status](https://
|
10
|
+
[![Build Status](https://github.com/ms-ati/docile/actions/workflows/main.yml/badge.svg)](https://github.com/ms-ati/docile/actions/workflows/main.yml)
|
16
11
|
[![Code Coverage](https://img.shields.io/codecov/c/github/ms-ati/docile.svg)](https://codecov.io/github/ms-ati/docile)
|
17
12
|
[![Maintainability](https://api.codeclimate.com/v1/badges/79ca631bc123f7b83b34/maintainability)](https://codeclimate.com/github/ms-ati/docile/maintainability)
|
18
13
|
|
@@ -29,7 +24,7 @@ coding a bit more docile...
|
|
29
24
|
|
30
25
|
## Usage
|
31
26
|
|
32
|
-
### Basic: Ruby [Array](http://ruby-doc.org/core-
|
27
|
+
### Basic: Ruby [Array](http://ruby-doc.org/core-3.0.0/Array.html) as DSL
|
33
28
|
|
34
29
|
Let's say that we want to make a DSL for modifying Array objects.
|
35
30
|
Wouldn't it be great if we could just treat the methods of Array as a DSL?
|
@@ -274,11 +269,11 @@ Sometimes, you want to use an object as a DSL, but it doesn't quite fit the
|
|
274
269
|
above.
|
275
270
|
|
276
271
|
Instead of methods like
|
277
|
-
[Array#push](http://www.ruby-doc.org/core-
|
272
|
+
[Array#push](http://www.ruby-doc.org/core-3.0.0/Array.html#method-i-push), which
|
278
273
|
modifies the object at hand, it has methods like
|
279
|
-
[String#reverse](http://www.ruby-doc.org/core-
|
274
|
+
[String#reverse](http://www.ruby-doc.org/core-3.0.0/String.html#method-i-reverse),
|
280
275
|
which returns a new object without touching the original. Perhaps it's even
|
281
|
-
[frozen](http://www.ruby-doc.org/core-
|
276
|
+
[frozen](http://www.ruby-doc.org/core-3.0.0/Object.html#method-i-freeze) in
|
282
277
|
order to enforce [immutability](http://en.wikipedia.org/wiki/Immutable_object).
|
283
278
|
|
284
279
|
Wouldn't it be great if we could just treat these methods as a DSL as well?
|
@@ -356,13 +351,19 @@ $ gem install docile
|
|
356
351
|
|
357
352
|
## Status
|
358
353
|
|
359
|
-
Works on [all ruby versions
|
354
|
+
Works on [all currently supported ruby versions](https://github.com/ms-ati/docile/blob/master/.github/workflows/main.yml),
|
355
|
+
or so [Github Actions](https://github.com/ms-ati/docile/actions)
|
356
|
+
tells us.
|
360
357
|
|
361
|
-
Used by some pretty cool gems to implement their DSLs, notably including
|
358
|
+
Used by some pretty cool gems to implement their DSLs, notably including
|
359
|
+
[SimpleCov](https://github.com/colszowka/simplecov). Keep an eye out for new
|
360
|
+
gems using Docile at the
|
361
|
+
[Ruby Toolbox](https://www.ruby-toolbox.com/projects/docile).
|
362
362
|
|
363
363
|
## Release Policy
|
364
364
|
|
365
|
-
Docile releases follow
|
365
|
+
Docile releases follow
|
366
|
+
[Semantic Versioning 2.0.0](https://semver.org/spec/v2.0.0.html).
|
366
367
|
|
367
368
|
## Note on Patches/Pull Requests
|
368
369
|
|
@@ -377,10 +378,33 @@ Docile releases follow [Semantic Versioning 2.0.0](https://semver.org/spec/v2.0.
|
|
377
378
|
commit by itself I can ignore when I pull)
|
378
379
|
* Send me a pull request. Bonus points for topic branches.
|
379
380
|
|
380
|
-
##
|
381
|
+
## Releasing
|
381
382
|
|
382
|
-
|
383
|
+
To make a new release of `Dile` to
|
384
|
+
[RubyGems](https://rubygems.org/gems/docile), first install the release
|
385
|
+
dependencies (e.g. `rake`) as follows:
|
386
|
+
|
387
|
+
```shell
|
388
|
+
bundle config set --local with 'release'
|
389
|
+
bundle install
|
390
|
+
```
|
391
|
+
|
392
|
+
Then carry out these steps:
|
383
393
|
|
384
|
-
|
394
|
+
1. Update `HISTORY.md`:
|
395
|
+
- Add an entry for the upcoming version _x.y.z_
|
396
|
+
- Move content from _Unreleased_ to the upcoming version _x.y.z_
|
397
|
+
- Commit with title `Update HISTORY.md for x.y.z`
|
385
398
|
|
399
|
+
2. Update `lib/docile/version.rb`
|
400
|
+
- Replace with upcoming version _x.y.z_
|
401
|
+
- Commit with title `Bump version to x.y.z`
|
402
|
+
|
403
|
+
3. `bundle exec rake release`
|
404
|
+
|
405
|
+
## Copyright & License
|
406
|
+
|
407
|
+
Copyright (c) 2012-2021 Marc Siegel.
|
386
408
|
|
409
|
+
Licensed under the [MIT License](http://choosealicense.com/licenses/mit/),
|
410
|
+
see [LICENSE](LICENSE) for details.
|
data/Rakefile
CHANGED
@@ -1,28 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "rake/clean"
|
2
4
|
require "bundler/gem_tasks"
|
3
5
|
require "rspec/core/rake_task"
|
4
|
-
require File.expand_path("on_what", File.dirname(__FILE__))
|
5
6
|
|
6
7
|
# Default task for `rake` is to run rspec
|
7
|
-
task :
|
8
|
+
task default: [:spec]
|
8
9
|
|
9
10
|
# Use default rspec rake task
|
10
11
|
RSpec::Core::RakeTask.new
|
11
12
|
|
12
13
|
# Configure `rake clobber` to delete all generated files
|
13
14
|
CLOBBER.include("pkg", "doc", "coverage")
|
14
|
-
|
15
|
-
# To limit needed compatibility with versions of dependencies, only configure
|
16
|
-
# yard doc generation when *not* on Travis, JRuby, or < 2.0
|
17
|
-
if !on_travis? && !on_jruby? && !on_less_than_2_0?
|
18
|
-
require "github/markup"
|
19
|
-
require "redcarpet"
|
20
|
-
require "yard"
|
21
|
-
require "yard/rake/yardoc_task"
|
22
|
-
|
23
|
-
YARD::Rake::YardocTask.new do |t|
|
24
|
-
OTHER_PATHS = %w()
|
25
|
-
t.files = ["lib/**/*.rb", OTHER_PATHS]
|
26
|
-
t.options = %w(--markup-provider=redcarpet --markup=markdown --main=README.md)
|
27
|
-
end
|
28
|
-
end
|
data/SECURITY.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# Security Policy
|
2
|
+
|
3
|
+
## Supported Versions
|
4
|
+
|
5
|
+
Use this section to tell people about which versions of your project are
|
6
|
+
currently being supported with security updates.
|
7
|
+
|
8
|
+
| Version | Supported |
|
9
|
+
| ------- | ------------------ |
|
10
|
+
| 1.3.x | :white_check_mark: |
|
11
|
+
| < 1.3 | :x: |
|
12
|
+
|
13
|
+
## Reporting a Vulnerability
|
14
|
+
|
15
|
+
At this time, security issues and vulnerabilities in Docile should
|
16
|
+
be reported like any other issue. Please create an issue in the
|
17
|
+
[public issue tracker](https://github.com/ms-ati/docile/issues) on
|
18
|
+
Github.
|
data/docile.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/docile/version"
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = "docile"
|
@@ -18,38 +18,12 @@ Gem::Specification.new do |s|
|
|
18
18
|
"semver.org."
|
19
19
|
s.license = "MIT"
|
20
20
|
|
21
|
+
# Specify oldest supported Ruby version (2.5 to support JRuby 9.2.17.0)
|
22
|
+
s.required_ruby_version = ">= 2.5.0"
|
23
|
+
|
21
24
|
# Files included in the gem
|
22
|
-
s.files
|
25
|
+
s.files = `git ls-files -z`.split("\x0").reject do |f|
|
23
26
|
f.match(%r{^(test|spec|features)/})
|
24
27
|
end
|
25
28
|
s.require_paths = ["lib"]
|
26
|
-
|
27
|
-
# Specify oldest supported Ruby version
|
28
|
-
s.required_ruby_version = ">= 1.8.7"
|
29
|
-
|
30
|
-
# Run rspec tests from rake even on old Ruby versions
|
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
|
-
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
|
-
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
|
35
|
-
|
36
|
-
# Run code coverage where possible - not on Rubinius
|
37
|
-
unless on_rubinius?
|
38
|
-
# Pin versions for Travis builds on 1.9
|
39
|
-
s.add_development_dependency "json", "< 2.0" if on_less_than_2_0?
|
40
|
-
|
41
|
-
# Pin versions for Travis builds on 1.8
|
42
|
-
s.add_development_dependency "mime-types" , "~> 1.25.1" if on_1_8?
|
43
|
-
s.add_development_dependency "rest-client", "~> 1.6.8" if on_1_8?
|
44
|
-
end
|
45
|
-
|
46
|
-
# To limit needed compatibility with versions of dependencies, only configure
|
47
|
-
# yard doc generation when *not* on Travis, JRuby, Rubinius, or < 2.0
|
48
|
-
if !on_travis? && !on_jruby? && !on_rubinius? && !on_less_than_2_0?
|
49
|
-
# Github flavored markdown in YARD documentation
|
50
|
-
# http://blog.nikosd.com/2011/11/github-flavored-markdown-in-yard.html
|
51
|
-
s.add_development_dependency "yard"
|
52
|
-
s.add_development_dependency "redcarpet"
|
53
|
-
s.add_development_dependency "github-markup"
|
54
|
-
end
|
55
29
|
end
|
data/lib/docile.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "docile/version"
|
2
4
|
require "docile/execution"
|
3
5
|
require "docile/fallback_context_proxy"
|
@@ -86,7 +88,9 @@ module Docile
|
|
86
88
|
exec_in_proxy_context(dsl, FallbackContextProxy, *args, &block)
|
87
89
|
end
|
88
90
|
|
89
|
-
|
91
|
+
if respond_to?(:ruby2_keywords, true)
|
92
|
+
ruby2_keywords :dsl_eval_with_block_return
|
93
|
+
end
|
90
94
|
module_function :dsl_eval_with_block_return
|
91
95
|
|
92
96
|
# Execute a block in the context of an immutable object whose methods,
|
@@ -124,7 +128,7 @@ module Docile
|
|
124
128
|
def dsl_eval_immutable(dsl, *args, &block)
|
125
129
|
exec_in_proxy_context(dsl, ChainingFallbackContextProxy, *args, &block)
|
126
130
|
end
|
127
|
-
|
131
|
+
|
128
132
|
ruby2_keywords :dsl_eval_immutable if respond_to?(:ruby2_keywords, true)
|
129
133
|
module_function :dsl_eval_immutable
|
130
134
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Docile
|
2
4
|
# @api private
|
3
5
|
#
|
@@ -7,15 +9,15 @@ module Docile
|
|
7
9
|
# If {NoMethodError} is caught then the exception object will be extended
|
8
10
|
# by this module to add filter functionalities.
|
9
11
|
module BacktraceFilter
|
10
|
-
FILTER_PATTERN = /lib
|
12
|
+
FILTER_PATTERN = %r{/lib/docile/}.freeze
|
11
13
|
|
12
14
|
def backtrace
|
13
|
-
super.
|
15
|
+
super.reject { |trace| trace =~ FILTER_PATTERN }
|
14
16
|
end
|
15
17
|
|
16
18
|
if ::Exception.public_method_defined?(:backtrace_locations)
|
17
19
|
def backtrace_locations
|
18
|
-
super.
|
20
|
+
super.reject { |location| location.absolute_path =~ FILTER_PATTERN }
|
19
21
|
end
|
20
22
|
end
|
21
23
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "docile/fallback_context_proxy"
|
2
4
|
|
3
5
|
module Docile
|
@@ -10,13 +12,16 @@ module Docile
|
|
10
12
|
# objects.
|
11
13
|
#
|
12
14
|
# @see Docile.dsl_eval_immutable
|
15
|
+
#
|
16
|
+
# rubocop:disable Style/MissingRespondToMissing
|
13
17
|
class ChainingFallbackContextProxy < FallbackContextProxy
|
14
18
|
# Proxy methods as in {FallbackContextProxy#method_missing}, replacing
|
15
19
|
# `receiver` with the returned value.
|
16
20
|
def method_missing(method, *args, &block)
|
17
21
|
@__receiver__ = super(method, *args, &block)
|
18
22
|
end
|
19
|
-
|
23
|
+
|
20
24
|
ruby2_keywords :method_missing if respond_to?(:ruby2_keywords, true)
|
21
25
|
end
|
26
|
+
# rubocop:enable Style/MissingRespondToMissing
|
22
27
|
end
|
data/lib/docile/execution.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Docile
|
2
4
|
# @api private
|
3
5
|
#
|
@@ -15,7 +17,14 @@ module Docile
|
|
15
17
|
# @param block [Proc] the block of DSL commands to be executed
|
16
18
|
# @return [Object] the return value of the block
|
17
19
|
def exec_in_proxy_context(dsl, proxy_type, *args, &block)
|
18
|
-
block_context = eval("self", block.binding)
|
20
|
+
block_context = eval("self", block.binding) # rubocop:disable Style/EvalWithLocation
|
21
|
+
|
22
|
+
# Use #equal? to test strict object identity (assuming that this dictum
|
23
|
+
# from the Ruby docs holds: "[u]nlike ==, the equal? method should never
|
24
|
+
# be overridden by subclasses as it is used to determine object
|
25
|
+
# identity")
|
26
|
+
return dsl.instance_exec(*args, &block) if dsl.equal?(block_context)
|
27
|
+
|
19
28
|
proxy_context = proxy_type.new(dsl, block_context)
|
20
29
|
begin
|
21
30
|
block_context.instance_variables.each do |ivar|
|
@@ -31,6 +40,7 @@ module Docile
|
|
31
40
|
|
32
41
|
block_context.instance_variables.each do |ivar|
|
33
42
|
next unless proxy_context.instance_variables.include?(ivar)
|
43
|
+
|
34
44
|
value_from_dsl_proxy = proxy_context.instance_variable_get(ivar)
|
35
45
|
block_context.instance_variable_set(ivar, value_from_dsl_proxy)
|
36
46
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "set"
|
2
4
|
|
3
5
|
module Docile
|
@@ -13,11 +15,13 @@ module Docile
|
|
13
15
|
# This is useful for implementing DSL evaluation in the context of an object.
|
14
16
|
#
|
15
17
|
# @see Docile.dsl_eval
|
18
|
+
#
|
19
|
+
# rubocop:disable Style/MissingRespondToMissing
|
16
20
|
class FallbackContextProxy
|
17
21
|
# The set of methods which will **not** be proxied, but instead answered
|
18
22
|
# by this object directly.
|
19
23
|
NON_PROXIED_METHODS = Set[:__send__, :object_id, :__id__, :==, :equal?,
|
20
|
-
|
24
|
+
:!, :!=, :instance_exec, :instance_variables,
|
21
25
|
:instance_variable_get, :instance_variable_set,
|
22
26
|
:remove_instance_variable]
|
23
27
|
|
@@ -45,7 +49,7 @@ module Docile
|
|
45
49
|
|
46
50
|
# Enables calling DSL methods from helper methods in the block's context
|
47
51
|
unless fallback.respond_to?(:method_missing)
|
48
|
-
# NOTE:
|
52
|
+
# NOTE: We could switch to {#define_singleton_method} on current Rubies
|
49
53
|
singleton_class = (class << fallback; self; end)
|
50
54
|
|
51
55
|
# instrument {#method_missing} on the block's context to fallback to
|
@@ -54,14 +58,18 @@ module Docile
|
|
54
58
|
singleton_class.
|
55
59
|
send(:define_method, :method_missing) do |method, *args, &block|
|
56
60
|
m = method.to_sym
|
57
|
-
if !NON_FALLBACK_METHODS.
|
61
|
+
if !NON_FALLBACK_METHODS.member?(m) &&
|
62
|
+
!fallback.respond_to?(m) &&
|
63
|
+
receiver.respond_to?(m)
|
58
64
|
receiver.__send__(method.to_sym, *args, &block)
|
59
65
|
else
|
60
66
|
super(method, *args, &block)
|
61
67
|
end
|
62
68
|
end
|
63
69
|
|
64
|
-
|
70
|
+
if singleton_class.respond_to?(:ruby2_keywords, true)
|
71
|
+
singleton_class.send(:ruby2_keywords, :method_missing)
|
72
|
+
end
|
65
73
|
|
66
74
|
# instrument a helper method to remove the above instrumentation
|
67
75
|
singleton_class.
|
@@ -74,12 +82,8 @@ module Docile
|
|
74
82
|
|
75
83
|
# @return [Array<Symbol>] Instance variable names, excluding
|
76
84
|
# {NON_PROXIED_INSTANCE_VARIABLES}
|
77
|
-
#
|
78
|
-
# @note on Ruby 1.8.x, the instance variable names are actually of
|
79
|
-
# type `String`.
|
80
85
|
def instance_variables
|
81
|
-
|
82
|
-
super.select { |v| !NON_PROXIED_INSTANCE_VARIABLES.include?(v.to_sym) }
|
86
|
+
super.reject { |v| NON_PROXIED_INSTANCE_VARIABLES.include?(v) }
|
83
87
|
end
|
84
88
|
|
85
89
|
# Proxy all methods, excluding {NON_PROXIED_METHODS}, first to `receiver`
|
@@ -99,4 +103,5 @@ module Docile
|
|
99
103
|
|
100
104
|
ruby2_keywords :method_missing if respond_to?(:ruby2_keywords, true)
|
101
105
|
end
|
106
|
+
# rubocop:enable Style/MissingRespondToMissing
|
102
107
|
end
|
data/lib/docile/version.rb
CHANGED
metadata
CHANGED
@@ -1,99 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: docile
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marc Siegel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: rake
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "<"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '11.0'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "<"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '11.0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rspec
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '3.0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
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
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: yard
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: redcarpet
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: github-markup
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
11
|
+
date: 2021-05-12 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
97
13
|
description: "Docile treats the methods of a given ruby object as a DSL (domain specific
|
98
14
|
language) within a given block. \n\nKiller feature: you can also reference methods,
|
99
15
|
instance variables, and local variables from the original (non-DSL) context within
|
@@ -103,15 +19,18 @@ executables: []
|
|
103
19
|
extensions: []
|
104
20
|
extra_rdoc_files: []
|
105
21
|
files:
|
22
|
+
- ".github/dependabot.yml"
|
23
|
+
- ".github/workflows/main.yml"
|
106
24
|
- ".gitignore"
|
107
25
|
- ".rspec"
|
108
|
-
- ".
|
26
|
+
- ".rubocop.yml"
|
109
27
|
- ".yardopts"
|
110
28
|
- Gemfile
|
111
29
|
- HISTORY.md
|
112
30
|
- LICENSE
|
113
31
|
- README.md
|
114
32
|
- Rakefile
|
33
|
+
- SECURITY.md
|
115
34
|
- docile.gemspec
|
116
35
|
- lib/docile.rb
|
117
36
|
- lib/docile/backtrace_filter.rb
|
@@ -119,7 +38,6 @@ files:
|
|
119
38
|
- lib/docile/execution.rb
|
120
39
|
- lib/docile/fallback_context_proxy.rb
|
121
40
|
- lib/docile/version.rb
|
122
|
-
- on_what.rb
|
123
41
|
homepage: https://ms-ati.github.io/docile/
|
124
42
|
licenses:
|
125
43
|
- MIT
|
@@ -132,14 +50,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
132
50
|
requirements:
|
133
51
|
- - ">="
|
134
52
|
- !ruby/object:Gem::Version
|
135
|
-
version:
|
53
|
+
version: 2.5.0
|
136
54
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
55
|
requirements:
|
138
56
|
- - ">="
|
139
57
|
- !ruby/object:Gem::Version
|
140
58
|
version: '0'
|
141
59
|
requirements: []
|
142
|
-
rubygems_version: 3.
|
60
|
+
rubygems_version: 3.2.3
|
143
61
|
signing_key:
|
144
62
|
specification_version: 4
|
145
63
|
summary: Docile keeps your Ruby DSLs tame and well-behaved.
|
data/.travis.yml
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
|
3
|
-
branches:
|
4
|
-
only:
|
5
|
-
- master
|
6
|
-
|
7
|
-
rvm:
|
8
|
-
# MRI
|
9
|
-
- ruby-head
|
10
|
-
- 2.7
|
11
|
-
- 2.6
|
12
|
-
- 2.5
|
13
|
-
- 2.4
|
14
|
-
- 2.3
|
15
|
-
- 2.2
|
16
|
-
- 2.1
|
17
|
-
- 1.9.3
|
18
|
-
# JRuby
|
19
|
-
- jruby-head
|
20
|
-
- jruby-9.2
|
21
|
-
# Truffleruby
|
22
|
-
- truffleruby-head
|
23
|
-
- truffleruby-20.3.0
|
24
|
-
|
25
|
-
jobs:
|
26
|
-
allow_failures:
|
27
|
-
- rvm: ruby-head
|
28
|
-
- rvm: jruby-head
|
29
|
-
- rvm: truffleruby-head
|
30
|
-
|
31
|
-
fast_finish: true
|
data/on_what.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
# NOTE: Very simple tests for what system we are on, extracted for sharing
|
2
|
-
# between Rakefile, gemspec, and spec_helper. Not for use in actual library.
|
3
|
-
|
4
|
-
def on_travis?
|
5
|
-
ENV["CI"] == "true"
|
6
|
-
end
|
7
|
-
|
8
|
-
def on_jruby?
|
9
|
-
defined?(RUBY_ENGINE) && "jruby" == RUBY_ENGINE
|
10
|
-
end
|
11
|
-
|
12
|
-
def on_rubinius?
|
13
|
-
defined?(RUBY_ENGINE) && "rbx" == RUBY_ENGINE
|
14
|
-
end
|
15
|
-
|
16
|
-
def on_1_8?
|
17
|
-
RUBY_VERSION.start_with? "1.8"
|
18
|
-
end
|
19
|
-
|
20
|
-
def on_less_than_1_9_3?
|
21
|
-
RUBY_VERSION < "1.9.3"
|
22
|
-
end
|
23
|
-
|
24
|
-
def on_less_than_2_0?
|
25
|
-
RUBY_VERSION < "2.0.0"
|
26
|
-
end
|
27
|
-
|
28
|
-
def on_less_than_2_3?
|
29
|
-
RUBY_VERSION < "2.3.0"
|
30
|
-
end
|