jawbit 0.0.2 → 0.0.3

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: 9c480afee49fefd14c6a1c48493da44cfefd738c
4
- data.tar.gz: 1f8da41ffc532f305795445ce08f12e6b2f2a763
3
+ metadata.gz: 02cfb4a2ba5c805af02a075023fc9265f181e3cd
4
+ data.tar.gz: 472c898d95d5b6a27383b63ad17af073a55b871d
5
5
  SHA512:
6
- metadata.gz: 27045e00a200a8269516bf638d73bee54b3dec39c333b04dc4aa1ec9251540862c7ff2888b6e9630cfffadc92904874526d4b5d2dbcaeb2bed142425651b14b1
7
- data.tar.gz: 2258a8a60122cd543e1b3f6e64af6ededb2f3c65a73a56932036324fa4fe3095cdd229ff8c524d396c4874ef4b783ada2e3f848798ff8cb158f151f4c172b583
6
+ metadata.gz: 8cc597800a7802e35513a8f1d7bb3258adac9e986f56e8defea72c4f7551d610ff0a3acd74ce72acef5df4871be6a50e326a89b705637fd93991e4d01e2e3260
7
+ data.tar.gz: 02b776e04c3fe74ae8676f8450ea3eac7b47180601304a6a8d134c384c20c211c27f6a648d337adc227c49d8e537d0a489a0fd9b5836d8e40a1bc7e4b6ac920f
data/.travis.yml CHANGED
@@ -6,6 +6,6 @@ rvm:
6
6
  - 2.1.1
7
7
  notifications:
8
8
  slack:
9
- secure: "jHdpTKZw0/7FAmBH6y5uRjFiY9cxRMbWN2F8pQcffmiCncBK59PZC8ppF5tGLV/NEX4knZPkU4gw2e6/IfFsP6cznj6SpzaQAgHJko2e7+I1P0AGNkizzVbWK4ix55YP59v+/9cBa5ldargD2/qUdqpdAv1EVzU2GslNWooq6qQ="
9
+ secure: "aN7wc3+0EvwROw91z1OQK6zowdmRJESDWb541Q0PfmzMcQULAFtQKcJJ3UH/WlDle8aMVKfy3iqwZOJbDSLuPW7PXiHhiFlsSCOzQjxPDPYyeOooGBxEzfay5bWFxrYMUISRSi29mH6LEDEN2qYGHJaZbgjyNNzDrxsLJhS3clg="
10
10
  on_success: change
11
11
  on_failure: change
data/README.md CHANGED
@@ -1,13 +1,13 @@
1
1
  # Jawbit
2
2
 
3
- For receiving Fitbit subscription requests in a Rails (or Rack) app.
3
+ For receiving Fitbit and/or Jawbone subscription requests in a Rails (or Rack) app.
4
4
 
5
5
  ## Installation
6
6
 
7
7
  Add this line to your application's Gemfile:
8
8
 
9
9
  ```ruby
10
- gem 'jawbit', '0.0.2'
10
+ gem 'jawbit', '0.0.3'
11
11
  ```
12
12
 
13
13
  ## Usage
@@ -17,12 +17,18 @@ gem 'jawbit', '0.0.2'
17
17
  post '/fitbit/subscriptions', to: Jawbit::FitbitRack.new(
18
18
  subscriber_id, consumer_secret
19
19
  )
20
+ post '/jawbone/subscriptions', to: Jawbit::JawboneRack.new
20
21
 
21
22
  # in an initialiser:
22
23
  ActiveSupport::Notifications.subscribe('notification.fitbit') do |*args|
23
24
  event = ActiveSupport::Notifications::Event.new *args
24
25
  # use event.payload[:json] however you like.
25
26
  end
27
+
28
+ ActiveSupport::Notifications.subscribe('notification.jawbone') do |*args|
29
+ event = ActiveSupport::Notifications::Event.new *args
30
+ # use event.payload[:json] however you like.
31
+ end
26
32
  ```
27
33
 
28
34
  ## Contributing
@@ -35,4 +41,4 @@ end
35
41
 
36
42
  ## Licence
37
43
 
38
- Copyright (c) 2014, Fitbit Subscriptions is developed and maintained by [Inspire9](http://development.inspire9.com), and is released under the open MIT Licence.
44
+ Copyright (c) 2014, Jawbit is developed and maintained by [Inspire9](http://development.inspire9.com), and is released under the open MIT Licence.
data/jawbit.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  # coding: utf-8
2
2
  Gem::Specification.new do |spec|
3
3
  spec.name = 'jawbit'
4
- spec.version = '0.0.2'
4
+ spec.version = '0.0.3'
5
5
  spec.authors = ['Pat Allan']
6
6
  spec.email = ['pat@freelancing-gods.com']
7
7
  spec.summary = %q{Captures Fitbit and Jawbone subscription notifications.}
@@ -0,0 +1,19 @@
1
+ class Jawbit::JawboneRack
2
+ delegate :instrument, to: ActiveSupport::Notifications
3
+
4
+ def call(env)
5
+ request = Rack::Request.new env
6
+
7
+ instrument 'notification.jawbone', json: json(request)
8
+
9
+ [200, {}, ['']]
10
+ end
11
+
12
+ private
13
+
14
+ def json(request)
15
+ MultiJson.load request.body.read
16
+ rescue MultiJson::ParseError
17
+ []
18
+ end
19
+ end
data/lib/jawbit.rb CHANGED
@@ -7,3 +7,4 @@ module Jawbit
7
7
  end
8
8
 
9
9
  require 'jawbit/fitbit_rack'
10
+ require 'jawbit/jawbone_rack'
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Jawbone Subscriptions' do
4
+ include Rack::Test::Methods
5
+
6
+ let(:app) { Jawbit::JawboneRack.new }
7
+ let(:subscriptions) { [] }
8
+
9
+ def subscribe(&block)
10
+ subscriptions << ActiveSupport::Notifications.subscribe(
11
+ 'notification.jawbone', &block
12
+ )
13
+ end
14
+
15
+ after :each do
16
+ subscriptions.each do |subscription|
17
+ ActiveSupport::Notifications.unsubscribe(subscription)
18
+ end
19
+ end
20
+
21
+ it 'returns a 200' do
22
+ post '/'
23
+
24
+ expect(last_response.status).to eq(200)
25
+ end
26
+
27
+ it 'fires an event' do
28
+ notification = false
29
+ subscribe { |*args| notification = true }
30
+
31
+ post '/'
32
+
33
+ expect(notification).to eq(true)
34
+ end
35
+
36
+ it 'includes the JSON body' do
37
+ subscribe { |*args|
38
+ event = ActiveSupport::Notifications::Event.new *args
39
+ expect(event.payload[:json]).to eq([{'foo' => 'bar'}])
40
+ }
41
+
42
+ post '/', '[{"foo":"bar"}]'
43
+ end
44
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jawbit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pat Allan
@@ -98,7 +98,9 @@ files:
98
98
  - jawbit.gemspec
99
99
  - lib/jawbit.rb
100
100
  - lib/jawbit/fitbit_rack.rb
101
- - spec/acceptance/notifications_spec.rb
101
+ - lib/jawbit/jawbone_rack.rb
102
+ - spec/acceptance/fitbit_notifications_spec.rb
103
+ - spec/acceptance/jawbone_notifications_spec.rb
102
104
  - spec/spec_helper.rb
103
105
  homepage: https://github.com/inspire9/jawbit
104
106
  licenses:
@@ -125,6 +127,7 @@ signing_key:
125
127
  specification_version: 4
126
128
  summary: Captures Fitbit and Jawbone subscription notifications.
127
129
  test_files:
128
- - spec/acceptance/notifications_spec.rb
130
+ - spec/acceptance/fitbit_notifications_spec.rb
131
+ - spec/acceptance/jawbone_notifications_spec.rb
129
132
  - spec/spec_helper.rb
130
133
  has_rdoc: