fitgem 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
data/fitgem.gemspec CHANGED
@@ -2,9 +2,11 @@
2
2
  $:.push File.expand_path("../lib", __FILE__)
3
3
  $:.push File.join(File.dirname(__FILE__), '.', 'lib')
4
4
 
5
+ require 'fitgem/version'
6
+
5
7
  Gem::Specification.new do |s|
6
8
  s.name = "fitgem"
7
- s.version = "0.3.2"
9
+ s.version = Fitgem::VERSION
8
10
  s.platform = Gem::Platform::RUBY
9
11
  s.authors = ["Zachery Moneypenny"]
10
12
  s.email = ["fitgem@whazzmaster.com"]
@@ -20,8 +22,36 @@ Gem::Specification.new do |s|
20
22
  s.add_development_dependency "rb-fsevent"
21
23
  s.add_development_dependency "growl"
22
24
 
23
- s.files = `git ls-files`.split("\n")
24
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
25
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
25
+ s.files = [
26
+ '.gitignore',
27
+ '.rvmrc',
28
+ 'Gemfile',
29
+ 'Guardfile',
30
+ 'LICENSE',
31
+ 'README.md',
32
+ 'Rakefile',
33
+ 'fitgem.gemspec',
34
+ 'lib/fitgem.rb',
35
+ 'lib/fitgem/activities.rb',
36
+ 'lib/fitgem/body_measurements.rb',
37
+ 'lib/fitgem/client.rb',
38
+ 'lib/fitgem/devices.rb',
39
+ 'lib/fitgem/errors.rb',
40
+ 'lib/fitgem/foods.rb',
41
+ 'lib/fitgem/friends.rb',
42
+ 'lib/fitgem/helpers.rb',
43
+ 'lib/fitgem/notifications.rb',
44
+ 'lib/fitgem/sleep.rb',
45
+ 'lib/fitgem/time_range.rb',
46
+ 'lib/fitgem/units.rb',
47
+ 'lib/fitgem/users.rb',
48
+ 'lib/fitgem/water.rb',
49
+ 'spec/fitgem_spec.rb',
50
+ 'spec/spec_helper.rb'
51
+ ]
52
+ s.test_files = [
53
+ 'spec/fitgem_spec.rb',
54
+ 'spec/spec_helper.rb'
55
+ ]
26
56
  s.require_paths = ["lib"]
27
57
  end
data/lib/fitgem.rb CHANGED
@@ -4,5 +4,4 @@ require 'oauth'
4
4
  require 'fitgem/client'
5
5
 
6
6
  module Fitgem
7
- VERSION = "0.3.2"
8
7
  end
data/lib/fitgem/client.rb CHANGED
@@ -75,21 +75,25 @@ module Fitgem
75
75
  headers.merge!("User-Agent" => "fitgem gem v#{Fitgem::VERSION}", "Accept-Language" => @api_unit_system)
76
76
  uri = "/#{@api_version}#{path}"
77
77
  oauth_response = access_token.get(uri, headers)
78
- JSON.parse(oauth_response.body)
78
+ process_response oauth_response
79
79
  end
80
80
 
81
81
  def post(path, body='', headers={})
82
82
  headers.merge!("User-Agent" => "fitgem gem v#{Fitgem::VERSION}", "Accept-Language" => @api_unit_system)
83
83
  uri = "/#{@api_version}#{path}"
84
84
  oauth_response = access_token.post(uri, body, headers)
85
- JSON.parse(oauth_response.body)
85
+ process_response oauth_response
86
86
  end
87
87
 
88
88
  def delete(path, headers={})
89
89
  headers.merge!("User-Agent" => "fitgem gem v#{Fitgem::VERSION}", "Accept-Language" => @api_unit_system)
90
90
  uri = "/#{@api_version}#{path}"
91
91
  oauth_response = access_token.delete(uri, headers)
92
- JSON.parse(oauth_response.body)
92
+ process_response oauth_response
93
+ end
94
+
95
+ def process_response(resp)
96
+ resp.nil? || resp.body.nil? ? {} : JSON.parse(resp.body)
93
97
  end
94
98
  end
95
- end
99
+ end
@@ -20,12 +20,7 @@ module Fitgem
20
20
  url = finalize_subscription_url(base_url, options)
21
21
  headers = {}
22
22
  headers['X-Fitgem-Subscriber-Id'] = options[:subscriber_id] if options[:subscriber_id]
23
- begin
24
- delete(url, headers)
25
- rescue TypeError
26
- # Deleting a subscription returns a nil response, which causes a TypeError
27
- # when the oauth library tries to parse it.
28
- end
23
+ delete(url, headers)
29
24
  end
30
25
 
31
26
  protected
@@ -49,4 +44,4 @@ module Fitgem
49
44
  end
50
45
 
51
46
  end
52
- end
47
+ end
data/lib/fitgem/water.rb CHANGED
@@ -28,11 +28,7 @@ module Fitgem
28
28
  # ==========================================
29
29
 
30
30
  def delete_water_log(log_id)
31
- begin
32
- delete("/user/-/foods/log/water/#{log_id}.json")
33
- rescue TypeError
34
- # OAuth library responds badly to nil responses by fitbit's delete methods
35
- end
31
+ delete("/user/-/foods/log/water/#{log_id}.json")
36
32
  end
37
33
  end
38
- end
34
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: fitgem
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.3.2
5
+ version: 0.3.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Zachery Moneypenny
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-08-19 00:00:00 -05:00
13
+ date: 2011-08-20 00:00:00 -05:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency