eventful 1.0.0 → 1.0.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.
@@ -1,3 +1,9 @@
1
+ === 1.0.1 / 2012-12-22
2
+
3
+ * Post-apocalypse release. Lock down to methodphitamine-1.0.0 because 1.0.1 is
4
+ really broken.
5
+
6
+
1
7
  === 1.0.0 / 2009-06-18
2
8
 
3
9
  * Initial release
@@ -1,18 +1,10 @@
1
1
  = Eventful
2
2
 
3
- * http://github.com/jcoglan/eventful
4
-
5
3
  +Eventful+ is a small extension on top of Ruby's +Observable+ module that
6
- implements named events, block listeners and event bubbling. It allows
7
- much more flexible event handling behaviour than is typically allowed
8
- by +Observable+, which requires listeners to be objects that implement
9
- +update+ and provides no simple way of calling subsets of observers based
10
- on event type.
11
-
12
-
13
- == Installation
14
-
15
- sudo gem install eventful
4
+ implements named events, block listeners and event bubbling. It allows much
5
+ more flexible event handling behaviour than is typically allowed by
6
+ +Observable+, which requires listeners to be objects that implement +update+
7
+ and provides no simple way of calling subsets of observers based on event type.
16
8
 
17
9
 
18
10
  == Examples
@@ -23,10 +15,9 @@ Make a class listenable by mixing +Eventful+ into it:
23
15
  include Eventful
24
16
  end
25
17
 
26
- Register event listeners using +on+ with an event name and a block.
27
- Publish events using +fire+ with the event name. The block accepts
28
- the object that published the event, along with any parameters passed
29
- to +fire+.
18
+ Register event listeners using +on+ with an event name and a block. Publish
19
+ events using +fire+ with the event name. The block accepts the object that
20
+ published the event, along with any parameters passed to +fire+.
30
21
 
31
22
  w = Watcher.new
32
23
 
@@ -51,8 +42,8 @@ so you can remove it using +delete_observer+.
51
42
 
52
43
  === Method chains instead of blocks
53
44
 
54
- Instead of passing a block, you can add behaviour to objects by chaining
55
- method calls after the +on+ call. For example:
45
+ Instead of passing a block, you can add behaviour to objects by chaining method
46
+ calls after the +on+ call. For example:
56
47
 
57
48
  class Logger
58
49
  include Eventful
@@ -71,10 +62,10 @@ method calls after the +on+ call. For example:
71
62
 
72
63
  === Events that bubble
73
64
 
74
- When you +fire+ an event, the event 'bubbles' up the type system. What
75
- this means is that you can listen to events on all the instances of a
76
- class just by placing an event listener on the class itself. As above,
77
- the listener is called with the instance that fired the event.
65
+ When you +fire+ an event, the event 'bubbles' up the type system. What this
66
+ means is that you can listen to events on all the instances of a class just by
67
+ placing an event listener on the class itself. As above, the listener is called
68
+ with the instance that fired the event.
78
69
 
79
70
  Logger.on(:receive) { |log, msg| puts "#{ log } :: #{ msg }" }
80
71
 
@@ -87,8 +78,8 @@ the listener is called with the instance that fired the event.
87
78
  # #<Logger:0xb7bf103c> :: The first message
88
79
  # #<Logger:0xb7bf1028> :: Another event
89
80
 
90
- Method chains can also be used, and they will be replayed on the instance
91
- that initiated the event.
81
+ Method chains can also be used, and they will be replayed on the instance that
82
+ initiated the event.
92
83
 
93
84
  # Calls `log.print "Received message"`
94
85
 
@@ -102,23 +93,23 @@ that initiated the event.
102
93
 
103
94
  (The MIT License)
104
95
 
105
- Copyright (c) 2009 James Coglan
106
-
107
- Permission is hereby granted, free of charge, to any person obtaining
108
- a copy of this software and associated documentation files (the
109
- 'Software'), to deal in the Software without restriction, including
110
- without limitation the rights to use, copy, modify, merge, publish,
111
- distribute, sublicense, and/or sell copies of the Software, and to
112
- permit persons to whom the Software is furnished to do so, subject to
113
- the following conditions:
114
-
115
- The above copyright notice and this permission notice shall be
116
- included in all copies or substantial portions of the Software.
117
-
118
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
119
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
120
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
121
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
122
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
123
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
124
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
96
+ Copyright (c) 2009-2012 James Coglan
97
+
98
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
99
+ this software and associated documentation files (the 'Software'), to deal in
100
+ the Software without restriction, including without limitation the rights to
101
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
102
+ of the Software, and to permit persons to whom the Software is furnished to do
103
+ so, subject to the following conditions:
104
+
105
+ The above copyright notice and this permission notice shall be included in all
106
+ copies or substantial portions of the Software.
107
+
108
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
109
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
110
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
111
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
112
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
113
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
114
+ SOFTWARE.
115
+
@@ -1,5 +1,4 @@
1
1
  require 'observer'
2
- require 'rubygems'
3
2
  require 'methodphitamine'
4
3
 
5
4
  # Adds named event publishing capabilities to the class that includes it.
@@ -1,6 +1,4 @@
1
- require "test/unit"
2
- require "eventful"
3
- require "set"
1
+ require "spec_helper"
4
2
 
5
3
  class Foo
6
4
  include Eventful
@@ -19,31 +17,31 @@ class Bar
19
17
  include Eventful
20
18
  end
21
19
 
22
- class TestEventful < Test::Unit::TestCase
23
- def setup
20
+ describe Eventful do
21
+ before do
24
22
  [Foo, Bar, Eventful].each &it.delete_observers
25
23
  end
26
24
 
27
- def test_named_events
25
+ it "fires events" do
28
26
  ayes, noes = 0, 0
29
27
  f = Foo.new
30
28
  f.on(:aye) { |foo, x| ayes += x }
31
29
  obs = f.on(:noe) { |foo, x| noes += x }
32
30
 
33
31
  f.fire(:aye, 1)
34
- assert_equal 1, ayes
35
- assert_equal 0, noes
32
+ ayes.should == 1
33
+ noes.should == 0
36
34
  f.fire(:noe, 3)
37
- assert_equal 1, ayes
38
- assert_equal 3, noes
35
+ ayes.should == 1
36
+ noes.should == 3
39
37
 
40
38
  f.delete_observer(obs)
41
39
  f.fire(:noe, 3)
42
- assert_equal 1, ayes
43
- assert_equal 3, noes
40
+ ayes.should == 1
41
+ noes.should == 3
44
42
  end
45
43
 
46
- def test_chaining
44
+ it "allows chaining" do
47
45
  f = Foo.new
48
46
  f.on(:aye).bump! 2
49
47
  f.on(:noe).bump! -1
@@ -51,10 +49,10 @@ class TestEventful < Test::Unit::TestCase
51
49
  2.times { f.fire(:aye) }
52
50
  f.fire(:noe)
53
51
 
54
- assert_equal 3, f.count
52
+ f.count.should == 3
55
53
  end
56
54
 
57
- def test_bubbling
55
+ it "bubbles events" do
58
56
  bar1, bar2 = Bar.new, Bar.new
59
57
  list = []
60
58
  Bar.on(:aye) { |r| list << r }
@@ -62,24 +60,24 @@ class TestEventful < Test::Unit::TestCase
62
60
  Eventful.on(:noe) { |r| list << r }
63
61
 
64
62
  bar1.fire(:aye)
65
- assert_equal [bar1, bar1], list
63
+ list.should == [bar1, bar1]
66
64
  bar2.fire(:noe)
67
- assert_equal [bar1, bar1, bar2], list
65
+ list.should == [bar1, bar1, bar2]
68
66
 
69
67
  Bar.fire(:aye)
70
- assert_equal [bar1, bar1, bar2, Bar], list
68
+ list.should == [bar1, bar1, bar2, Bar]
71
69
  Bar.fire(:noe)
72
- assert_equal [bar1, bar1, bar2, Bar], list
70
+ list.should == [bar1, bar1, bar2, Bar]
73
71
  end
74
72
 
75
- def test_chaining_on_bubble
73
+ it "allows chaining on bubble" do
76
74
  f1, f2 = Foo.new, Foo.new
77
75
  Foo.on(:aye).bump! 5
78
76
  f1.fire(:aye)
79
- assert_equal 5, f1.count
80
- assert_equal 0, f2.count
77
+ f1.count.should == 5
78
+ f2.count.should == 0
81
79
  f2.fire(:aye)
82
- assert_equal 5, f1.count
83
- assert_equal 5, f2.count
80
+ f1.count.should == 5
81
+ f2.count.should == 5
84
82
  end
85
83
  end
@@ -0,0 +1,4 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require File.expand_path('../../lib/eventful', __FILE__)
4
+
metadata CHANGED
@@ -1,83 +1,84 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: eventful
3
- version: !ruby/object:Gem::Version
4
- version: 1.0.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ prerelease:
5
6
  platform: ruby
6
- authors:
7
+ authors:
7
8
  - James Coglan
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
-
12
- date: 2009-06-18 00:00:00 +01:00
13
- default_executable:
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2012-12-22 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
16
15
  name: methodphitamine
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - '='
20
+ - !ruby/object:Gem::Version
21
+ version: 1.0.0
17
22
  type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: "0"
24
- version:
25
- - !ruby/object:Gem::Dependency
26
- name: hoe
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - '='
28
+ - !ruby/object:Gem::Version
29
+ version: 1.0.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
27
38
  type: :development
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: 2.0.0
34
- version:
35
- description: ""
36
- email:
37
- - jcoglan@googlemail.com
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description:
47
+ email: jcoglan@gmail.com
38
48
  executables: []
39
-
40
49
  extensions: []
41
-
42
- extra_rdoc_files:
50
+ extra_rdoc_files:
51
+ - README.rdoc
52
+ files:
53
+ - README.rdoc
43
54
  - History.txt
44
- - Manifest.txt
45
- - README.txt
46
- files:
47
- - History.txt
48
- - Manifest.txt
49
- - README.txt
50
- - Rakefile
51
55
  - lib/eventful.rb
52
- - test/test_eventful.rb
53
- has_rdoc: true
56
+ - spec/eventful_spec.rb
57
+ - spec/spec_helper.rb
54
58
  homepage: http://github.com/jcoglan/eventful
55
59
  licenses: []
56
-
57
60
  post_install_message:
58
- rdoc_options:
61
+ rdoc_options:
59
62
  - --main
60
- - README.txt
61
- require_paths:
63
+ - README.rdoc
64
+ require_paths:
62
65
  - lib
63
- required_ruby_version: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- version: "0"
68
- version:
69
- required_rubygems_version: !ruby/object:Gem::Requirement
70
- requirements:
71
- - - ">="
72
- - !ruby/object:Gem::Version
73
- version: "0"
74
- version:
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ! '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
75
78
  requirements: []
76
-
77
- rubyforge_project: eventful
78
- rubygems_version: 1.3.3
79
+ rubyforge_project:
80
+ rubygems_version: 1.8.23
79
81
  signing_key:
80
82
  specification_version: 3
81
- summary: ""
82
- test_files:
83
- - test/test_eventful.rb
83
+ summary: A little pub/sub abstraction based on Observable
84
+ test_files: []
@@ -1,6 +0,0 @@
1
- History.txt
2
- Manifest.txt
3
- README.txt
4
- Rakefile
5
- lib/eventful.rb
6
- test/test_eventful.rb
data/Rakefile DELETED
@@ -1,12 +0,0 @@
1
- # -*- ruby -*-
2
-
3
- require 'rubygems'
4
- require 'hoe'
5
-
6
- Hoe.spec 'eventful' do |p|
7
- # self.rubyforge_name = 'eventfulx' # if different than 'eventful'
8
- p.developer('James Coglan', 'jcoglan@googlemail.com')
9
- p.extra_deps = %w[methodphitamine]
10
- end
11
-
12
- # vim: syntax=ruby