oura 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7919509104715a2159f26ce292e6348cc421b35c344b526e14a9e493648d38f9
4
- data.tar.gz: 89ff63d40bcb760185905bfc5f91e079e9c27e232f3778a4b74b365900449624
3
+ metadata.gz: fc0cb134fcdedad75e27f75a7329befdd0c5a4755e6b5c565691231ecb60b2ba
4
+ data.tar.gz: 63b6ff856e32217808920bd8ab5d73e63074f732499206d25ba16dfeaa261b18
5
5
  SHA512:
6
- metadata.gz: 7dcb0169c2e24abe90ff5d835214f6b7b67953e14fe62453ad2acd1171d50766ab4c05559f6ff9d42ec7afb4dff08f8b7ea1aacdad9482d09fc8e172067e7861
7
- data.tar.gz: 47d5cb53a272acba517a0390c5147b0c06536b148b733945a147368786017546eaa10b4e18e62201f97449081cbacce9a3665792e9fe2a2ca70498ac011b7b39
6
+ metadata.gz: 167ee71201bfbb1b11718d7eb59b115800e63aeb1c5a83203f7bab75013884267c3b8ff4c32d421e307c5182b64bea334831b52882f6ee7e1a757848011bc3d0
7
+ data.tar.gz: e25478db494ffbb831cd2628d172c0cfd9f73f47894a299fafca2c0769d8e13dea41dbf3d062ba0e3c2e2300406c3147214971a53b07cc90f33132146b2970e4
data/.gitignore CHANGED
@@ -14,3 +14,4 @@ spec/.rspec_status
14
14
  .envrc
15
15
  vendor
16
16
  Gemfile.lock
17
+ .ruby-version
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  Change Log
2
- ===
2
+ ==========
3
+
4
+ ## v0.1.4
5
+
6
+ - Add scores and score_resting_hrs
7
+ - Add Readiness model spec
3
8
 
4
9
  ## v0.1.3
5
10
 
@@ -17,7 +17,7 @@ module Oura
17
17
  # "activity": [{"summary_date": "2016-10-11", ...}, {"summary_date": "2016-10-12", ...}, ...]
18
18
  # }
19
19
  # @return [Oura::Model::Activity]
20
- def activity(start_date:, end_date:)
20
+ def activity(start_date:, end_date: Time.current.to_date)
21
21
  sdate, edate = [start_date, end_date].map { |date| transform_date(date) }
22
22
  response_body = get(REQUEST_PATH, params: { start: sdate, end: edate }).body
23
23
  symbolized_json = JSON.parse(response_body).deep_symbolize_keys
@@ -32,7 +32,7 @@ module Oura
32
32
  # "readiness": [{"summary_date": "2016-10-11", ...}, {"summary_date": "2016-10-12", ...}, ...]
33
33
  # }
34
34
  # @return [Oura::Model::Readiness]
35
- def readiness(start_date:, end_date:)
35
+ def readiness(start_date:, end_date: Time.current.to_date)
36
36
  sdate, edate = [start_date, end_date].map { |date| transform_date(date) }
37
37
  response_body = get(REQUEST_PATH, params: { start: sdate, end: edate }).body
38
38
  symbolized_json = JSON.parse(response_body).deep_symbolize_keys
@@ -17,7 +17,7 @@ module Oura
17
17
  # "sleep": [{"summary_date": "2016-10-11", ...}, {"summary_date": "2016-10-12", ...}, ...]
18
18
  # }
19
19
  # @return [Oura::Model::SleepPeriod]
20
- def sleep_period(start_date:, end_date:)
20
+ def sleep_period(start_date:, end_date: Time.current.to_date)
21
21
  sdate, edate = [start_date, end_date].map { |date| transform_date(date) }
22
22
  response_body = get(REQUEST_PATH, params: { start: sdate, end: edate }).body
23
23
  symbolized_json = JSON.parse(response_body).deep_symbolize_keys
@@ -6,6 +6,39 @@ module Oura
6
6
  # Oura::Mode::Readiness is Readiness Model.
7
7
  class Readiness < ::Oura::Model::Base
8
8
  attr_reader :readiness
9
+
10
+ ATTRIBUTES = %i[
11
+ score_activity_balance
12
+ score_resting_hr
13
+ score
14
+ period_id
15
+ score_temperature
16
+ score_sleep_balance
17
+ summary_date
18
+ score_previous_day
19
+ score_previous_night
20
+ score_recovery_index
21
+ ].freeze
22
+
23
+ ATTRIBUTES.map { |k| k.to_s.pluralize }.each.with_index do |pluralized_name, index|
24
+ define_method pluralized_name do
25
+ readiness.map { |h| h[ATTRIBUTES[index]] }
26
+ end
27
+ end
28
+
29
+ def average_score
30
+ average_by_array(scores)
31
+ end
32
+
33
+ def average_resting_hr
34
+ average_by_array(score_resting_hrs)
35
+ end
36
+
37
+ private
38
+
39
+ def average_by_array(array)
40
+ array.sum.to_f / array.size
41
+ end
9
42
  end
10
43
  end
11
44
  end
data/lib/oura/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Oura
4
- VERSION = '0.1.3'
4
+ VERSION = '0.1.4'
5
5
  end
data/oura.gemspec CHANGED
@@ -26,7 +26,6 @@ Gem::Specification.new do |spec|
26
26
 
27
27
  spec.add_dependency 'oauth2'
28
28
  spec.add_development_dependency 'activesupport'
29
- spec.add_development_dependency 'bundler', '~> 1.17'
30
29
  spec.add_development_dependency 'codecov'
31
30
  spec.add_development_dependency 'danger'
32
31
  spec.add_development_dependency 'danger-junit'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oura
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryota Ikezawa
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-02-04 00:00:00.000000000 Z
11
+ date: 2019-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oauth2
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: bundler
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '1.17'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '1.17'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: codecov
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -317,8 +303,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
317
303
  - !ruby/object:Gem::Version
318
304
  version: '0'
319
305
  requirements: []
320
- rubyforge_project:
321
- rubygems_version: 2.7.6
306
+ rubygems_version: 3.0.3
322
307
  signing_key:
323
308
  specification_version: 4
324
309
  summary: unofficial API client of oura-cloud.