misfit_gem 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MDZmZjZjZDI3OGQxYmYzYjMyYTBmODAxNmM5ZTI1ZjNlZDBkMGFhOQ==
5
+ data.tar.gz: !binary |-
6
+ ZjAyY2Q1NWE3NmFiY2JiMDgyZGYyNjc0YjVhZTljMzEwMzMyMzQ3NQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ NjVmMWViOGNhMzdkY2Y2ZTQ3MTM1MWRkM2NmY2UyYTI4NGU4MmUyMTA5Zjhl
10
+ MDkyOGRkZDJjYjY0NzRhMmYyMGRiMjdjZDM5ZGQwMTk3YTE2NzZlZjFmNGFm
11
+ ZTkyMzYyMjI2ZTViMzBhZjVhNjdkMmIwNjMyZjgyMzg5ZDg2Yjk=
12
+ data.tar.gz: !binary |-
13
+ OTUxYmYwZWM3Y2VjNzNiZjk0YjY0ODJhNDNkZjdkODYzNzIyMTUyNGQ4MTZk
14
+ MzQ5NWUwMTQxZTRmYTFiYzU1YmJkY2FmNDVkNTVjNDNkMDEwYmFkOTc0ZTk1
15
+ YWE3NzVhZjk3MmNmNGJiNDEzYmU1MGM3NmE0NTA2YWEyNjBjNWY=
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ .bundle/
2
+ log/*.log
3
+ pkg/
4
+ test/dummy/db/*.sqlite3
5
+ test/dummy/db/*.sqlite3-journal
6
+ test/dummy/log/*.log
7
+ test/dummy/tmp/
8
+ test/dummy/.sass-cache
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ group :test do
6
+ gem 'guard-rspec'
7
+ gem 'rb-inotify', :require => false
8
+ gem 'rb-fsevent', :require => false
9
+ gem 'rb-fchange', :require => false
10
+ gem 'terminal-notifier-guard'
11
+ end
data/Guardfile ADDED
@@ -0,0 +1,12 @@
1
+ guard 'rspec', :version => 2, cmd: "bundle exec rspec" do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
4
+ watch('spec/spec_helper.rb') { "spec" }
5
+
6
+ # Rails example
7
+ watch(%r{^spec/.+_spec\.rb$})
8
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
9
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
10
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
11
+ watch('spec/spec_helper.rb') { "spec" }
12
+ end
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2014 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,4 @@
1
+ misfit_gem
2
+ ==========
3
+
4
+ A client library to retrieve data from misfit shine
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ require 'bundler'
2
+ require 'rspec/core/rake_task'
3
+
4
+ Bundler::GemHelper.install_tasks
5
+
6
+ desc 'Default: run specs.'
7
+ task :default => :spec
8
+
9
+ desc "Run specs"
10
+ RSpec::Core::RakeTask.new do |t|
11
+ t.pattern = "./spec/**/*_spec.rb" # don't need this, it's default.
12
+ # Put spec opts in a file named .rspec in root
13
+ end
data/changelog.md ADDED
@@ -0,0 +1,10 @@
1
+ # @markup markdown
2
+ # @author Jay Whiting
3
+
4
+ # misfit_gem changelog
5
+
6
+ ## v0.1.0
7
+
8
+ #### 2014-11-13 Jay Whiting <misfit_gem@thedevsquad.com>
9
+
10
+ * First revision. Supports the auth process via oauth, and retrieval of resources.
@@ -0,0 +1,93 @@
1
+ require 'misfit_gem/errors'
2
+ require 'misfit_gem/helpers'
3
+ require 'misfit_gem/version'
4
+ require 'misfit_gem/profile'
5
+ require 'misfit_gem/device'
6
+ require 'misfit_gem/goals'
7
+ require 'misfit_gem/summary'
8
+ require 'misfit_gem/sessions'
9
+ require 'misfit_gem/sleeps'
10
+ require 'date'
11
+ require 'uri'
12
+
13
+ module MisfitGem
14
+ class Client
15
+ API_VERSION = 'v1'
16
+ EMPTY_BODY = ''
17
+
18
+ attr_accessor :api_version
19
+
20
+ def initialize(opts)
21
+ missing = [:consumer_key, :consumer_secret] - opts.keys
22
+ if missing.size > 0
23
+ raise MisfitGem::InvalidArgumentError, "Missing required options: #{missing.join(',')}"
24
+ end
25
+ @consumer_key = opts[:consumer_key]
26
+ @consumer_secret = opts[:consumer_secret]
27
+
28
+ @token = opts[:token]
29
+ @secret = opts[:secret]
30
+
31
+ @proxy = opts[:proxy] if opts[:proxy]
32
+ @user_id = opts[:user_id] || '-'
33
+
34
+ @api_version = API_VERSION
35
+ end
36
+
37
+ def authorize(token, secret, opts={})
38
+ request_token = OAuth::RequestToken.new(consumer, token, secret)
39
+ @access_token = request_token.get_access_token(opts)
40
+ @token = @access_token.token
41
+ @secret = @access_token.secret
42
+ @access_token
43
+ end
44
+
45
+ def reconnect(token, secret)
46
+ @token = token
47
+ @secret = secret
48
+ access_token
49
+ end
50
+
51
+ def connected?
52
+ !@access_token.nil?
53
+ end
54
+
55
+ def request_token(opts={})
56
+ consumer.get_request_token(opts)
57
+ end
58
+
59
+ def authentication_request_token(opts={})
60
+ consumer.options[:authorize_path] = '/oauth/authenticate'
61
+ request_token(opts)
62
+ end
63
+
64
+ private
65
+
66
+ def consumer
67
+ @consumer ||= OAuth::Consumer.new(@consumer_key, @consumer_secret, {
68
+ :site => 'https://api.misfitwearables.com',
69
+ :proxy => @proxy
70
+ })
71
+ end
72
+
73
+ def access_token
74
+ @access_token ||= OAuth::AccessToken.new(consumer, @token, @secret)
75
+ end
76
+
77
+ def get(path)
78
+ extract_response_body raw_get(path)
79
+ end
80
+
81
+ def raw_get(path)
82
+ headers = {'User-Agent' => "misfit_gem gem v#{MisfitGem::VERSION}", 'access_token' => @token}
83
+ uri = "/move/resource/#{@api_version}#{path}"
84
+
85
+ access_token.get(uri, headers)
86
+ end
87
+
88
+ def extract_response_body(resp)
89
+ resp.nil? || resp.body.nil? ? {} : JSON.parse(resp.body)
90
+ end
91
+
92
+ end
93
+ end
@@ -0,0 +1,9 @@
1
+ module MisfitGem
2
+ class Client
3
+
4
+ def get_device
5
+ get("/user/me/device")
6
+ end
7
+
8
+ end
9
+ end
@@ -0,0 +1,16 @@
1
+ module MisfitGem
2
+ class InvalidArgumentError < ArgumentError
3
+ end
4
+
5
+ class InvalidDateArgument < InvalidArgumentError
6
+ end
7
+
8
+ class InvalidDateRangeArgument < InvalidArgumentError
9
+ end
10
+
11
+ class ConnectionRequiredError < Exception
12
+ end
13
+
14
+ class DeprecatedApiError < Exception
15
+ end
16
+ end
@@ -0,0 +1,23 @@
1
+ module MisfitGem
2
+ class Client
3
+
4
+ def get_goals(opts)
5
+
6
+ missing = [:start_date, :end_date] - opts.keys
7
+ if missing.size > 0
8
+ raise MisfitGem::InvalidArgumentError, "Missing required options: #{missing.join(',')}"
9
+ end
10
+
11
+ start_date_string = format_date(opts[:start_date])
12
+ end_date_string = format_date(opts[:end_date])
13
+
14
+ check_date_range(start_date_string, end_date_string)
15
+
16
+ parameters = "start_date=#{start_date_string}&end_date=#{end_date_string}"
17
+
18
+ get("/user/me/activity/goals?#{parameters}")
19
+
20
+ end
21
+
22
+ end
23
+ end
@@ -0,0 +1,41 @@
1
+ module MisfitGem
2
+ class Client
3
+
4
+ def format_date(date)
5
+ if date.is_a? String
6
+ case date
7
+ when 'today'
8
+ return Date.today.strftime("%Y-%m-%d")
9
+ when 'yesterday'
10
+ return (Date.today-1).strftime("%Y-%m-%d")
11
+ else
12
+ unless date =~ /\d{4}\-\d{2}\-\d{2}/
13
+ raise MisfitGem::InvalidDateArgument, "Invalid date (#{date}), must be in yyyy-MM-dd format"
14
+ end
15
+ return date
16
+ end
17
+ elsif Date === date || Time === date || DateTime === date
18
+ return date.strftime("%Y-%m-%d")
19
+ else
20
+ raise MisfitGem::InvalidDateArgument, "Date used must be a date/time object or a string in the format YYYY-MM-DD; supplied argument is a #{date.class}"
21
+ end
22
+ end
23
+
24
+ def check_date_range(start_date_string, end_date_string)
25
+
26
+ start_date = Date.parse(start_date_string)
27
+ end_date = Date.parse(end_date_string)
28
+
29
+ if (end_date - start_date > 30)
30
+ raise MisfitGem::InvalidDateRangeArgument, "Dates must be less than 30 days apart"
31
+ end
32
+
33
+ if (end_date < start_date)
34
+ raise MisfitGem::InvalidDateRangeArgument, "End date must be after start date"
35
+ end
36
+
37
+ end
38
+
39
+ end
40
+
41
+ end
@@ -0,0 +1,9 @@
1
+ module MisfitGem
2
+ class Client
3
+
4
+ def get_profile
5
+ get("/user/me/profile")
6
+ end
7
+
8
+ end
9
+ end
@@ -0,0 +1,23 @@
1
+ module MisfitGem
2
+ class Client
3
+
4
+ def get_sessions(opts)
5
+
6
+ missing = [:start_date, :end_date] - opts.keys
7
+ if missing.size > 0
8
+ raise MisfitGem::InvalidArgumentError, "Missing required options: #{missing.join(',')}"
9
+ end
10
+
11
+ start_date_string = format_date(opts[:start_date])
12
+ end_date_string = format_date(opts[:end_date])
13
+
14
+ check_date_range(start_date_string, end_date_string)
15
+
16
+ parameters = "start_date=#{start_date_string}&end_date=#{end_date_string}&detail=#{detail}"
17
+
18
+ get("/user/me/activity/sessions?#{parameters}")
19
+
20
+ end
21
+
22
+ end
23
+ end
@@ -0,0 +1,23 @@
1
+ module MisfitGem
2
+ class Client
3
+
4
+ def get_sleeps(opts)
5
+
6
+ missing = [:start_date, :end_date] - opts.keys
7
+ if missing.size > 0
8
+ raise MisfitGem::InvalidArgumentError, "Missing required options: #{missing.join(',')}"
9
+ end
10
+
11
+ start_date_string = format_date(opts[:start_date])
12
+ end_date_string = format_date(opts[:end_date])
13
+
14
+ check_date_range(start_date_string, end_date_string)
15
+
16
+ parameters = "start_date=#{start_date_string}&end_date=#{end_date_string}&detail=#{detail}"
17
+
18
+ get("/user/me/activity/sleeps?#{parameters}")
19
+
20
+ end
21
+
22
+ end
23
+ end
@@ -0,0 +1,24 @@
1
+ module MisfitGem
2
+ class Client
3
+
4
+ def get_summary(opts)
5
+
6
+ missing = [:start_date, :end_date] - opts.keys
7
+ if missing.size > 0
8
+ raise MisfitGem::InvalidArgumentError, "Missing required options: #{missing.join(',')}"
9
+ end
10
+
11
+ start_date_string = format_date(opts[:start_date])
12
+ end_date_string = format_date(opts[:end_date])
13
+ detail = opts[:detail]
14
+
15
+ check_date_range(start_date_string, end_date_string)
16
+
17
+ parameters = "start_date=#{start_date_string}&end_date=#{end_date_string}&detail=#{detail}"
18
+
19
+ get("/user/me/activity/summary?#{parameters}")
20
+
21
+ end
22
+
23
+ end
24
+ end
@@ -0,0 +1,3 @@
1
+ module MisfitGem
2
+ VERSION = "0.1.0"
3
+ end
data/lib/misfit_gem.rb ADDED
@@ -0,0 +1,9 @@
1
+ require 'json'
2
+ require 'oauth'
3
+ require 'misfit_gem/client'
4
+
5
+ # Read/write data with the {https://build.misfit.com misfit.com} OAuth API.
6
+ #
7
+ # @author Jay Whiting
8
+ module MisfitGem
9
+ end
@@ -0,0 +1,49 @@
1
+ $:.push File.expand_path('../lib', __FILE__)
2
+ $:.push File.join(File.dirname(__FILE__), '.', 'lib')
3
+
4
+ require 'misfit_gem/version'
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = 'misfit_gem'
8
+ s.version = MisfitGem::VERSION
9
+ s.platform = Gem::Platform::RUBY
10
+ s.authors = ['Jay Whiting']
11
+ s.email = ['misfit_gem@thedevsquad.com']
12
+ s.homepage = 'http://github.com/randomizor/misfit_gem.git'
13
+ s.summary = %q{OAuth client library to the data on misfit.com}
14
+ s.description = %q{A client library to retrieve data from misfit shine}
15
+
16
+ s.add_dependency 'oauth'
17
+ s.add_development_dependency 'rake'
18
+ s.add_development_dependency 'rspec', '~> 3.0.0'
19
+
20
+ s.files = [
21
+ '.gitignore',
22
+ 'Gemfile',
23
+ 'Guardfile',
24
+ 'LICENSE',
25
+ 'README.md',
26
+ 'Rakefile',
27
+ 'changelog.md',
28
+ 'misfit_gem.gemspec',
29
+ 'lib/misfit_gem.rb',
30
+ 'lib/misfit_gem/client.rb',
31
+ 'lib/misfit_gem/device.rb',
32
+ 'lib/misfit_gem/errors.rb',
33
+ 'lib/misfit_gem/goals.rb',
34
+ 'lib/misfit_gem/helpers.rb',
35
+ 'lib/misfit_gem/profile.rb',
36
+ 'lib/misfit_gem/sessions.rb',
37
+ 'lib/misfit_gem/sleeps.rb',
38
+ 'lib/misfit_gem/summary.rb',
39
+ 'lib/misfit_gem/version.rb'
40
+ ]
41
+ s.test_files = [
42
+ 'spec/misfit_gem_spec.rb',
43
+ 'spec/spec_helper.rb',
44
+ 'spec/misfit_gem_client_spec.rb',
45
+ 'spec/misfit_gem_information_spec.rb',
46
+ 'spec/misfit_gem_resources_spec.rb'
47
+ ]
48
+ s.require_paths = ['lib']
49
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe MisfitGem::Client do
4
+
5
+ it "requires consumer_key" do
6
+ expect {
7
+ opts = { :consumer_secret => "12345" }
8
+ client = MisfitGem::Client.new(opts)
9
+ }.to raise_error(MisfitGem::InvalidArgumentError, "Missing required options: consumer_key")
10
+ end
11
+
12
+ it "requires consumer_secret" do
13
+ expect {
14
+ opts = { :consumer_key => "12345" }
15
+ client = MisfitGem::Client.new(opts)
16
+ }.to raise_error(MisfitGem::InvalidArgumentError, "Missing required options: consumer_secret")
17
+ end
18
+
19
+ end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ describe MisfitGem::Client do
4
+
5
+ before(:each) do
6
+ @client = MisfitGem::Client.new({
7
+ :consumer_key => '12345',
8
+ :consumer_secret => '67890'
9
+ })
10
+ end
11
+
12
+ describe "#get_profile" do
13
+
14
+ it "returns the correct uri for current profile" do
15
+ expect(@client).to receive(:get).with("/user/me/profile")
16
+ @client.get_profile
17
+ end
18
+
19
+ end
20
+
21
+ describe "#get_device" do
22
+
23
+ it "returns the correct uri for current device" do
24
+ expect(@client).to receive(:get).with("/user/me/device")
25
+ @client.get_device
26
+ end
27
+
28
+ end
29
+
30
+ end
@@ -0,0 +1,188 @@
1
+ require 'spec_helper'
2
+
3
+ describe MisfitGem::Client do
4
+
5
+ before(:each) do
6
+ @client = MisfitGem::Client.new({
7
+ :consumer_key => '12345',
8
+ :consumer_secret => '67890'
9
+ })
10
+ end
11
+
12
+ describe '#get_goals' do
13
+
14
+ before(:each) do
15
+ @opts = {start_date: "2014-11-13", end_date: "2014-11-21"}
16
+ end
17
+
18
+ it 'raises an exception if the :start_date value is missing' do
19
+ @opts.delete :start_date
20
+ expect {
21
+ @client.get_goals @opts
22
+ }.to raise_error(MisfitGem::InvalidArgumentError)
23
+ end
24
+
25
+ it 'raises an exception if the :end_date value is not missing' do
26
+ @opts.delete :end_date
27
+ expect {
28
+ @client.get_goals @opts
29
+ }.to raise_error(MisfitGem::InvalidArgumentError)
30
+ end
31
+
32
+ it 'raises an exception if the date range is greater than 30 days' do
33
+
34
+ @opts[:start_date] = "2014-11-01"
35
+ @opts[:end_date] = "2014-12-30"
36
+
37
+ expect {
38
+ @client.get_goals @opts
39
+ }.to raise_error(MisfitGem::InvalidDateRangeArgument)
40
+
41
+ end
42
+
43
+ it 'raises an exception if the end date is before the start date' do
44
+
45
+ @opts[:start_date] = "2014-12-30"
46
+ @opts[:end_date] = "2014-11-01"
47
+
48
+ expect {
49
+ @client.get_goals @opts
50
+ }.to raise_error(MisfitGem::InvalidDateRangeArgument)
51
+
52
+ end
53
+
54
+ end
55
+
56
+ describe '#get_summary' do
57
+
58
+ before(:each) do
59
+ @opts = {start_date: "2014-11-13", end_date: "2014-11-21"}
60
+ end
61
+
62
+ it 'raises an exception if the :start_date value is missing' do
63
+ @opts.delete :start_date
64
+ expect {
65
+ @client.get_summary @opts
66
+ }.to raise_error(MisfitGem::InvalidArgumentError)
67
+ end
68
+
69
+ it 'raises an exception if the :end_date value is not missing' do
70
+ @opts.delete :end_date
71
+ expect {
72
+ @client.get_summary @opts
73
+ }.to raise_error(MisfitGem::InvalidArgumentError)
74
+ end
75
+
76
+ it 'raises an exception if the date range is greater than 30 days' do
77
+
78
+ @opts[:start_date] = "2014-11-01"
79
+ @opts[:end_date] = "2014-12-30"
80
+
81
+ expect {
82
+ @client.get_summary @opts
83
+ }.to raise_error(MisfitGem::InvalidDateRangeArgument)
84
+
85
+ end
86
+
87
+ it 'raises an exception if the end date is before the start date' do
88
+
89
+ @opts[:start_date] = "2014-12-30"
90
+ @opts[:end_date] = "2014-11-01"
91
+
92
+ expect {
93
+ @client.get_summary @opts
94
+ }.to raise_error(MisfitGem::InvalidDateRangeArgument)
95
+
96
+ end
97
+
98
+ end
99
+
100
+ describe '#get_summary' do
101
+
102
+ before(:each) do
103
+ @opts = {start_date: "2014-11-13", end_date: "2014-11-21"}
104
+ end
105
+
106
+ it 'raises an exception if the :start_date value is missing' do
107
+ @opts.delete :start_date
108
+ expect {
109
+ @client.get_summary @opts
110
+ }.to raise_error(MisfitGem::InvalidArgumentError)
111
+ end
112
+
113
+ it 'raises an exception if the :end_date value is not missing' do
114
+ @opts.delete :end_date
115
+ expect {
116
+ @client.get_summary @opts
117
+ }.to raise_error(MisfitGem::InvalidArgumentError)
118
+ end
119
+
120
+ it 'raises an exception if the date range is greater than 30 days' do
121
+
122
+ @opts[:start_date] = "2014-11-01"
123
+ @opts[:end_date] = "2014-12-30"
124
+
125
+ expect {
126
+ @client.get_summary @opts
127
+ }.to raise_error(MisfitGem::InvalidDateRangeArgument)
128
+
129
+ end
130
+
131
+ it 'raises an exception if the end date is before the start date' do
132
+
133
+ @opts[:start_date] = "2014-12-30"
134
+ @opts[:end_date] = "2014-11-01"
135
+
136
+ expect {
137
+ @client.get_summary @opts
138
+ }.to raise_error(MisfitGem::InvalidDateRangeArgument)
139
+
140
+ end
141
+
142
+ end
143
+
144
+ describe '#get_sleeps' do
145
+
146
+ before(:each) do
147
+ @opts = {start_date: "2014-11-13", end_date: "2014-11-21"}
148
+ end
149
+
150
+ it 'raises an exception if the :start_date value is missing' do
151
+ @opts.delete :start_date
152
+ expect {
153
+ @client.get_sleeps @opts
154
+ }.to raise_error(MisfitGem::InvalidArgumentError)
155
+ end
156
+
157
+ it 'raises an exception if the :end_date value is not missing' do
158
+ @opts.delete :end_date
159
+ expect {
160
+ @client.get_sleeps @opts
161
+ }.to raise_error(MisfitGem::InvalidArgumentError)
162
+ end
163
+
164
+ it 'raises an exception if the date range is greater than 30 days' do
165
+
166
+ @opts[:start_date] = "2014-11-01"
167
+ @opts[:end_date] = "2014-12-30"
168
+
169
+ expect {
170
+ @client.get_sleeps @opts
171
+ }.to raise_error(MisfitGem::InvalidDateRangeArgument)
172
+
173
+ end
174
+
175
+ it 'raises an exception if the end date is before the start date' do
176
+
177
+ @opts[:start_date] = "2014-12-30"
178
+ @opts[:end_date] = "2014-11-01"
179
+
180
+ expect {
181
+ @client.get_sleeps @opts
182
+ }.to raise_error(MisfitGem::InvalidDateRangeArgument)
183
+
184
+ end
185
+
186
+ end
187
+
188
+ end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ describe MisfitGem do
4
+
5
+ before do
6
+ @client = MisfitGem::Client.new({
7
+ :consumer_key => '12345',
8
+ :consumer_secret => '67890'
9
+ })
10
+ end
11
+
12
+ describe 'global settings' do
13
+ it 'should expose the api_version' do
14
+ expect(@client.api_version).to eq "v1"
15
+ end
16
+
17
+ it 'should allow clients to set a new api version' do
18
+ @client.api_version = "v2"
19
+ expect(@client.api_version).to eq "v2"
20
+ end
21
+
22
+ end
23
+ end
@@ -0,0 +1,8 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+
4
+ require 'misfit_gem'
5
+
6
+ RSpec.configure do |config|
7
+ config.mock_with :rspec
8
+ end
metadata ADDED
@@ -0,0 +1,115 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: misfit_gem
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jay Whiting
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: oauth
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 3.0.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 3.0.0
55
+ description: A client library to retrieve data from misfit shine
56
+ email:
57
+ - misfit_gem@thedevsquad.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - Gemfile
64
+ - Guardfile
65
+ - LICENSE
66
+ - README.md
67
+ - Rakefile
68
+ - changelog.md
69
+ - misfit_gem.gemspec
70
+ - lib/misfit_gem.rb
71
+ - lib/misfit_gem/client.rb
72
+ - lib/misfit_gem/device.rb
73
+ - lib/misfit_gem/errors.rb
74
+ - lib/misfit_gem/goals.rb
75
+ - lib/misfit_gem/helpers.rb
76
+ - lib/misfit_gem/profile.rb
77
+ - lib/misfit_gem/sessions.rb
78
+ - lib/misfit_gem/sleeps.rb
79
+ - lib/misfit_gem/summary.rb
80
+ - lib/misfit_gem/version.rb
81
+ - spec/misfit_gem_spec.rb
82
+ - spec/spec_helper.rb
83
+ - spec/misfit_gem_client_spec.rb
84
+ - spec/misfit_gem_information_spec.rb
85
+ - spec/misfit_gem_resources_spec.rb
86
+ homepage: http://github.com/randomizor/misfit_gem.git
87
+ licenses: []
88
+ metadata: {}
89
+ post_install_message:
90
+ rdoc_options: []
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ! '>='
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ! '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ requirements: []
104
+ rubyforge_project:
105
+ rubygems_version: 2.1.11
106
+ signing_key:
107
+ specification_version: 4
108
+ summary: OAuth client library to the data on misfit.com
109
+ test_files:
110
+ - spec/misfit_gem_spec.rb
111
+ - spec/spec_helper.rb
112
+ - spec/misfit_gem_client_spec.rb
113
+ - spec/misfit_gem_information_spec.rb
114
+ - spec/misfit_gem_resources_spec.rb
115
+ has_rdoc: