fitgem 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -21,10 +21,10 @@ We've started to develop an example app using the fitgem client. See [https://g
21
21
 
22
22
  The Fitbit API allows for you to set up notification subscription so that when values change (via automatic syncs with the fitbit device) your applications can be notified automatically. You can set up a default subscription callback URL via the [Fitbit dev site](https://dev.fitbit.com/ 'Fitbit Developer Site') and then use the Subscriptions API to add or remove subscriptions for individual users.
23
23
 
24
- __Currently, notification management is experimental in this gem__. There is currently code to add, remove, and list subscriptions (foods, activities, sleep, body, and all collections).
24
+ __Currently, notification management is experimental in this gem__. There is currently code to add, remove, and list subscriptions (foods, activities, sleep, body, and all collections).
25
25
 
26
26
 
27
- # FAQs
27
+ # FAQs
28
28
  ## What About ruby-fitbit?
29
29
 
30
30
  There is a good looking gem called [ruby-fitbit](https://github.com/danmayer/ruby-fitbit "ruby-fitbit") that also aims to collect data from the site. It was created before they released their REST API and uses screen-scraping to gather the data rather than through their API. I looked into forking it and refactoring to use the new API but after looking through the code I felt it would be more of a total rewrite and so decided to create a new gem that I could design from scratch.
@@ -51,4 +51,4 @@ The Fitbit REST API is in BETA right now, and so it will quite likely change ove
51
51
 
52
52
  ### Copyright ###
53
53
 
54
- Copyright (c) 2011 Zachery Moneypenny. See LICENSE for further details.
54
+ Copyright (c) 2011-2012 Zachery Moneypenny. See LICENSE for further details.
@@ -27,7 +27,7 @@ module Fitgem
27
27
  # a hash containing confirmation information for the subscription.
28
28
  # @since v0.4.0
29
29
  def create_subscription(opts)
30
- resp = raw_post make_subscription_url(opts), EMPTY_BODY, make_headers(opts.merge({:use_subscription_id => true}))
30
+ resp = raw_post make_subscription_url(opts.merge({:use_subscription_id => true})), EMPTY_BODY, make_headers(opts)
31
31
  [resp.code, extract_response_body(resp)]
32
32
  end
33
33
 
@@ -48,7 +48,7 @@ module Fitgem
48
48
  # a hash containing confirmation information for the subscription.
49
49
  # @since v0.4.0
50
50
  def remove_subscription(opts)
51
- resp = raw_delete make_subscription_url(opts), make_headers(opts.merge({:use_subscription_id => true}))
51
+ resp = raw_delete make_subscription_url(opts.merge({:use_subscription_id => true})), make_headers(opts)
52
52
  [resp.code, extract_response_body(resp)]
53
53
  end
54
54
 
@@ -81,16 +81,10 @@ module Fitgem
81
81
  # @return [Hash] The headers has to pass to the get/post/put/delete
82
82
  # methods
83
83
  def make_headers(opts)
84
- headers = opts.dup
84
+ headers = {}
85
85
  if opts[:subscriber_id]
86
86
  headers['X-Fitbit-Subscriber-Id'] = opts[:subscriber_id]
87
- headers.delete :subscriber_id
88
87
  end
89
-
90
- headers.delete :subscription_id if headers[:subscription_id]
91
- headers.delete :type if headers[:type]
92
- headers.delete :use_subscription_id if headers[:use_subscription_id]
93
-
94
88
  headers
95
89
  end
96
90
 
@@ -109,10 +103,10 @@ module Fitgem
109
103
  def make_subscription_url(opts)
110
104
  validate_subscription_type opts[:type]
111
105
  path = if opts[:type] == :all
112
- ""
113
- else
114
- "/"+opts[:type].to_s
115
- end
106
+ ""
107
+ else
108
+ "/"+opts[:type].to_s
109
+ end
116
110
  url = "/user/#{@user_id}#{path}/apiSubscriptions"
117
111
  if opts[:use_subscription_id]
118
112
  unless opts[:subscription_id]
@@ -1,3 +1,3 @@
1
1
  module Fitgem
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
@@ -32,7 +32,7 @@ describe Fitgem::Client do
32
32
 
33
33
  it "adds the :use_subscription_id flag and calls #make_headers" do
34
34
  opts = { :subscriber_id => "5555", :type => :all, :subscription_id => "320" }
35
- @client.should_receive(:make_headers).with({ :subscriber_id => "5555", :type => :all, :subscription_id => "320", :use_subscription_id => true })
35
+ @client.should_receive(:make_headers).with({ :subscriber_id => "5555", :type => :all, :subscription_id => "320"})
36
36
  @client.create_subscription(opts)
37
37
  end
38
38
 
@@ -69,7 +69,7 @@ describe Fitgem::Client do
69
69
 
70
70
  it "adds the :use_subscription_id flag and calls #make_headers" do
71
71
  opts = { :subscriber_id => "5555", :type => :all, :subscription_id => "320" }
72
- @client.should_receive(:make_headers).with({ :subscriber_id => "5555", :type => :all, :subscription_id => "320", :use_subscription_id => true })
72
+ @client.should_receive(:make_headers).with({ :subscriber_id => "5555", :type => :all, :subscription_id => "320" })
73
73
  @client.remove_subscription(opts)
74
74
  end
75
75
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fitgem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-22 00:00:00.000000000 Z
12
+ date: 2012-01-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: oauth
16
- requirement: &70184430460560 !ruby/object:Gem::Requirement
16
+ requirement: &70336813924980 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70184430460560
24
+ version_requirements: *70336813924980
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &70184430460140 !ruby/object:Gem::Requirement
27
+ requirement: &70336813924560 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70184430460140
35
+ version_requirements: *70336813924560
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &70184430495900 !ruby/object:Gem::Requirement
38
+ requirement: &70336813960400 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70184430495900
46
+ version_requirements: *70336813960400
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: guard
49
- requirement: &70184430494680 !ruby/object:Gem::Requirement
49
+ requirement: &70336813959180 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70184430494680
57
+ version_requirements: *70336813959180
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: guard-rspec
60
- requirement: &70184430493220 !ruby/object:Gem::Requirement
60
+ requirement: &70336813957720 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70184430493220
68
+ version_requirements: *70336813957720
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rb-fsevent
71
- requirement: &70184430492320 !ruby/object:Gem::Requirement
71
+ requirement: &70336813956900 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70184430492320
79
+ version_requirements: *70336813956900
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: growl
82
- requirement: &70184430491460 !ruby/object:Gem::Requirement
82
+ requirement: &70336813956040 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70184430491460
90
+ version_requirements: *70336813956040
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: yard
93
- requirement: &70184430490160 !ruby/object:Gem::Requirement
93
+ requirement: &70336813954640 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70184430490160
101
+ version_requirements: *70336813954640
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: rdiscount
104
- requirement: &70184430488900 !ruby/object:Gem::Requirement
104
+ requirement: &70336813953360 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,7 +109,7 @@ dependencies:
109
109
  version: '0'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *70184430488900
112
+ version_requirements: *70336813953360
113
113
  description: A client library to send and retrieve workout, weight, and diet data
114
114
  from fitbit.com
115
115
  email:
@@ -168,7 +168,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
168
168
  version: '0'
169
169
  segments:
170
170
  - 0
171
- hash: 2581731821553703730
171
+ hash: -4091779949925866203
172
172
  required_rubygems_version: !ruby/object:Gem::Requirement
173
173
  none: false
174
174
  requirements:
@@ -177,7 +177,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
177
177
  version: '0'
178
178
  segments:
179
179
  - 0
180
- hash: 2581731821553703730
180
+ hash: -4091779949925866203
181
181
  requirements: []
182
182
  rubyforge_project: fitgem
183
183
  rubygems_version: 1.8.10