webhooker 0.1.2 → 0.2.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: d00bfa20cfc5ba71dee551ae7825b149a7be63a2
4
- data.tar.gz: 2c831b174da8ec7928e0fb93bea5ce5957d04ff0
3
+ metadata.gz: a277008a0b540d629182febcdcc8d6d22d8f08ca
4
+ data.tar.gz: 38f244063164b4d5b2041a3ad51be361c09ac287
5
5
  SHA512:
6
- metadata.gz: a3b67753827ed25041814958abb28bfe85fd7f101ac9d0c9c51eb37685a7ed0414c53ea017e19db7350f75975b0e5bcfc6eb3c24d3ce74c895e244ca272e80e0
7
- data.tar.gz: 67ba6c0f877fbd30e6362d08a2c76d3e7ee0c679ee1381934281415f0c39842fd897986d3dd7172e7f3c21876de7880b399933a716a1089c98eb8cc5e1d6fa62
6
+ metadata.gz: 392686f1fcbd17746d3efb0587c7bb6ef5f30a5b43ec909f67d3487c9b9d277c26ba27bd5183a1d229fa202aa570d063aa248a09d161523f171d513581d12c42
7
+ data.tar.gz: 393148dac4ebcac9bad54c517f68f3447064a06ad5c6dd49e06a1af446316220a18d602a8a0eaf90986cf3dd16a3ecfb35d2ccfa34305496fb58c6e1364910bb
@@ -2,8 +2,9 @@ module Webhooker
2
2
  class TriggerJob < ActiveJob::Base
3
3
  queue_as :default
4
4
 
5
- def perform subscriber, payload
5
+ def perform subscriber, data
6
6
  @subscriber = subscriber
7
+ @data = data
7
8
  uri = URI.parse subscriber.url
8
9
  req = Net::HTTP::Post.new(uri.path)
9
10
  req.set_form_data payload
@@ -11,7 +12,7 @@ module Webhooker
11
12
  app = Rails.application.class.parent.to_s
12
13
  body = payload.to_json
13
14
  header = {
14
- 'Content-Type' => 'application/json; charset=utf-8',
15
+ 'Content-Type' => 'application/json',
15
16
  'User-Agent' => app,
16
17
  "X-#{app}-Signature" => create_signature(body)
17
18
  }
@@ -22,5 +23,14 @@ module Webhooker
22
23
  def create_signature body
23
24
  OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'), @subscriber.secret, body)
24
25
  end
26
+
27
+ def payload
28
+ @payload ||=
29
+ if Webhooker.config.payload_key.present?
30
+ { Webhooker.config.payload_key => @data }
31
+ else
32
+ @data
33
+ end
34
+ end
25
35
  end
26
36
  end
data/config/spring.rb CHANGED
@@ -1,2 +1,3 @@
1
1
  Spring.application_root = 'spec/dummy'
2
2
  Spring.watch '../../lib/webhooker'
3
+ Spring.watch '../../lib/webhooker.rb'
@@ -0,0 +1,10 @@
1
+ require 'active_support/configurable'
2
+
3
+ module Webhooker
4
+ include ActiveSupport::Configurable
5
+ config_accessor :payload_key
6
+
7
+ configure do |c|
8
+ c.payload_key = 'payload'
9
+ end
10
+ end
@@ -1,3 +1,3 @@
1
1
  module Webhooker
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/webhooker.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'webhooker/version'
2
2
  require 'webhooker/engine'
3
3
  require 'webhooker/model'
4
+ require 'webhooker/config'
4
5
 
5
6
  module Webhooker
6
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webhooker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - kayhide
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-19 00:00:00.000000000 Z
11
+ date: 2015-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -277,6 +277,7 @@ files:
277
277
  - db/migrate/20151213073634_create_webhooker_subscribers.rb
278
278
  - lib/tasks/webhooker_tasks.rake
279
279
  - lib/webhooker.rb
280
+ - lib/webhooker/config.rb
280
281
  - lib/webhooker/engine.rb
281
282
  - lib/webhooker/model.rb
282
283
  - lib/webhooker/version.rb