gridhook 0.1.0 → 0.1.1

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: 929f775d4ad5ef72c2271ea9214652640e6288e1
4
- data.tar.gz: b458d351413b42c38ac1e8f3e063fa71ba0cf3b1
3
+ metadata.gz: cd1b5b0d7fdd8ee2aabe014129eb68735f7e2559
4
+ data.tar.gz: aff3bde4721b9444ef3e1d33963438a40e5fdd8b
5
5
  SHA512:
6
- metadata.gz: ddc1640c178b547cc72993c7e834103b2f872013bfc464b64ff56fe773f391a0e080e511d91391f93588173384b545293b4030eb13d01f8b9874b765d9a64b58
7
- data.tar.gz: c8f4a9793e857b751aea2ffdb9007a6f6259289378c55839e9114709ae2b4d8fce835dc6c00c08d8580f5d1009751a3d9dac4b3f6bfd38502d920af4c47f0bd5
6
+ metadata.gz: be176c7e538cd9edd0d87681aee4b95176f594ff1e05db89da37d1abf47aa49a7567e8c7521d2fa576e4dce7ac1fd308987b9bd6271fa1e998aa26c6cf93b314
7
+ data.tar.gz: 48cec9955b1ac5884010856e1dd38729bec8d2111173d0b15d23a124aeb74388c1557969756d10523dc834a6bde2c4d92a99d9b9e417e23e0dc84d6c678ce38d
data/README.md CHANGED
@@ -11,17 +11,14 @@ Add Gridhook to your application's Gemfile and run `bundle install`:
11
11
  gem 'gridhook'
12
12
  ```
13
13
 
14
- Add a route for the default event handling endpoint that Gridhook provides:
15
-
16
- ```ruby
17
- post '/email_event' => 'gridhook/events#create'
18
- ```
19
-
20
14
  You must also tell Gridhook how to process your event. Simply add an
21
15
  initializer in `config/initializers/gridhook.rb`:
22
16
 
23
17
  ```ruby
24
18
  Gridhook.configure do |config|
19
+ # The path we want to receive events
20
+ config.event_receive_path = '/sendgrid/event'
21
+
25
22
  config.event_processor = proc do |event|
26
23
  # event is a Gridhook::Event object
27
24
  EmailEvent.create! event.attributes
@@ -45,6 +42,11 @@ Gridhook.configure do |config|
45
42
  end
46
43
  ```
47
44
 
45
+ ## TODO
46
+
47
+ * More tests
48
+ * Integrate [parse webhook](http://sendgrid.com/docs/API_Reference/Webhooks/parse.html)
49
+
48
50
  ## More Information
49
51
 
50
52
  * [SendGrid Webhooks](http://sendgrid.com/docs/API_Reference/Webhooks/index.html)
@@ -0,0 +1,3 @@
1
+ Rails.application.routes.draw do
2
+ post Gridhook.config.event_receive_path => 'gridhook/events#create'
3
+ end
@@ -8,7 +8,11 @@ module Gridhook
8
8
  yield config
9
9
  end
10
10
 
11
- class Config < Struct.new(:event_processor)
11
+ class Config < Struct.new(:event_processor, :event_receive_path)
12
+ def initialize(*)
13
+ self.event_receive_path = '/sendgrid/event'
14
+ super
15
+ end
12
16
  end
13
17
 
14
18
  end
@@ -1,4 +1,7 @@
1
+ require 'gridhook/unfortunate_sendgrid_fix'
2
+
1
3
  module Gridhook
2
4
  class Engine < ::Rails::Engine
5
+ config.app_middleware.insert_before ActionDispatch::ParamsParser, 'UnfortunateSendgridFix'
3
6
  end
4
7
  end
@@ -0,0 +1,12 @@
1
+ class UnfortunateSendgridFix
2
+ def initialize(app)
3
+ @app = app
4
+ end
5
+
6
+ def call(env)
7
+ if env['PATH_INFO'] == Gridhook.config.event_receive_path
8
+ env['CONTENT_TYPE'] = 'text/plain'
9
+ end
10
+ @app.call(env)
11
+ end
12
+ end
@@ -1,3 +1,3 @@
1
1
  module Gridhook
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gridhook
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lee Jarvis
@@ -94,12 +94,14 @@ files:
94
94
  - Rakefile
95
95
  - app/controllers/gridhook/events_controller.rb
96
96
  - config/initializers/gridhook.rb
97
+ - config/routes.rb
97
98
  - gridhook.gemspec
98
99
  - lib/gridhook.rb
99
100
  - lib/gridhook/config.rb
100
101
  - lib/gridhook/engine.rb
101
102
  - lib/gridhook/errors.rb
102
103
  - lib/gridhook/event.rb
104
+ - lib/gridhook/unfortunate_sendgrid_fix.rb
103
105
  - lib/gridhook/version.rb
104
106
  - test/dummy/README.rdoc
105
107
  - test/dummy/Rakefile