proclaimer 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f828bb32881de602413bf79b13d3d7cfe93e75e1
4
+ data.tar.gz: 22716b13b309b4fe2d049eefb1f8d28bf93e699d
5
+ SHA512:
6
+ metadata.gz: 8721b30d047b3f7ff45becdee6933ad63b083cbbcb010e3dba79b3cbee9b1374842355a104b3aacfcceb7ddea9e71ecd1c71e38532de26f8138a1ecf338c1e57
7
+ data.tar.gz: 47e10b63f25a17f165dd0a54050824c5f5d5c43254ae4342ee0db493be48fd01d3912c1b0e70bfc6a7a2badfc7500721bd990d281231a112febc80184b511637
data/.gitignore ADDED
@@ -0,0 +1,39 @@
1
+ *.rbc
2
+ capybara-*.html
3
+ .rspec
4
+ /log
5
+ /tmp
6
+ /db/*.sqlite3
7
+ /db/*.sqlite3-journal
8
+ /public/system
9
+ pkg
10
+ /coverage/
11
+ /spec/tmp
12
+ **.orig
13
+ rerun.txt
14
+ pickle-email-*.html
15
+
16
+ # TODO Comment out these rules if you are OK with secrets being uploaded to the repo
17
+ config/initializers/secret_token.rb
18
+ config/secrets.yml
19
+
20
+ ## Environment normalisation:
21
+ /.bundle
22
+ /vendor/bundle
23
+
24
+ # these should all be checked in to normalise the environment:
25
+ # Gemfile.lock, .ruby-version, .ruby-gemset
26
+
27
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
28
+ .rvmrc
29
+
30
+ # if using bower-rails ignore default bower_components path bower.json files
31
+ /vendor/assets/bower_components
32
+ *.bowerrc
33
+ bower.json
34
+
35
+ # Ignore pow environment settings
36
+ .powenv
37
+
38
+ # Ignore Spree dummy application
39
+ /spec/dummy
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ sudo: false
3
+ cache: bundler
4
+ rvm:
5
+ - "2.1"
6
+ - "2.2"
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "spree", github: "spree/spree", branch: "3-0-stable"
4
+ # Provides basic authentication functionality for testing parts of your engine
5
+ gem "spree_auth_devise", github: "spree/spree_auth_devise", branch: "3-0-stable"
6
+
7
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,376 @@
1
+ GIT
2
+ remote: git://github.com/spree/spree.git
3
+ revision: c621abd94ead37e85d4171550fc11ac4f03439ac
4
+ branch: 3-0-stable
5
+ specs:
6
+ spree (3.0.4.beta)
7
+ spree_api (= 3.0.4.beta)
8
+ spree_backend (= 3.0.4.beta)
9
+ spree_cmd (= 3.0.4.beta)
10
+ spree_core (= 3.0.4.beta)
11
+ spree_frontend (= 3.0.4.beta)
12
+ spree_sample (= 3.0.4.beta)
13
+ spree_api (3.0.4.beta)
14
+ rabl (~> 0.9.4.pre1)
15
+ spree_core (= 3.0.4.beta)
16
+ versioncake (~> 2.3.1)
17
+ spree_backend (3.0.4.beta)
18
+ bootstrap-sass (~> 3.3.1)
19
+ jquery-rails (~> 4.0.3)
20
+ jquery-ui-rails (~> 5.0.0)
21
+ select2-rails (= 3.5.9.1)
22
+ spree_api (= 3.0.4.beta)
23
+ spree_core (= 3.0.4.beta)
24
+ sprockets-rails (~> 2.2)
25
+ spree_cmd (3.0.4.beta)
26
+ thor (~> 0.14)
27
+ spree_core (3.0.4.beta)
28
+ activemerchant (~> 1.47.0)
29
+ acts_as_list (~> 0.6)
30
+ awesome_nested_set (~> 3.0.1)
31
+ cancancan (~> 1.10.1)
32
+ carmen (~> 1.0.0)
33
+ deface (~> 1.0.0)
34
+ ffaker (~> 1.16)
35
+ font-awesome-rails (~> 4.0)
36
+ friendly_id (~> 5.1.0)
37
+ highline (~> 1.6.18)
38
+ httparty (~> 0.11)
39
+ json (~> 1.7)
40
+ kaminari (~> 0.15, >= 0.15.1)
41
+ monetize (~> 1.1)
42
+ paperclip (~> 4.2.0)
43
+ paranoia (~> 2.1.0)
44
+ premailer-rails
45
+ rails (~> 4.2.2)
46
+ ransack (~> 1.4.1)
47
+ responders
48
+ state_machines-activerecord (~> 0.2)
49
+ stringex
50
+ truncate_html (= 0.9.2)
51
+ twitter_cldr (~> 3.0)
52
+ spree_frontend (3.0.4.beta)
53
+ bootstrap-sass (~> 3.3.1)
54
+ canonical-rails (~> 0.0.4)
55
+ jquery-rails (~> 4.0.3)
56
+ spree_api (= 3.0.4.beta)
57
+ spree_core (= 3.0.4.beta)
58
+ sprockets-rails (~> 2.2)
59
+ spree_sample (3.0.4.beta)
60
+ spree_core (= 3.0.4.beta)
61
+
62
+ GIT
63
+ remote: git://github.com/spree/spree_auth_devise.git
64
+ revision: b554f307e5aa887110a70d54f8967c284f881375
65
+ branch: 3-0-stable
66
+ specs:
67
+ spree_auth_devise (3.0.0)
68
+ devise (~> 3.4.1)
69
+ devise-encryptable (= 0.1.2)
70
+ json
71
+ multi_json
72
+ spree_core (~> 3.0.0)
73
+
74
+ PATH
75
+ remote: .
76
+ specs:
77
+ proclaimer (0.2.0)
78
+ spree_backend (~> 3.0.0)
79
+
80
+ GEM
81
+ remote: https://rubygems.org/
82
+ specs:
83
+ actionmailer (4.2.3)
84
+ actionpack (= 4.2.3)
85
+ actionview (= 4.2.3)
86
+ activejob (= 4.2.3)
87
+ mail (~> 2.5, >= 2.5.4)
88
+ rails-dom-testing (~> 1.0, >= 1.0.5)
89
+ actionpack (4.2.3)
90
+ actionview (= 4.2.3)
91
+ activesupport (= 4.2.3)
92
+ rack (~> 1.6)
93
+ rack-test (~> 0.6.2)
94
+ rails-dom-testing (~> 1.0, >= 1.0.5)
95
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
96
+ actionview (4.2.3)
97
+ activesupport (= 4.2.3)
98
+ builder (~> 3.1)
99
+ erubis (~> 2.7.0)
100
+ rails-dom-testing (~> 1.0, >= 1.0.5)
101
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
102
+ activejob (4.2.3)
103
+ activesupport (= 4.2.3)
104
+ globalid (>= 0.3.0)
105
+ activemerchant (1.47.0)
106
+ activesupport (>= 3.2.14, < 5.0.0)
107
+ builder (>= 2.1.2, < 4.0.0)
108
+ i18n (>= 0.6.9)
109
+ nokogiri (~> 1.4)
110
+ activemodel (4.2.3)
111
+ activesupport (= 4.2.3)
112
+ builder (~> 3.1)
113
+ activerecord (4.2.3)
114
+ activemodel (= 4.2.3)
115
+ activesupport (= 4.2.3)
116
+ arel (~> 6.0)
117
+ activesupport (4.2.3)
118
+ i18n (~> 0.7)
119
+ json (~> 1.7, >= 1.7.7)
120
+ minitest (~> 5.1)
121
+ thread_safe (~> 0.3, >= 0.3.4)
122
+ tzinfo (~> 1.1)
123
+ acts_as_list (0.7.2)
124
+ activerecord (>= 3.0)
125
+ addressable (2.3.8)
126
+ arel (6.0.3)
127
+ autoprefixer-rails (5.2.1.1)
128
+ execjs
129
+ json
130
+ awesome_nested_set (3.0.2)
131
+ activerecord (>= 4.0.0, < 5)
132
+ bcrypt (3.1.10)
133
+ bootstrap-sass (3.3.5)
134
+ autoprefixer-rails (>= 5.0.0.1)
135
+ sass (>= 3.2.19)
136
+ builder (3.2.2)
137
+ byebug (5.0.0)
138
+ columnize (= 0.9.0)
139
+ camertron-eprun (1.1.0)
140
+ cancancan (1.10.1)
141
+ canonical-rails (0.0.9)
142
+ rails (>= 3.1, < 5.0)
143
+ capybara (2.4.4)
144
+ mime-types (>= 1.16)
145
+ nokogiri (>= 1.3.3)
146
+ rack (>= 1.0.0)
147
+ rack-test (>= 0.5.4)
148
+ xpath (~> 2.0)
149
+ carmen (1.0.2)
150
+ activesupport (>= 3.0.0)
151
+ cldr-plurals-runtime-rb (1.0.0)
152
+ climate_control (0.0.3)
153
+ activesupport (>= 3.0)
154
+ cocaine (0.5.7)
155
+ climate_control (>= 0.0.3, < 1.0)
156
+ coderay (1.1.0)
157
+ coffee-rails (4.1.0)
158
+ coffee-script (>= 2.2.0)
159
+ railties (>= 4.0.0, < 5.0)
160
+ coffee-script (2.4.1)
161
+ coffee-script-source
162
+ execjs
163
+ coffee-script-source (1.9.1.1)
164
+ colorize (0.7.7)
165
+ columnize (0.9.0)
166
+ css_parser (1.3.6)
167
+ addressable
168
+ database_cleaner (1.4.1)
169
+ deface (1.0.1)
170
+ colorize (>= 0.5.8)
171
+ nokogiri (~> 1.6.0)
172
+ polyglot
173
+ rails (>= 3.1)
174
+ devise (3.4.1)
175
+ bcrypt (~> 3.0)
176
+ orm_adapter (~> 0.1)
177
+ railties (>= 3.2.6, < 5)
178
+ responders
179
+ thread_safe (~> 0.1)
180
+ warden (~> 1.2.3)
181
+ devise-encryptable (0.1.2)
182
+ devise (>= 2.1.0)
183
+ diff-lcs (1.2.5)
184
+ docile (1.1.5)
185
+ erubis (2.7.0)
186
+ execjs (2.5.2)
187
+ factory_girl (4.5.0)
188
+ activesupport (>= 3.0.0)
189
+ ffaker (1.32.1)
190
+ font-awesome-rails (4.4.0.0)
191
+ railties (>= 3.2, < 5.0)
192
+ friendly_id (5.1.0)
193
+ activerecord (>= 4.0.0)
194
+ globalid (0.3.6)
195
+ activesupport (>= 4.1.0)
196
+ highline (1.6.21)
197
+ hike (1.2.3)
198
+ htmlentities (4.3.4)
199
+ httparty (0.13.5)
200
+ json (~> 1.8)
201
+ multi_xml (>= 0.5.2)
202
+ i18n (0.7.0)
203
+ jquery-rails (4.0.4)
204
+ rails-dom-testing (~> 1.0)
205
+ railties (>= 4.2.0)
206
+ thor (>= 0.14, < 2.0)
207
+ jquery-ui-rails (5.0.5)
208
+ railties (>= 3.2.16)
209
+ json (1.8.3)
210
+ kaminari (0.16.3)
211
+ actionpack (>= 3.0.0)
212
+ activesupport (>= 3.0.0)
213
+ loofah (2.0.2)
214
+ nokogiri (>= 1.5.9)
215
+ mail (2.6.3)
216
+ mime-types (>= 1.16, < 3)
217
+ method_source (0.8.2)
218
+ mime-types (2.6.1)
219
+ mini_portile (0.6.2)
220
+ minitest (5.8.0)
221
+ monetize (1.3.1)
222
+ money (~> 6.6)
223
+ money (6.6.1)
224
+ i18n (>= 0.6.4, <= 0.7.0)
225
+ multi_json (1.11.2)
226
+ multi_xml (0.5.5)
227
+ nokogiri (1.6.6.2)
228
+ mini_portile (~> 0.6.0)
229
+ orm_adapter (0.5.0)
230
+ paperclip (4.2.4)
231
+ activemodel (>= 3.2.0)
232
+ activesupport (>= 3.2.0)
233
+ cocaine (~> 0.5.5)
234
+ mime-types
235
+ paranoia (2.1.3)
236
+ activerecord (~> 4.0)
237
+ polyamorous (1.2.0)
238
+ activerecord (>= 3.0)
239
+ polyglot (0.3.5)
240
+ premailer (1.8.4)
241
+ css_parser (>= 1.3.6)
242
+ htmlentities (>= 4.0.0)
243
+ premailer-rails (1.8.2)
244
+ actionmailer (>= 3, < 5)
245
+ premailer (~> 1.7, >= 1.7.9)
246
+ pry (0.10.2)
247
+ coderay (~> 1.1.0)
248
+ method_source (~> 0.8.1)
249
+ slop (~> 3.4)
250
+ pry-byebug (3.2.0)
251
+ byebug (~> 5.0)
252
+ pry (~> 0.10)
253
+ rabl (0.9.4.pre1)
254
+ activesupport (>= 2.3.14)
255
+ rack (1.6.4)
256
+ rack-test (0.6.3)
257
+ rack (>= 1.0)
258
+ rails (4.2.3)
259
+ actionmailer (= 4.2.3)
260
+ actionpack (= 4.2.3)
261
+ actionview (= 4.2.3)
262
+ activejob (= 4.2.3)
263
+ activemodel (= 4.2.3)
264
+ activerecord (= 4.2.3)
265
+ activesupport (= 4.2.3)
266
+ bundler (>= 1.3.0, < 2.0)
267
+ railties (= 4.2.3)
268
+ sprockets-rails
269
+ rails-deprecated_sanitizer (1.0.3)
270
+ activesupport (>= 4.2.0.alpha)
271
+ rails-dom-testing (1.0.6)
272
+ activesupport (>= 4.2.0.beta, < 5.0)
273
+ nokogiri (~> 1.6.0)
274
+ rails-deprecated_sanitizer (>= 1.0.1)
275
+ rails-html-sanitizer (1.0.2)
276
+ loofah (~> 2.0)
277
+ railties (4.2.3)
278
+ actionpack (= 4.2.3)
279
+ activesupport (= 4.2.3)
280
+ rake (>= 0.8.7)
281
+ thor (>= 0.18.1, < 2.0)
282
+ rake (10.4.2)
283
+ ransack (1.4.1)
284
+ actionpack (>= 3.0)
285
+ activerecord (>= 3.0)
286
+ activesupport (>= 3.0)
287
+ i18n
288
+ polyamorous (~> 1.1)
289
+ responders (2.1.0)
290
+ railties (>= 4.2.0, < 5)
291
+ rspec-core (3.3.2)
292
+ rspec-support (~> 3.3.0)
293
+ rspec-expectations (3.3.1)
294
+ diff-lcs (>= 1.2.0, < 2.0)
295
+ rspec-support (~> 3.3.0)
296
+ rspec-mocks (3.3.2)
297
+ diff-lcs (>= 1.2.0, < 2.0)
298
+ rspec-support (~> 3.3.0)
299
+ rspec-rails (3.3.3)
300
+ actionpack (>= 3.0, < 4.3)
301
+ activesupport (>= 3.0, < 4.3)
302
+ railties (>= 3.0, < 4.3)
303
+ rspec-core (~> 3.3.0)
304
+ rspec-expectations (~> 3.3.0)
305
+ rspec-mocks (~> 3.3.0)
306
+ rspec-support (~> 3.3.0)
307
+ rspec-support (3.3.0)
308
+ sass (3.2.19)
309
+ sass-rails (4.0.5)
310
+ railties (>= 4.0.0, < 5.0)
311
+ sass (~> 3.2.2)
312
+ sprockets (~> 2.8, < 3.0)
313
+ sprockets-rails (~> 2.0)
314
+ select2-rails (3.5.9.1)
315
+ thor (~> 0.14)
316
+ simplecov (0.10.0)
317
+ docile (~> 1.1.0)
318
+ json (~> 1.8)
319
+ simplecov-html (~> 0.10.0)
320
+ simplecov-html (0.10.0)
321
+ slop (3.6.0)
322
+ sprockets (2.12.4)
323
+ hike (~> 1.2)
324
+ multi_json (~> 1.0)
325
+ rack (~> 1.0)
326
+ tilt (~> 1.1, != 1.3.0)
327
+ sprockets-rails (2.3.2)
328
+ actionpack (>= 3.0)
329
+ activesupport (>= 3.0)
330
+ sprockets (>= 2.8, < 4.0)
331
+ sqlite3 (1.3.10)
332
+ state_machines (0.4.0)
333
+ state_machines-activemodel (0.3.0)
334
+ activemodel (~> 4.1)
335
+ state_machines (>= 0.4.0)
336
+ state_machines-activerecord (0.3.0)
337
+ activerecord (~> 4.1)
338
+ state_machines-activemodel (>= 0.3.0)
339
+ stringex (2.5.2)
340
+ thor (0.19.1)
341
+ thread_safe (0.3.5)
342
+ tilt (1.4.1)
343
+ truncate_html (0.9.2)
344
+ twitter_cldr (3.2.1)
345
+ camertron-eprun
346
+ cldr-plurals-runtime-rb (~> 1.0.0)
347
+ json
348
+ tzinfo
349
+ tzinfo (1.2.2)
350
+ thread_safe (~> 0.1)
351
+ versioncake (2.3.1)
352
+ actionpack (>= 3.2)
353
+ activesupport (>= 3.2)
354
+ railties (>= 3.2)
355
+ tzinfo
356
+ warden (1.2.3)
357
+ rack (>= 1.0)
358
+ xpath (2.0.0)
359
+ nokogiri (~> 1.3)
360
+
361
+ PLATFORMS
362
+ ruby
363
+
364
+ DEPENDENCIES
365
+ capybara (~> 2.4)
366
+ coffee-rails
367
+ database_cleaner
368
+ factory_girl (~> 4.5)
369
+ proclaimer!
370
+ pry-byebug
371
+ rspec-rails (~> 3.1)
372
+ sass-rails (~> 4.0.2)
373
+ simplecov
374
+ spree!
375
+ spree_auth_devise!
376
+ sqlite3
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 ground(ctrl)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
data/README.md ADDED
@@ -0,0 +1,58 @@
1
+ Proclaimer
2
+ ==========
3
+
4
+ An easy, and extensible transactional event notification add on for Spree
5
+
6
+ Installation
7
+ ------------
8
+
9
+ Add proclaimer to your Gemfile:
10
+
11
+ ```ruby
12
+ gem "proclaimer"
13
+ ```
14
+
15
+ Bundle your dependencies and run the installation generator:
16
+
17
+ ```shell
18
+ bundle
19
+ bundle exec rails g proclaimer:install
20
+ ```
21
+
22
+ Usage
23
+ -----
24
+
25
+ Use `Proclaimer.configure` block to setup subscription:
26
+
27
+ ```ruby
28
+ Proclaimer.configure do |config|
29
+ # Subscribe to a particular event
30
+ config.subscribe("order.complete") do |event, payload|
31
+ # ...
32
+ end
33
+
34
+ # Subscribe to any events related to order
35
+ config.subscribe("order") do |event, payload|
36
+ # ...
37
+ end
38
+
39
+ # Subscribe to any Spree events
40
+ config.subscribe_all do |event, payload|
41
+ # ...
42
+ end
43
+ end
44
+ ```
45
+
46
+ Testing
47
+ -------
48
+
49
+ First bundle your dependencies, then run `rake`. `rake` will default to
50
+ building the dummy app if it does not exist, then it will run specs. The dummy
51
+ app can be regenerated by using `rake test_app`.
52
+
53
+ ```shell
54
+ bundle
55
+ bundle exec rake
56
+ ```
57
+
58
+ Copyright (c) 2015 ground(ctrl), released under the MIT License
data/Rakefile ADDED
@@ -0,0 +1,30 @@
1
+ require "bundler"
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require "rspec/core/rake_task"
5
+ require "spree/testing_support/extension_rake"
6
+
7
+ RSpec::Core::RakeTask.new
8
+
9
+ task :default do
10
+ if Dir["spec/dummy"].empty?
11
+ Rake::Task[:test_app].invoke
12
+ Dir.chdir("../../")
13
+ end
14
+ Rake::Task[:spec].invoke
15
+ end
16
+
17
+ desc "Generates a dummy app for testing"
18
+ task :test_app do
19
+ ENV["LIB_NAME"] = "proclaimer"
20
+ Rake::Task["extension:test_app"].invoke
21
+ Rake::Task["test_app:cleanup"].invoke
22
+ end
23
+
24
+ desc "Remove references to JavaScript and CSS files from dummy app"
25
+ task "test_app:cleanup" do
26
+ Dir["#{__dir__}/spec/dummy/vendor/**/all.{css,js}"].each do |path|
27
+ content = File.read(path).sub(%r<^.*require spree/\S+/proclaimer.*$>, "")
28
+ File.open(path, "w") { |file| file.write(content) }
29
+ end
30
+ end
@@ -0,0 +1,14 @@
1
+ module Spree
2
+ Order.class_eval do
3
+ state_machine.after_transition to: :complete, do: :notify_order_completion
4
+
5
+ private
6
+
7
+ def notify_order_completion
8
+ ActiveSupport::Notifications.instrument(
9
+ "spree.order.complete",
10
+ order: self
11
+ )
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ module Spree
2
+ OrderUpdater.class_eval do
3
+ def update_shipments_with_state_tracking
4
+ shipment_states = shipments.map(&:state)
5
+ update_shipments_without_state_tracking
6
+
7
+ shipments.each_with_index do |shipment, index|
8
+ shipment.broadcast_state if shipment_states[index] != shipment.state
9
+ end
10
+ end
11
+
12
+ alias_method_chain :update_shipments, :state_tracking
13
+ end
14
+ end
@@ -0,0 +1,16 @@
1
+ module Spree
2
+ Payment.class_eval do
3
+ state_machine.after_transition \
4
+ to: :completed,
5
+ do: :notify_payment_completion
6
+
7
+ private
8
+
9
+ def notify_payment_completion
10
+ ActiveSupport::Notifications.instrument(
11
+ "spree.payment.complete",
12
+ payment: self
13
+ )
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,14 @@
1
+ module Spree
2
+ Refund.class_eval do
3
+ after_create :notify_refund_processed
4
+
5
+ private
6
+
7
+ def notify_refund_processed
8
+ ActiveSupport::Notifications.instrument(
9
+ "spree.refund.complete",
10
+ refund: self
11
+ )
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,24 @@
1
+ module Spree
2
+ Shipment.class_eval do
3
+ after_create :notify_shipment_pending
4
+ state_machine.after_transition to: :ready, do: :notify_shipment_ready
5
+ state_machine.after_transition to: :canceled, do: :notify_shipment_canceled
6
+
7
+ def broadcast_state
8
+ notification_event(state)
9
+ end
10
+
11
+ private
12
+
13
+ %i(pending resume ready canceled).each do |type|
14
+ define_method(:"notify_shipment_#{type}") { notification_event type }
15
+ end
16
+
17
+ def notification_event(type)
18
+ ActiveSupport::Notifications.instrument(
19
+ "spree.shipment.#{type}",
20
+ shipment: self
21
+ )
22
+ end
23
+ end
24
+ end
data/bin/rails ADDED
@@ -0,0 +1,7 @@
1
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
2
+
3
+ ENGINE_ROOT = File.expand_path('../..', __FILE__)
4
+ ENGINE_PATH = File.expand_path('../../lib/proclaimer/engine', __FILE__)
5
+
6
+ require 'rails/all'
7
+ require 'rails/engine/commands'
data/bin/rake ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rake' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('rake', 'rake')
@@ -0,0 +1,24 @@
1
+ require "active_support/notifications"
2
+
3
+ module Proclaimer
4
+ class Configuration
5
+ def subscribe(event_name, callable = Proc.new)
6
+ if callable.respond_to?(:call)
7
+ ActiveSupport::Notifications.subscribe(
8
+ /^spree\.#{Regexp.escape(event_name)}/,
9
+ -> (event, *args, payload) do
10
+ callable.call(event, payload)
11
+ end
12
+ )
13
+ else
14
+ raise \
15
+ ArgumentError,
16
+ "Callback must be a block or object responding to #call."
17
+ end
18
+ end
19
+
20
+ def subscribe_all(callable = Proc.new)
21
+ subscribe("", callable)
22
+ end
23
+ end
24
+ end