happenings 0.2.0 → 1.0.0

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: e1e537ae388537bc29c33619c3111e967978b8e6
4
- data.tar.gz: d68fbd0b09651bb1ec86606c0942a235c4e336a0
3
+ metadata.gz: b2a46401f49eac6f78fa52f0c96da11306e57732
4
+ data.tar.gz: 7aa05d405dde4af3cf28d9e93df56525dd087012
5
5
  SHA512:
6
- metadata.gz: a5c845b87e8671250c6e46ba59f6b12e844561ff92628636d205109f3632b290019b306bcc88222fa1fb900fa5120708af994b8480ca218bb267c7e52a3b45c8
7
- data.tar.gz: b698a50271b6724313f99e7fde8262c87b45fb1f5a80d2c82f0fe55ec1bb702dd074a5156f76b7ae8f5b7df59fbe095f7beb60c951e655c3348b34814df9c756
6
+ metadata.gz: a32d940f64959958351ca3b862b4c185698c515d9e27018c7ca81de56e0f6575818e2adf25975b4b85e237015b87abcfcb24b9d42bfe00228848acef87e8de3c
7
+ data.tar.gz: 141a7126c6bc092b724a380db5ead8866dcbff0fc0c76bcd38b50aa0a0124c9b6a8b4ec1988349e4e38179ef50e2ff316b84c92feac7de553d175583abdee0b5
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ == 1.0.0 2014-10-30
2
+
3
+ * [breaking change] set default event name to the class name, without
4
+ underscores. This removes a dependency on ActiveSupport. To retain backward
5
+ compatibility, call #underscore on your even_name.
6
+
1
7
  == 0.2.0 2014-05-06
2
8
 
3
9
  * Removed #app_name method that forced users to declare one. You can always
data/README.md CHANGED
@@ -18,7 +18,7 @@ Or install it yourself as:
18
18
 
19
19
  ## Basic Usage
20
20
 
21
- Start by creating a Plain Old Ruby Object for your domain event and including the `Happening::Event` module.
21
+ Start by creating a Plain Old Ruby Object for your domain event and including the `Happenings::Event` module.
22
22
  You'll want to declare an initialize method that sets up any needed variables. Then, implement
23
23
  a `#strategy` method and add your business logic there. This method will be called when your
24
24
  Happening Event is run and returns a generic success by default. `#strategy` must return with
@@ -61,7 +61,7 @@ end
61
61
  `#run!` will return Boolean `true` or `false` depending on the outcome of your strategy.
62
62
 
63
63
  ## Success, Failure
64
- `#success!` and `#failure!` will set a `succeeded?` attribute and set optional keys for
64
+ `#success!` and `#failure!` will set a `succeeded?` attribute and optional keys for
65
65
  `message` and `reason` attributes. `message` is meant for human-readable messages,
66
66
  such as "Password reset failed", whereas `reason` is designed for machine-sortable
67
67
  filtering, such as "confirmation\_mismatch". A `duration` attribute is also recorded.
@@ -84,7 +84,7 @@ be overridden in your event to include useful info such as the user id, changed
84
84
  You can override this to use your own routing scheme, but you'll probably just want to augment it by
85
85
  calling `"#{super}.my.details.here"`.
86
86
 
87
- `event_name`: A machine-filterable version of the event. Defaults to the underscored class name. Override
87
+ `event_name`: A machine-filterable version of the event. Defaults to the event's class name. Override
88
88
  this to use your own naming scheme.
89
89
 
90
90
  Here's an expanded version of our Reset Password example above that includes publishing features:
@@ -148,14 +148,14 @@ end
148
148
  If the event is successful, `MyEventPublisher#publish` will receive the following parameters:
149
149
  ```
150
150
  message.inspect # => { user: { id: 2 },
151
- event: 'reset_password_event',
151
+ event: 'ResetPasswordEvent',
152
152
  reason: nil,
153
153
  message: 'Password reset successfully',
154
154
  duration: '0.0015',
155
155
  succeeded: true }
156
156
 
157
157
  properties.inspect # => { message_id: <SecureRandom.uuid>,
158
- routing_key: 'reset_password_event.success',
158
+ routing_key: 'ResetPasswordEvent.success',
159
159
  timestamp: <Time.now.to_i> }
160
160
  ```
161
161
 
@@ -173,10 +173,6 @@ Happenings.configure do |config|
173
173
  end
174
174
  ```
175
175
 
176
- ## Requirements
177
-
178
- * ActiveSupport (>= 2.3)
179
-
180
176
  ## Contributing
181
177
 
182
178
  1. Fork it ( http://github.com/desmondmonster/happenings/fork )
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
7
7
  spec.name = "happenings"
8
8
  spec.version = Happenings::VERSION
9
9
  spec.authors = ["Desmond Bowe"]
10
- spec.email = ["desmondbowe@gmail.com"]
10
+ spec.email = ["desmond@crevalle.io"]
11
11
  spec.summary = %q{Event-Driven Domain Scaffold}
12
12
  spec.description = %q{For use in applications where business domain events are first-class citizens}
13
13
  spec.homepage = "https://github.com/desmondmonster/happenings"
@@ -18,7 +18,6 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ['lib']
20
20
 
21
- spec.add_dependency 'activesupport', '>= 2.3'
22
21
  spec.add_development_dependency 'bundler', '~> 1.5'
23
22
  spec.add_development_dependency 'pry'
24
23
  spec.add_development_dependency 'rake'
@@ -3,8 +3,15 @@ module Happenings
3
3
  class OutcomeError < StandardError; end
4
4
 
5
5
  module Event
6
+ module ClassMethods
7
+ def self.run! *args
8
+ new(*args).tap &:run!
9
+ end
10
+ end
6
11
 
7
- require 'active_support/inflector'
12
+ def self.included base
13
+ base.extend ClassMethods
14
+ end
8
15
 
9
16
  attr_reader :duration, :message, :reason, :succeeded
10
17
 
@@ -13,7 +20,7 @@ module Happenings
13
20
  strategy
14
21
  end
15
22
 
16
- raise OutcomeError.new 'no outcome specified' if no_outcome_specified?
23
+ raise OutcomeError.new "no outcome specified for #{event_name}" if no_outcome_specified?
17
24
 
18
25
  publish
19
26
 
@@ -54,7 +61,7 @@ module Happenings
54
61
  end
55
62
 
56
63
  def event_name
57
- self.class.to_s.underscore
64
+ self.class.to_s
58
65
  end
59
66
 
60
67
  def publish
@@ -1,5 +1,5 @@
1
1
  module Happenings
2
- VERSION = [0, 2, 0]
2
+ VERSION = [1, 0, 0]
3
3
 
4
4
  class << VERSION
5
5
  include Comparable
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: happenings
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Desmond Bowe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-06 00:00:00.000000000 Z
11
+ date: 2014-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: activesupport
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '2.3'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '2.3'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: bundler
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -97,7 +83,7 @@ dependencies:
97
83
  description: For use in applications where business domain events are first-class
98
84
  citizens
99
85
  email:
100
- - desmondbowe@gmail.com
86
+ - desmond@crevalle.io
101
87
  executables: []
102
88
  extensions: []
103
89
  extra_rdoc_files: []
@@ -140,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
126
  version: '0'
141
127
  requirements: []
142
128
  rubyforge_project:
143
- rubygems_version: 2.2.0
129
+ rubygems_version: 2.4.1
144
130
  signing_key:
145
131
  specification_version: 4
146
132
  summary: Event-Driven Domain Scaffold
@@ -151,4 +137,3 @@ test_files:
151
137
  - spec/support/event.rb
152
138
  - spec/support/reset_password_event.rb
153
139
  - spec/support/user.rb
154
- has_rdoc: