webhooker 0.1.2 → 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.
- checksums.yaml +4 -4
- data/app/jobs/webhooker/trigger_job.rb +12 -2
- data/config/spring.rb +1 -0
- data/lib/webhooker/config.rb +10 -0
- data/lib/webhooker/version.rb +1 -1
- data/lib/webhooker.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a277008a0b540d629182febcdcc8d6d22d8f08ca
|
4
|
+
data.tar.gz: 38f244063164b4d5b2041a3ad51be361c09ac287
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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,
|
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
|
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
data/lib/webhooker/version.rb
CHANGED
data/lib/webhooker.rb
CHANGED
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.
|
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-
|
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
|