duck_puncher 4.2.2 → 4.2.3
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/README.md +7 -7
- data/lib/duck_puncher/version.rb +1 -1
- data/lib/duck_puncher.rb +8 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f3865242be8b73f05bd76345f5d48af3ce41dcb
|
4
|
+
data.tar.gz: 8b5d46549c916081521a43ca500abd836d1d9cc0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c7e01041bc9440fb98bfe60a52e5be1597c5cfd3aaa38f96b0a66042b7bf34cdd70d2c21e647328fa375d123969f57c6d1f709b4eae68db90bfceeb29e606a9
|
7
|
+
data.tar.gz: 6093aeca1a64b78ad8376ed2075c765e950d320a0a1fca42a915aebc8ab88c8ca60d51a5f15b5a53ce8860e08a1073bf8cd7fb0ee2e245a181b54b156f64f0dd
|
data/README.md
CHANGED
@@ -14,7 +14,7 @@ Enumerable (including Array, Set, Range, and Enumerator)
|
|
14
14
|
#mm # => `[].mm(:sub, /[aeiou]/, '*')`
|
15
15
|
#mm! # => `[].mm!(:sub, /[aeiou]/, '*')`
|
16
16
|
#except # => `[].except('foo', 'bar')`
|
17
|
-
#map_keys # => `[
|
17
|
+
#map_keys # => `[].map_keys(:id)`
|
18
18
|
Hash
|
19
19
|
#dig # => `{a: 1, b: {c: 2}}.dig(:b, :c)` (Standard in Ruby >= 2.3)
|
20
20
|
#compact # => `{a: 1, b: nil}.compact` # => {a: 1}
|
@@ -26,16 +26,16 @@ Numeric
|
|
26
26
|
String
|
27
27
|
#pluralize # => `'hour'.pluralize(2)` # => "hours"
|
28
28
|
#underscore # => `'DJ::JSONStorage'.underscore` # => 'dj/json_storage'
|
29
|
-
#to_boolean # => `'
|
29
|
+
#to_boolean # => `'true'.to_boolean` # => true
|
30
30
|
#constantize # => `'MiniTest::Test'.constantize` # => MiniTest::Test
|
31
31
|
Module
|
32
32
|
#local_methods # => `Kernel.local_methods` # => returns the methods defined directly in the class + nested constants w/ methods
|
33
33
|
Object
|
34
|
-
#clone! # => `Object.new.clone!`
|
35
|
-
#punch # => `
|
36
|
-
#punch! # => `
|
37
|
-
#echo # => `
|
38
|
-
#track # => `Object.new.track`
|
34
|
+
#clone! # => `Object.new.clone!` # => a deep clone of the object (using Marshal.dump)
|
35
|
+
#punch # => `Object.new.punch` # => a copy of Object.new with String punches mixed in
|
36
|
+
#punch! # => `Object.new.punch!` # => destructive version applies extensions directly to the base object
|
37
|
+
#echo # => `Object.new.echo.inspect` # => spits out the caller and value of the object and returns the object
|
38
|
+
#track # => `Object.new.track` # => Trace methods calls to the object (requires [object_tracker](https://github.com/ridiculous/object_tracker), which it'll try to download)
|
39
39
|
Method
|
40
40
|
#to_instruct # => `Benchmark.method(:measure).to_instruct` returns the Ruby VM instruction sequence for the method
|
41
41
|
#to_source # => `Benchmark.method(:measure).to_source` returns the method definition as a string
|
data/lib/duck_puncher/version.rb
CHANGED
data/lib/duck_puncher.rb
CHANGED
@@ -39,11 +39,13 @@ module DuckPuncher
|
|
39
39
|
classes = args.any? ? args : Ducks.list.keys
|
40
40
|
classes.each do |klass|
|
41
41
|
klass = lookup_constant(klass)
|
42
|
-
Ducks[klass].sort.each do |duck|
|
42
|
+
(Ducks[klass] - punched_ducks).sort.each do |duck|
|
43
43
|
punches = Array(options[:only] || duck.options[:only] || Ducks::Module.instance_method(:local_methods).bind(duck.mod).call)
|
44
44
|
options[:target] = klass
|
45
45
|
logger.info %Q(#{klass}#{" <-- #{duck.mod.name}#{punches}" if punches.any?})
|
46
|
-
|
46
|
+
if duck.punch(options)
|
47
|
+
punched_ducks << duck
|
48
|
+
else
|
47
49
|
logger.error %Q(Failed to punch #{name})
|
48
50
|
end
|
49
51
|
end
|
@@ -54,6 +56,10 @@ module DuckPuncher
|
|
54
56
|
# Backwards compatibility
|
55
57
|
alias punch_all! call
|
56
58
|
alias punch! call
|
59
|
+
|
60
|
+
def punched_ducks
|
61
|
+
@punched_ducks ||= []
|
62
|
+
end
|
57
63
|
end
|
58
64
|
end
|
59
65
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: duck_puncher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.2.
|
4
|
+
version: 4.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Buckley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: usable
|