duck_puncher 4.2.0 → 4.2.1

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: f03c81056b93d66e3c9799672cc6e20c34d1ac72
4
- data.tar.gz: 30186f7d1cc1b8ce19d94810b17e24cf7fe0b2ab
3
+ metadata.gz: 8d87f6e9cc70035a1882583f6f8118b50a48a727
4
+ data.tar.gz: ef1253af39b88d4ca68738aa5ae278c19f2cc235
5
5
  SHA512:
6
- metadata.gz: a27458ff3a2d1e52d381c44d91b6281b0c485870471298413a8144a070574e06a2119d75f9f61feb803167d0cf6e23c05d7a31f967dc9482eb2c46bfc62429b7
7
- data.tar.gz: 5cb8230d00f0cf0b058b1db9f9043990beacf2c4dcafb1073aae9d74356b7fc8dd0d6a0ec7eb42a1ceb8b525c9ba21b85d9a1c4458f972e675f98799a2fdba70
6
+ metadata.gz: 30e60aeae2f9484ece1756527f2b5217a5af1fecee7fbe72435d7c368d022d72bf47795011ef3a6de8a6698ee280492bba9f408d9eea6b576224bd7323b66470
7
+ data.tar.gz: 0fe659cc0d20d179246eedd5522da3ea2fa824489b40ca2785ef56b1fd20037af3a75a6649d5946ae4447450dfd3f1d58e617ef15b0929d4ae66ba67e9d3b159
data/README.md CHANGED
@@ -66,20 +66,20 @@ DuckPuncher.(Object, only: :punch)
66
66
  `DuckPuncher` extends the amazing [Usable](https://github.com/ridiculous/usable) gem, so you can configure only the punches you want! For instance:
67
67
 
68
68
  ```ruby
69
- DuckPuncher.punch! Numeric, only: [:to_currency, :to_duration]
69
+ DuckPuncher.(Numeric, only: [:to_currency, :to_duration])
70
70
  ```
71
71
 
72
72
  If you punch `Object` then you can use `#punch!` on any object to extend individual instances:
73
73
 
74
74
  ```ruby
75
- >> DuckPuncher.punch! Object, only: :punch!
75
+ >> DuckPuncher.(Object, only: :punch!)
76
76
  >> %w[yes no 1].punch!.m!(:punch).m(:to_boolean)
77
77
  => [true, false, true]
78
78
  ```
79
79
 
80
80
  Alternatively, there is also the `Object#punch` method which returns a decorated copy of an object with punches mixed in:
81
81
  ```ruby
82
- >> DuckPuncher.punch! Object, only: :punch
82
+ >> DuckPuncher.(Object, only: :punch)
83
83
  >> %w[1 2 3].punch.m(:to_i)
84
84
  => [1, 2, 3]
85
85
  ```
@@ -106,7 +106,7 @@ def soft_punch
106
106
  end
107
107
 
108
108
  def hard_punch
109
- ('a'..'z').to_a.punch!.m!(:upcase).mm!(:*, 3).echo
109
+ ('a'..'z').punch!.m!(:upcase).mm!(:*, 3).echo
110
110
  end
111
111
 
112
112
  >> soft_punch
@@ -152,13 +152,15 @@ end
152
152
  DuckPuncher.register User, :Billable, :Retryable
153
153
 
154
154
  # Add the #punch method to User instances
155
- DuckPuncher.punch! Object, only: :punch
155
+ DuckPuncher.(Object, only: :punch)
156
156
 
157
157
  # Usage
158
158
  user = User.new('Ryan').punch
159
159
  user.call_with_retry(19.99)
160
160
  ```
161
161
 
162
+ To register _and_ punch in one swoop, use `DuckPuncher.register!`
163
+
162
164
  ## Install
163
165
 
164
166
  ```ruby
@@ -189,7 +191,7 @@ LoadError: cannot load such file -- pry
189
191
  from (irb):1:in `require'
190
192
  from (irb):1
191
193
  from bin/console:10:in `<main>'
192
- >> DuckPuncher.punch! Object, only: :require!
194
+ >> DuckPuncher.(Object, only: :require!)
193
195
  => nil
194
196
  >> require! 'pry'
195
197
  Fetching: method_source-0.8.2.gem (100%)
@@ -209,7 +211,7 @@ if it's not available in the current load path, and starts tracking the current
209
211
  ```ruby
210
212
  Duck = Class.new
211
213
  Donald = Module.new { def tap_tap() self end }
212
- DuckPuncher.punch!(:Object, only: :track)
214
+ DuckPuncher.(:Object, only: :track)
213
215
  Donald.track
214
216
  Duck.track
215
217
  >> Duck.usable Donald, only: :tap_tap
@@ -1,5 +1,5 @@
1
1
  DuckPuncher.logger = Logger.new(STDOUT).tap do |config|
2
- config.formatter = proc { |*args| "[#{args[1]}] #{args[0]}: #{args[-1]}\n" }
2
+ config.formatter = proc { |*args| "[DuckPuncher] #{args[0]}: #{args[-1]}\n" }
3
3
  config.level = Logger::ERROR
4
4
  end
5
5
 
@@ -7,7 +7,6 @@ ducks = [
7
7
  [String, DuckPuncher::Ducks::String],
8
8
  [Enumerable, DuckPuncher::Ducks::Enumerable],
9
9
  [Array, DuckPuncher::Ducks::Enumerable],
10
- [Hash, DuckPuncher::Ducks::Enumerable],
11
10
  [Numeric, DuckPuncher::Ducks::Numeric],
12
11
  [Hash, DuckPuncher::Ducks::Hash],
13
12
  [Object, DuckPuncher::Ducks::Object],
@@ -13,6 +13,11 @@ module DuckPuncher
13
13
  @cached_decorators = nil
14
14
  end
15
15
 
16
+ def register!(*args)
17
+ register *args
18
+ call args.first
19
+ end
20
+
16
21
  def deregister(*classes)
17
22
  classes.each &Ducks.list.method(:delete)
18
23
  classes.each &decorators.method(:delete)
@@ -1,3 +1,3 @@
1
1
  module DuckPuncher
2
- VERSION = '4.2.0'.freeze
2
+ VERSION = '4.2.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: duck_puncher
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.0
4
+ version: 4.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Buckley