ianwhite-hark 0.0.1 → 0.0.2

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: b71c62889085f5896f266c976ae49d855d550917
4
- data.tar.gz: 9f69d753ec889c9cf354b1586c68313604cbeaf3
3
+ metadata.gz: 257615d2c004b4af5d262c95bc085cc04a20113c
4
+ data.tar.gz: 6b53aeb761b46d56f932fe054866142f2e7b8657
5
5
  SHA512:
6
- metadata.gz: 7c690463f3539c9b835b3ed34b09cdcaa64d642f37a51eb63f441812274888b7ee93f8f1ce40b6afa1de957b3f9056de68b7cd2860b6181d10898eca851f7425
7
- data.tar.gz: f79b3613750fc960271a57091f966ea02b6b17a35f6c9d19087b35715d3b6e4ac154efc53a1390adbe6b5a6a5692fa69970d98402da2c90466c2ec0a09ff3c41
6
+ metadata.gz: c003deb6ef1d73e06cf9d06e17f06abc56d9ed99f6ca44b29eec664f51d4f0a9b3363c8d347e3dbac632419e8c891b1dcdb97d70af37285e8b6e7bb7b4109c6d
7
+ data.tar.gz: 0efa1f2ac66c433f8fb1b90d271dedfe135c995ef1300aa61c8fa63232731392460c308662d26b2db382cdbab5a478f6fced2ec7737f46721952301bc0ae3d78
data/README.md CHANGED
@@ -1,13 +1,31 @@
1
- # Hark
1
+ # Hark [![Code Climate](https://codeclimate.com/repos/52691919c7f3a37a2301dfc5/badges/8f5a4caa333ec7a654ec/gpa.png)](https://codeclimate.com/repos/52691919c7f3a37a2301dfc5/feed) [![Build Status](https://travis-ci.org/ianwhite/hark.png)](https://travis-ci.org/ianwhite/hark)
2
2
 
3
3
  Create an ad-hoc listener object with hark.
4
4
 
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'ianwhite-hark'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install ianwhite-hark
18
+
19
+ ## Usage
20
+
5
21
  The idea behind hark is that the objects that receive listeners shouldn't need to perform any ceremony on
6
22
  them, just treat them as objects that respond to messages. It's up to the caller to provide these lsitener objects,
7
- and to decide how they behave (re: lax), perhaps smushing together listeners (re: add). If required, these ad-hoc
23
+ and to decide how they behave, perhaps combining together listeners (in an subscriber fashion). If required, these ad-hoc
8
24
  listeners can easily be refactored into classes in their own right, as the recievers don't need to know anything about
9
25
  hark.
10
26
 
27
+ Tell don't ask style is encouraged with hark. That said, the return value for a message sent to a hark listener is an array of all of the return values.
28
+
11
29
  listener = hark success: ->{ "succeeded" }, failure: ->{ "failed" }
12
30
  listener.success # => ["succeeded"]
13
31
  listener.failure # => ["failed"]
@@ -38,27 +56,23 @@ To add new messages to a listener, use #hark
38
56
 
39
57
  To decorate an object (of any sort) so that it becomes a hark listener (and therefore can be smushed etc)
40
58
 
41
- listener = object.to_hark
59
+ listener = hark(object)
42
60
 
43
61
  The listener is immutable, #strict, #lax, and #hark all return new listeners
44
62
 
45
- ## Installation
46
-
47
- Add this line to your application's Gemfile:
48
-
49
- gem 'ianwhite-hark'
50
-
51
- And then execute:
63
+ Here's an example from a rails controller
52
64
 
53
- $ bundle
54
-
55
- Or install it yourself as:
56
-
57
- $ gem install ianwhite-hark
58
-
59
- ## Usage
65
+ def create
66
+ SignupNewUser.new params, hark(create_response, SignupEmailer.new)
67
+ end
60
68
 
61
- TODO: Write usage instructions here
69
+ # response block style
70
+ def create_response
71
+ hark do |on|
72
+ on.signed_up {|user| redirect_to user, notice: "Signed up!" }
73
+ on.invalid {|user| render "new", user: user }
74
+ end
75
+ end
62
76
 
63
77
  ## Contributing
64
78
 
data/lib/hark/core_ext.rb CHANGED
@@ -2,8 +2,4 @@ module Kernel
2
2
  def hark *args, &block
3
3
  Hark.from *args, &block
4
4
  end
5
-
6
- def to_hark *args, &block
7
- Hark.from self, *args, &block
8
- end
9
5
  end
data/lib/hark/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Hark
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/spec/hark_spec.rb CHANGED
@@ -91,8 +91,8 @@ describe Hark do
91
91
  it_should_behave_like "a success/failure hark listener"
92
92
  end
93
93
 
94
- describe "object.to_hark" do
95
- Given(:listener) { PlainListener.new(transcript).to_hark }
94
+ describe "hark object" do
95
+ Given(:listener) { hark PlainListener.new(transcript) }
96
96
 
97
97
  it_should_behave_like "a success/failure hark listener"
98
98
  end
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.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian White