heed 0.0.7 → 0.0.8

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: 0345d1edb02b2cf539eec0ab3dd83d53b64ae55b
4
- data.tar.gz: 6e49bd332ad4e1e77980a745ec3fa369fe2e263f
3
+ metadata.gz: 9aa08585301fcc08e8968c5773f0e7c4ecadc65d
4
+ data.tar.gz: 3f0cea242cd9ac55909ed9b67c6bb2be83c82a2e
5
5
  SHA512:
6
- metadata.gz: 4ed74d4af4b784f28e102e3f9828aec13772078d5e4a2555019c1476385a6ecb85e8a9651f4b1b9060dd662673e419ebf60c3ff9ea8460101a45340f1093e03b
7
- data.tar.gz: b5f84d357dad9563f3eca222f0dbcca63096dffea597640e4779f0ea2a16b11e8539b38a1e2b07b40bd531e73eccff6360ec0b871744f3a822b50cfaa305d069
6
+ metadata.gz: b2a21bc055d7676ea2c7a658ce6d58e2c5d77830653e47338a794d4046f68483dcd7116bb209bffe886fb51d471a0235bee393aeeab2420ab83f68f74025071b
7
+ data.tar.gz: d6aaf0eff296699a569f32536a8c3dcf490689519f78d926cad5ba217a803dac3f2adf34fa7ef38a3a96aef7fc2a605890ff32f50bfba5a43d5db95bf0843a03
data/History.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # History
2
2
 
3
+ ## 0.0.8
4
+
5
+ * #hearken becomes #heed, with more functional semantics
6
+
3
7
  ## 0.0.7
4
8
 
5
9
  * Change gem name to 'heed'
data/README.md CHANGED
@@ -30,7 +30,7 @@ started with a tell-dont-ask style, in rails controllers for example. For more
30
30
 
31
31
  ## Usage
32
32
 
33
- ### Create a listener
33
+ ### `hark`: create a listener
34
34
 
35
35
  To create a listener object use `hark`.
36
36
 
@@ -107,7 +107,7 @@ Turn any object into a listener, adding new methods as we go
107
107
 
108
108
  Now, when listener is sent #created, all create handlers are called.
109
109
 
110
- ### Sugar: `Kernel#hearken`
110
+ ### `heed` call a message with an ad-hoc listener
111
111
 
112
112
  Because of the precedence of the block operator, constructing ad-hoc listeners requires
113
113
  you to insert some parens, which might be seen as unsightly, e.g:
@@ -117,9 +117,9 @@ you to insert some parens, which might be seen as unsightly, e.g:
117
117
  on.invalid_item {|item| redirect_to item, error: "Item not evaluable" }
118
118
  end))
119
119
 
120
- You may use Kernerl#hearken to create an ad-hoc listener using a passed block as follows
120
+ You may use #heed to create an ad-hoc listener using a passed block as follows
121
121
 
122
- seller.hearken :request_valuation, item do |on|
122
+ heed seller, :request_valuation, item do |on|
123
123
  on.valuation_requested {|valuation| redirect_to valuation}
124
124
  on.invalid_item {|item| redirect_to item, error: "Item not evaluable" }
125
125
  end
@@ -127,7 +127,7 @@ You may use Kernerl#hearken to create an ad-hoc listener using a passed block as
127
127
  If you want to combine listeners with an ad-hoc block, you may pass a 0-arity block that is
128
128
  yielded as the listener
129
129
 
130
- seller.hearken :request_valuation, item do
130
+ heed seller, :request_valuation, item do
131
131
  hark valuation_notifier do |on|
132
132
  on.valuation_requested {|valuation| redirect_to valuation}
133
133
  on.invalid_item {|item| redirect_to item, error: "Item not evaluable" }
@@ -3,8 +3,8 @@ module Kernel
3
3
  Hark.from *args, &block
4
4
  end
5
5
 
6
- def hearken method, *args, &block
6
+ def heed object, *args, &block
7
7
  listener = (block.arity == 1) ? hark(&block) : block.call
8
- send method, *args + [listener]
8
+ object.send *args + [listener]
9
9
  end
10
10
  end
@@ -1,3 +1,3 @@
1
1
  module Hark
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -136,7 +136,7 @@ describe Hark do
136
136
  it { listener.foo.should == [false] }
137
137
  end
138
138
 
139
- describe "#hearken :method" do
139
+ describe "Kernel#heed object, :method" do
140
140
  let(:object) do
141
141
  Object.new.tap do |obj|
142
142
  class << obj
@@ -150,7 +150,7 @@ describe Hark do
150
150
 
151
151
  context "with 1 arity block" do
152
152
  it "sends :method with an ad-hoc listener created from the block" do
153
- object.hearken :foo, "ONE", "TWO" do |on|
153
+ heed object, :foo, "ONE", "TWO" do |on|
154
154
  on.foo {|a| transcript << [:foo, a] }
155
155
  on.bar {|a| transcript << [:bar, a] }
156
156
  end
@@ -162,7 +162,7 @@ describe Hark do
162
162
  it "sends :method with listener created by yielding to the block" do
163
163
  foo = hark(:foo) {|a| transcript << [:foo, a] }
164
164
 
165
- object.hearken :foo, "ONE", "TWO" do
165
+ heed object, :foo, "ONE", "TWO" do
166
166
  hark(foo, :bar) {|a| transcript << [:bar, a] }
167
167
  end
168
168
  transcript.should == [[:foo, "ONE"], [:bar, "TWO"]]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian White