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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 65996bcd8666c6b83b5b5c3a71c6517b9ecc7d75
4
- data.tar.gz: f1362ac2578ddcd74677066c9d168c267fee119a
3
+ metadata.gz: 3f3865242be8b73f05bd76345f5d48af3ce41dcb
4
+ data.tar.gz: 8b5d46549c916081521a43ca500abd836d1d9cc0
5
5
  SHA512:
6
- metadata.gz: 3cc4e467436746ed770f32df6ab88d0b82b7134940f255cddc6b2899ba852641235afc9af94bd00a828d84bcd59b138656d6109d1ff5b3a7597d0f3a191ec45a
7
- data.tar.gz: 223c5e24a33223540342be0ea2bbcfc969080e4bcd9e584e336325f869e39cf7bc88e3d3065107c2cc22b2d972eaa81ab03c7673731ff1438262533a9e7b3bf6
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 # => `[{id: 1}, {id: 2}].map_keys(:id)`
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 # => `'1'.to_boolean` # => true
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!` # => a deep clone of the object (using Marshal.dump)
35
- #punch # => `'duck'.punch` # => a copy of 'duck' with String punches mixed in
36
- #punch! # => `'duck'.punch!` # => destructive version applies extensions directly to the base object
37
- #echo # => `'duck'.echo.upcase` # => spits out the caller and value of the object and returns the object
38
- #track # => `Object.new.track` # => Traces methods calls to the object (requires [object_tracker](https://github.com/ridiculous/object_tracker), which it'll try to download)
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
@@ -1,3 +1,3 @@
1
1
  module DuckPuncher
2
- VERSION = '4.2.2'.freeze
2
+ VERSION = '4.2.3'.freeze
3
3
  end
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
- unless duck.punch(options)
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.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-08-24 00:00:00.000000000 Z
11
+ date: 2016-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: usable