Browse files

Merge pull request #11 from andrewpbrett/master

strength training activities and user settings
  • Loading branch information...
2 parents 33f0607 + 1fe9b77 commit b382166bacda897eb2a63cc9c077e7300fa0092a @andrewpbrett andrewpbrett committed Jul 17, 2012
View
2 .gitignore
@@ -1,5 +1,5 @@
Gemfile.lock
-
+health-graph-*.gem
# rcov generated
coverage
View
2 VERSION
@@ -1 +1 @@
-0.5.6
+0.6.0
View
36 health_graph.gemspec
@@ -5,11 +5,11 @@
Gem::Specification.new do |s|
s.name = "health_graph"
- s.version = "0.5.6"
+ s.version = "0.6.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Kenny Ma"]
- s.date = "2012-05-09"
+ s.date = "2012-07-17"
s.description = "This is a wrapper for RunKeeper Health Graph RESTful API."
s.email = "kenny@kennyma.me"
s.extra_rdoc_files = [
@@ -34,7 +34,10 @@ Gem::Specification.new do |s|
"lib/health_graph/models/fitness_activity_update.rb",
"lib/health_graph/models/new_fitness_activity.rb",
"lib/health_graph/models/profile.rb",
+ "lib/health_graph/models/settings.rb",
"lib/health_graph/models/sleep_feed.rb",
+ "lib/health_graph/models/strength_training_activities_feed.rb",
+ "lib/health_graph/models/strength_training_activity.rb",
"lib/health_graph/models/user.rb",
"lib/health_graph/models/weight_feed.rb",
"test/fixtures/background_activities_feed.json",
@@ -61,7 +64,7 @@ Gem::Specification.new do |s|
s.homepage = "http://github.com/kennyma/health_graph"
s.licenses = ["MIT"]
s.require_paths = ["lib"]
- s.rubygems_version = "1.8.24"
+ s.rubygems_version = "1.8.13"
s.summary = "Ruby gem for RunKeeper Health Graph API"
if s.respond_to? :specification_version then
@@ -72,6 +75,15 @@ Gem::Specification.new do |s|
s.add_development_dependency(%q<shoulda>, [">= 0"])
s.add_development_dependency(%q<simplecov>, [">= 0"])
s.add_development_dependency(%q<jeweler>, [">= 0"])
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
s.add_runtime_dependency(%q<oauth2>, [">= 0.5.2"])
s.add_runtime_dependency(%q<faraday>, [">= 0.7.4"])
s.add_runtime_dependency(%q<faraday_middleware>, [">= 0.7.8"])
@@ -85,6 +97,15 @@ Gem::Specification.new do |s|
s.add_dependency(%q<shoulda>, [">= 0"])
s.add_dependency(%q<simplecov>, [">= 0"])
s.add_dependency(%q<jeweler>, [">= 0"])
+ s.add_dependency(%q<shoulda>, [">= 0"])
+ s.add_dependency(%q<simplecov>, [">= 0"])
+ s.add_dependency(%q<jeweler>, [">= 0"])
+ s.add_dependency(%q<shoulda>, [">= 0"])
+ s.add_dependency(%q<simplecov>, [">= 0"])
+ s.add_dependency(%q<jeweler>, [">= 0"])
+ s.add_dependency(%q<shoulda>, [">= 0"])
+ s.add_dependency(%q<simplecov>, [">= 0"])
+ s.add_dependency(%q<jeweler>, [">= 0"])
s.add_dependency(%q<oauth2>, [">= 0.5.2"])
s.add_dependency(%q<faraday>, [">= 0.7.4"])
s.add_dependency(%q<faraday_middleware>, [">= 0.7.8"])
@@ -99,6 +120,15 @@ Gem::Specification.new do |s|
s.add_dependency(%q<shoulda>, [">= 0"])
s.add_dependency(%q<simplecov>, [">= 0"])
s.add_dependency(%q<jeweler>, [">= 0"])
+ s.add_dependency(%q<shoulda>, [">= 0"])
+ s.add_dependency(%q<simplecov>, [">= 0"])
+ s.add_dependency(%q<jeweler>, [">= 0"])
+ s.add_dependency(%q<shoulda>, [">= 0"])
+ s.add_dependency(%q<simplecov>, [">= 0"])
+ s.add_dependency(%q<jeweler>, [">= 0"])
+ s.add_dependency(%q<shoulda>, [">= 0"])
+ s.add_dependency(%q<simplecov>, [">= 0"])
+ s.add_dependency(%q<jeweler>, [">= 0"])
s.add_dependency(%q<oauth2>, [">= 0.5.2"])
s.add_dependency(%q<faraday>, [">= 0.7.4"])
s.add_dependency(%q<faraday_middleware>, [">= 0.7.8"])
View
2 lib/health_graph.rb
@@ -10,9 +10,11 @@
require 'health_graph/models/weight_feed'
require 'health_graph/models/sleep_feed'
require 'health_graph/models/fitness_activities_feed'
+require 'health_graph/models/strength_training_activities_feed'
require 'health_graph/models/new_fitness_activity'
require 'health_graph/models/fitness_activity_update'
require 'health_graph/models/fitness_activity_delete'
+require 'health_graph/models/settings'
module HealthGraph
extend Configuration
View
3 lib/health_graph/configuration.rb
@@ -39,7 +39,8 @@ module Configuration
:diabetes_feed => "application/vnd.com.runkeeper.DiabetesFeed+json",
:diatetes_measurement => "application/vnd.com.runkeeper.DiabetesMeasurement+json",
:records => "application/vnd.com.runkeeper.Records+json",
- :profile => "application/vnd.com.runkeeper.Profile+json"
+ :profile => "application/vnd.com.runkeeper.Profile+json",
+ :settings => "application/vnd.com.runkeeper.Settings+json"
}.freeze
attr_accessor *VALID_OPTIONS_KEYS
View
18 lib/health_graph/models/settings.rb
@@ -0,0 +1,18 @@
+module HealthGraph
+ class Settings
+ include Model
+
+ hash_attr_accessor :distance_units, :weight_units
+
+ def initialize(access_token, path)
+ self.access_token = access_token
+ response = get path, HealthGraph.accept_headers[:settings]
+ self.body = response.body
+ populate_from_hash! self.body
+ end
+
+ def elite?
+ self.body["elite"] == "true"
+ end
+ end
+end
View
24 lib/health_graph/models/strength_training_activities_feed.rb
@@ -0,0 +1,24 @@
+module HealthGraph
+ class StrengthTrainingActivitiesFeed
+ include Model
+
+ hash_attr_accessor :items, :next, :previous, :size
+
+ class Item
+ include Model
+
+ hash_attr_accessor :start_time, :uri
+
+ def initialize(hash)
+ populate_from_hash! hash
+ end
+ end
+
+ def initialize(access_token, path, params = {})
+ self.access_token = access_token
+ response = get path, HealthGraph.accept_headers[:strength_training_activity_feed], params
+ self.body = response.body
+ populate_from_hash! self.body
+ end
+ end
+end
View
8 lib/health_graph/models/strength_training_activity.rb
@@ -0,0 +1,8 @@
+module HealthGraph
+ class StrengthTrainingActivity
+ include Model
+
+ hash_attr_accessor :uri, :start_time, :notes
+ end
+
+end
View
8 lib/health_graph/models/user.rb
@@ -15,6 +15,10 @@ def profile
HealthGraph::Profile.new self.access_token, self.body["profile"]
end
+ def settings
+ HealthGraph::Settings.new self.access_token, self.body["settings"]
+ end
+
def weight
HealthGraph::WeightFeed.new self.access_token, self.body["weight"]
end
@@ -38,5 +42,9 @@ def fitness_activity_update params
def fitness_activity_delete params
HealthGraph::FitnessActivityDelete.new self.access_token, params
end
+
+ def strength_training_activities params = {}
+ HealthGraph::StrengthTrainingActivitiesFeed.new self.access_token, self.body["strength_training_activities"], params
+ end
end
end

0 comments on commit b382166

Please sign in to comment.