chargify-loops 0.1.0 → 0.2.0

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.
data/HISTORY CHANGED
@@ -1,2 +1,5 @@
1
+ 0.2.0 - February 6th 2012
2
+ * Making sure all keys are strings (matching the payload hashes).
3
+
1
4
  0.1.0 - November 17th 2011
2
5
  * First release
data/README.textile CHANGED
@@ -16,14 +16,14 @@ Then add an initializer for your loops, and provide your shared key:
16
16
  Chargify::Loops.shared_key = 'secret-key-from-chargify'
17
17
 
18
18
  Chargify::Loops.loop! :signup_success do |payload|
19
- Emails.welcome(payload[:subscription][:customer][:email]).deliver
19
+ Emails.welcome(payload['subscription']['customer']['email']).deliver
20
20
  end
21
21
 
22
22
  Chargify::Loops.loop! :payment_failure do |payload|
23
- Banker.loan payload[:payment][:amount_in_cents]
23
+ Banker.loan payload['payment']['amount_in_cents']
24
24
  end</code></pre>
25
25
 
26
- If a web hook is invalid, it'll never hit your loops - so you're only dealing with valid hook requests.
26
+ If a web hook is invalid, it'll never hit your loops - so you're only dealing with valid hook requests. All hash keys will be strings (I normally prefer symbols, but hashes within hashes had string keys, so opting with that as a default).
27
27
 
28
28
  Also: it's best to keep your loops short and sweet - don't put business logic in your initializer, but somewhere else where you've got some test coverage. As a rule of thumb, if you've got more than one line inside a loop block, then you should probably consider whether that code could be somewhere else.
29
29
 
@@ -3,7 +3,7 @@ class Chargify::HooksController < ActionController::Base
3
3
 
4
4
  def create
5
5
  Chargify::Loops.delegate_hook params[:event].to_sym,
6
- params[:payload].symbolize_keys
6
+ params[:payload].stringify_keys!
7
7
 
8
8
  head :ok
9
9
  end
@@ -1,5 +1,5 @@
1
1
  module Chargify
2
2
  module Loops
3
- VERSION = '0.1.0'
3
+ VERSION = '0.2.0'
4
4
  end
5
5
  end
@@ -37,7 +37,7 @@ describe Chargify::HooksController do
37
37
 
38
38
  it "delegates the hook to the appropriate loops" do
39
39
  Chargify::Loops.should_receive(:delegate_hook).
40
- with(:test, {:chargify => 'testing'})
40
+ with(:test, {'chargify' => 'testing'})
41
41
 
42
42
  post_with_signature :create, :payload => {:chargify => 'testing'},
43
43
  :event => 'test'
metadata CHANGED
@@ -1,64 +1,46 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: chargify-loops
3
- version: !ruby/object:Gem::Version
4
- hash: 27
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 1
9
- - 0
10
- version: 0.1.0
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Pat Allan
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-11-17 00:00:00 +07:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2012-02-06 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: rails
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &70144716951620 !ruby/object:Gem::Requirement
25
17
  none: false
26
- requirements:
18
+ requirements:
27
19
  - - ~>
28
- - !ruby/object:Gem::Version
29
- hash: 7
30
- segments:
31
- - 3
32
- - 0
33
- version: "3.0"
20
+ - !ruby/object:Gem::Version
21
+ version: '3.0'
34
22
  type: :runtime
35
- version_requirements: *id001
36
- - !ruby/object:Gem::Dependency
37
- name: rspec-rails
38
23
  prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *70144716951620
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec-rails
27
+ requirement: &70144716951120 !ruby/object:Gem::Requirement
40
28
  none: false
41
- requirements:
42
- - - "="
43
- - !ruby/object:Gem::Version
44
- hash: 19
45
- segments:
46
- - 2
47
- - 7
48
- - 0
29
+ requirements:
30
+ - - =
31
+ - !ruby/object:Gem::Version
49
32
  version: 2.7.0
50
33
  type: :development
51
- version_requirements: *id002
52
- description: A Rails Engine that handles Chargify Webhooks requests and validates and forwards them off to registered loops.
53
- email:
34
+ prerelease: false
35
+ version_requirements: *70144716951120
36
+ description: A Rails Engine that handles Chargify Webhooks requests and validates
37
+ and forwards them off to registered loops.
38
+ email:
54
39
  - pat@freelancing-gods.com
55
40
  executables: []
56
-
57
41
  extensions: []
58
-
59
42
  extra_rdoc_files: []
60
-
61
- files:
43
+ files:
62
44
  - .gitignore
63
45
  - Gemfile
64
46
  - HISTORY
@@ -78,43 +60,34 @@ files:
78
60
  - spec/internal/log/.gitignore
79
61
  - spec/internal/public/favicon.ico
80
62
  - spec/spec_helper.rb
81
- has_rdoc: true
82
63
  homepage: https://github.com/freelancing-god/chargify-loops
83
64
  licenses: []
84
-
85
65
  post_install_message:
86
66
  rdoc_options: []
87
-
88
- require_paths:
67
+ require_paths:
89
68
  - lib
90
- required_ruby_version: !ruby/object:Gem::Requirement
69
+ required_ruby_version: !ruby/object:Gem::Requirement
91
70
  none: false
92
- requirements:
93
- - - ">="
94
- - !ruby/object:Gem::Version
95
- hash: 3
96
- segments:
97
- - 0
98
- version: "0"
99
- required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ! '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
76
  none: false
101
- requirements:
102
- - - ">="
103
- - !ruby/object:Gem::Version
104
- hash: 3
105
- segments:
106
- - 0
107
- version: "0"
77
+ requirements:
78
+ - - ! '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
108
81
  requirements: []
109
-
110
82
  rubyforge_project: chargify-loops
111
- rubygems_version: 1.4.2
83
+ rubygems_version: 1.8.10
112
84
  signing_key:
113
85
  specification_version: 3
114
86
  summary: A Rails Engine for Chargify Webhooks
115
- test_files:
87
+ test_files:
116
88
  - spec/chargify/loops_spec.rb
117
89
  - spec/controllers/chargify/hooks_controller_spec.rb
118
90
  - spec/internal/log/.gitignore
119
91
  - spec/internal/public/favicon.ico
120
92
  - spec/spec_helper.rb
93
+ has_rdoc: