gridhook 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -0
- data/gridhook.gemspec +1 -1
- data/lib/gridhook.rb +1 -2
- data/lib/gridhook/engine.rb +0 -5
- data/lib/gridhook/event.rb +4 -7
- data/lib/gridhook/version.rb +1 -1
- data/test/gridlock/event_test.rb +0 -9
- metadata +8 -9
- data/lib/gridhook/unfortunate_sendgrid_fix.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ad6d5bbe35f5ec6ea021d69e67971e053deb4af
|
4
|
+
data.tar.gz: 3eab2c6b882d0f6277b87fa8c8cdb9c2c177519d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 087d115559a7a5ab94831ad5a1375a36b933b7612100f4c7e3ed29131d7b844d5ed066c68d64ee8d736a43bc3557b47c8f2c7462fc32f530495bf1b201a281b5
|
7
|
+
data.tar.gz: 9d3bf84b34671514fd207e4212dc1f5d2648227c6bb6efe582d7e4f17f86713103dca19d990f9c6f7deb16e995d439a19c02da60d64fde6eaee197566fcbb5f3
|
data/README.md
CHANGED
@@ -48,6 +48,12 @@ Gridhook.configure do |config|
|
|
48
48
|
end
|
49
49
|
```
|
50
50
|
|
51
|
+
## Changelog
|
52
|
+
v0.2.0 Supports version 3 of the Sendgrid webhook released on
|
53
|
+
September 6th, 2013, which provides the proper headers and JSON post body
|
54
|
+
without hacks or middleware. If upgrading to this version, please make sure
|
55
|
+
to update the Webhooks settings in your SendGrid App to use V3 of their API.
|
56
|
+
|
51
57
|
## TODO
|
52
58
|
|
53
59
|
* More tests
|
data/gridhook.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.require_paths = ['app', 'lib']
|
21
21
|
|
22
22
|
spec.add_dependency 'rails', '>= 3.1.0'
|
23
|
-
spec.add_dependency '
|
23
|
+
spec.add_dependency 'multi_json', '>= 1.3.0'
|
24
24
|
|
25
25
|
spec.add_development_dependency 'bundler', '~> 1.2'
|
26
26
|
spec.add_development_dependency 'rake'
|
data/lib/gridhook.rb
CHANGED
data/lib/gridhook/engine.rb
CHANGED
@@ -1,9 +1,4 @@
|
|
1
|
-
require 'gridhook/unfortunate_sendgrid_fix'
|
2
|
-
|
3
1
|
module Gridhook
|
4
2
|
class Engine < ::Rails::Engine
|
5
|
-
# Insert our SendGrid JSON fix middleware before ParamsParser
|
6
|
-
# attempts to encode the JSON.
|
7
|
-
config.app_middleware.insert_before ActionDispatch::ParamsParser, 'Gridhook::UnfortunateSendgridFix'
|
8
3
|
end
|
9
4
|
end
|
data/lib/gridhook/event.rb
CHANGED
@@ -6,21 +6,18 @@ module Gridhook
|
|
6
6
|
# Process a String or stream of JSON and execute our
|
7
7
|
# event processor.
|
8
8
|
#
|
9
|
-
# body - A String or stream for
|
9
|
+
# body - A String or stream for MultiJson to parse
|
10
10
|
#
|
11
11
|
# Returns nothing.
|
12
12
|
def self.process(body, params = {})
|
13
|
-
|
14
|
-
|
13
|
+
begin
|
14
|
+
event = MultiJson.load(body)
|
15
15
|
if event.is_a?(Array)
|
16
16
|
process_events event
|
17
17
|
else
|
18
18
|
process_event event
|
19
19
|
end
|
20
|
-
|
21
|
-
begin
|
22
|
-
parser.parse(body)
|
23
|
-
rescue Yajl::ParseError
|
20
|
+
rescue MultiJson::LoadError
|
24
21
|
process_event params.except(:controller, :action)
|
25
22
|
end
|
26
23
|
end
|
data/lib/gridhook/version.rb
CHANGED
data/test/gridlock/event_test.rb
CHANGED
@@ -18,15 +18,6 @@ class EventTest < TestCase
|
|
18
18
|
assert_equal 'delivered', @events.first.name
|
19
19
|
end
|
20
20
|
|
21
|
-
test 'parsing incoming (invalid) JSON in batches' do
|
22
|
-
process <<-E
|
23
|
-
{"email":"foo@bar.com","timestamp":1322000095,"unique_arg":"my unique arg","event":"delivered"}
|
24
|
-
{"email":"foo@bar.com","timestamp":1322000096,"unique_arg":"my unique arg","event":"open"}
|
25
|
-
E
|
26
|
-
assert_kind_of Gridhook::Event, @events.first
|
27
|
-
assert_equal 2, @events.size
|
28
|
-
end
|
29
|
-
|
30
21
|
# for when sendgrid fix their JSON batch requests
|
31
22
|
test 'parsing incoming (valid) JSON in batches' do
|
32
23
|
obj = [
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gridhook
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lee Jarvis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -25,19 +25,19 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 3.1.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: multi_json
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.
|
33
|
+
version: 1.3.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.
|
40
|
+
version: 1.3.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -101,7 +101,6 @@ files:
|
|
101
101
|
- lib/gridhook/engine.rb
|
102
102
|
- lib/gridhook/errors.rb
|
103
103
|
- lib/gridhook/event.rb
|
104
|
-
- lib/gridhook/unfortunate_sendgrid_fix.rb
|
105
104
|
- lib/gridhook/version.rb
|
106
105
|
- test/dummy/README.rdoc
|
107
106
|
- test/dummy/Rakefile
|
@@ -159,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
159
158
|
version: '0'
|
160
159
|
requirements: []
|
161
160
|
rubyforge_project:
|
162
|
-
rubygems_version: 2.0.
|
161
|
+
rubygems_version: 2.0.2
|
163
162
|
signing_key:
|
164
163
|
specification_version: 4
|
165
164
|
summary: A SendGrid webhook endpoint
|