ianwhite-hark 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a312e8d34fdb0a88013aa0d4602addb244719b35
4
- data.tar.gz: 19ec8e5b542f72aaa806bc88a55faa276b275ad7
3
+ metadata.gz: 6c1768749a71703d7f3a754773c0dda1b9b9c754
4
+ data.tar.gz: c704b92cd229dc37ecb44a0fa5daff446b64b313
5
5
  SHA512:
6
- metadata.gz: ad050f9e915f633cbbdd082aed1f6d1e6057f006b44614bc38e760b742b73540444b187f09189d1323efaa2cdbace4514e57a2ac70710db5aa29338cfe93d14a
7
- data.tar.gz: 0291b41c2e65a84190aa8e58d3ba68bc0dd61d1b2dc0bfd5ddde32e5410dae1dac020755571c1187614bf9982de897bb8a1391cef2cabacf55fa23cb3f9dac95
6
+ metadata.gz: 3da05565f8c13dc4d477441f48be5cb746797f6e854af8152c09326b564cd2e6010e177ddaf5c2832472430fec6d7825f2e21665c096ac8854bece6cf22adb4e
7
+ data.tar.gz: 397d7d99fe5936cca9661fc7e0eb00ef8bbcf484f74f3b04c4e029cf7fcd880dbe2efc6a5f938b0bdc63f8070c869a0bbb5ca9bc2cbdff5e4828925260c95b22
data/History.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # History
2
2
 
3
+ ## 0.0.6
4
+
5
+ * remove Kernel#to_hark
6
+
3
7
  ## 0.0.5
4
8
 
5
9
  * ruby 1.8.7 compat
data/README.md CHANGED
@@ -42,7 +42,7 @@ You can pass a symbol and block
42
42
 
43
43
  The following methods are more suitable for a listener with multiple messages.
44
44
 
45
- A hash with callables as keys
45
+ A hash with callables as values
46
46
 
47
47
  hark(
48
48
  created: ->(user) { redirect_to(user, notice: "You have signed up!") },
@@ -50,7 +50,7 @@ A hash with callables as keys
50
50
  )
51
51
 
52
52
  # assuming some methods for rendering and redirecting exist on the controller
53
- hash created: method(:redirect_to_user), invalid: method(:render_new)
53
+ hark(created: method(:redirect_to_user), invalid: method(:render_new))
54
54
 
55
55
  Or, a 'respond_to' style block
56
56
 
@@ -99,9 +99,15 @@ Combine with any object that support the same protocol
99
99
  logger = UserLogger.new # responds to :created
100
100
  listener = listener.hark(logger)
101
101
 
102
+ Turn any object into a listener, adding new methods as we go
103
+
104
+ hark UserLogger.new do |on|
105
+ on.created {|user| Emailer.send_welcom_email(user) }
106
+ end
107
+
102
108
  Now, when listener is sent #created, all create handlers are called.
103
109
 
104
- ### Sugar: #hearken
110
+ ### Sugar: `Kernel#hearken`
105
111
 
106
112
  Because of the precedence of the block operator, constructing ad-hoc listeners requires
107
113
  you to insert some parens, which might be seen as unsightly, e.g:
@@ -118,7 +124,7 @@ You may use Kernerl#hearken to create an ad-hoc listener using a passed block as
118
124
  on.invalid_item {|item| redirect_to item, error: "Item not evaluable" }
119
125
  end
120
126
 
121
- If you want to combine listeners with an ad-hoc blokc, you may pass a 0-arity block that is
127
+ If you want to combine listeners with an ad-hoc block, you may pass a 0-arity block that is
122
128
  yielded as the listener
123
129
 
124
130
  seller.hearken :request_valuation, item do
@@ -3,10 +3,6 @@ module Kernel
3
3
  Hark.from *args, &block
4
4
  end
5
5
 
6
- def to_hark *args, &block
7
- hark self, *args, &block
8
- end
9
-
10
6
  def hearken method, *args, &block
11
7
  listener = (block.arity == 1) ? hark(&block) : block.call
12
8
  send method, *args + [listener]
@@ -1,3 +1,3 @@
1
1
  module Hark
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -97,12 +97,6 @@ describe Hark do
97
97
  it_should_behave_like "a success/failure hark listener"
98
98
  end
99
99
 
100
- describe "object.to_hark" do
101
- let(:listener) { PlainListener.new(transcript).to_hark }
102
-
103
- it_should_behave_like "a success/failure hark listener"
104
- end
105
-
106
100
  describe "combine two listeners together" do
107
101
  let(:logger) { hark(:signup_user) {|user| transcript << "User #{user} signed up" } }
108
102
  let(:emailer) { hark(:signup_user) {|user| transcript << "Emailed #{user}" } }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ianwhite-hark
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian White