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 +4 -4
- data/.travis.yml +1 -1
- data/README.md +9 -3
- data/jawbit.gemspec +1 -1
- data/lib/jawbit/jawbone_rack.rb +19 -0
- data/lib/jawbit.rb +1 -0
- data/spec/acceptance/jawbone_notifications_spec.rb +44 -0
- metadata +6 -3
- /data/spec/acceptance/{notifications_spec.rb → fitbit_notifications_spec.rb} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02cfb4a2ba5c805af02a075023fc9265f181e3cd
|
4
|
+
data.tar.gz: 472c898d95d5b6a27383b63ad17af073a55b871d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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: "
|
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.
|
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,
|
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.
|
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
@@ -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.
|
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
|
-
-
|
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/
|
130
|
+
- spec/acceptance/fitbit_notifications_spec.rb
|
131
|
+
- spec/acceptance/jawbone_notifications_spec.rb
|
129
132
|
- spec/spec_helper.rb
|
130
133
|
has_rdoc:
|
File without changes
|