dexcom 0.2.2 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9d280d55dcaebe7390a8c9abfa96f778d011030120b485bc63b6043a8095f179
4
- data.tar.gz: 839a8c2d15504a7d6de4853285d5b8b0f01de3bb6c453f917d964930ea59765e
3
+ metadata.gz: 318075e2340168e9bdb2f21b974cfd3a434c0726396223938a614fb790d75d6e
4
+ data.tar.gz: d24bb4a72533377a0964616efca955920d10817e315be455f544efdec49487cc
5
5
  SHA512:
6
- metadata.gz: 298d575a9935df69443b1d420a719cb2188bfa1c26ab7eff85c963f05ad7877e346f139289a641eab3d5aaf0f7c591edd92947085d8e4110ad548a0eb21fc115
7
- data.tar.gz: a716d140828a40330c9c9f80f65380b66458c2c6fe9d2307e9433b973ab68e490b519f9ac7f593897f5b445fc10aed97878740eb9db32e09ab36dbf6e7dca2da
6
+ metadata.gz: 9ee214af2ee0be1ec1c2447a6834141d7ddcf1d0c49cd93555c8b40d7436dfeca725146da8fe58a3cb768c1c63e5bc9ceb133894a89c98337c62cdab95c140cc
7
+ data.tar.gz: a59ba85426354dce6fbd3d100f69bc53e2570a136f35b39c1ea9bd03791185a5d0aafdbc53ef97533ba4d9466ab2ccde6c9fe2246a9c3aefe4e2e1254bd86999
data/Gemfile.lock CHANGED
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dexcom (0.2.1)
4
+ dexcom (0.3.0)
5
+ activesupport
5
6
  httparty
6
7
 
7
8
  GEM
@@ -53,6 +54,7 @@ GEM
53
54
  rspec-support (3.9.3)
54
55
  safe_yaml (1.0.5)
55
56
  thread_safe (0.3.6)
57
+ timecop (0.9.1)
56
58
  tzinfo (1.2.5)
57
59
  thread_safe (~> 0.1)
58
60
  webmock (3.8.3)
@@ -70,6 +72,7 @@ DEPENDENCIES
70
72
  factory_bot
71
73
  pry
72
74
  rspec
75
+ timecop
73
76
  webmock
74
77
 
75
78
  BUNDLED WITH
data/README.md CHANGED
@@ -1,2 +1,108 @@
1
1
  # dexcom-ruby
2
- Gem to interact with Dexcom Share API, enabling real-time retrieval of glucose data
2
+ [Imgur](https://i.imgur.com/HZdC1fH.png?1)
3
+ [![Gem Version](https://badge.fury.io/rb/dexcom.svg)](https://rubygems.org/gems/dexcom) [![AlexGascon](https://circleci.com/gh/AlexGascon/dexcom-ruby.svg?style=svg)](https://app.circleci.com/pipelines/github/AlexGascon/dexcom-ruby)
4
+
5
+ ## Introduction
6
+ `dexcom-ruby` allows you to easily interact with Dexcom Share APIs, enabling real-time retrieval of glucose data on your application
7
+
8
+ ## Install
9
+ You can install the gem via Rubygems:
10
+
11
+ ```
12
+ gem install dexcom
13
+ ```
14
+
15
+ ## Configuration
16
+ The gem can be easily configured via the `configure` method:
17
+
18
+ ```ruby
19
+ Dexcom.configure do |config|
20
+ config.username = 'my_username'
21
+ config.password = 'my_password'
22
+ config.outside_usa = true
23
+ end
24
+ ```
25
+
26
+ There are three available parameters to configure:
27
+ * `username`: The username of your Dexcom account
28
+ * `password`: The password of your Dexcom account
29
+ * `outside_usa`: Boolean indicating if the account that you want to access is not an American one
30
+
31
+ ## Usage
32
+ You can retrieve the last blood glucose reading from Dexcom using the method `Dexcom::BloodGlucose.last`
33
+
34
+ ```
35
+ bg = Dexcom::BloodGlucose.last
36
+ => #<Dexcom::BloodGlucose:0x0000555c19959000
37
+ @timestamp=Sun, 21 Jun 2020 11:23:05 +0000,
38
+ @trend=4,
39
+ @value=147>
40
+ ```
41
+
42
+ It will return a `Dexcom::BloodGlucose` object, which has the following fields:
43
+
44
+ * `value`: The blood glucose value in mg/dL
45
+ * `timestamp`: The instant when this reading was registered
46
+ * `trend`: Number representing the type of progression of the latest readings. You can get a human-readable version using `trend_description` and its symbol using `trend_symbol`.
47
+ * `mg_dl`: Alias to `value`
48
+ * `mmol`: Blood glucose value in mmol/L
49
+
50
+ ```
51
+ bg.timestamp
52
+ => Sun, 21 Jun 2020 11:23:05 +0000
53
+
54
+ bg.trend_description
55
+ => "Steady"
56
+
57
+ bg.trend_symbol
58
+ => "→"
59
+
60
+ bg.mg_dl
61
+ => 147
62
+
63
+ bg.mmol
64
+ => 8.2
65
+ ```
66
+
67
+ Additionally, if you prefer to retrieve a range of values instead of only the last one, you can use the `.get_last` method. You can specify either the number of values that you want or how many minutes in the past you want to search for
68
+
69
+ ```
70
+ Dexcom::BloodGlucose.get_last(max_count: 5)
71
+ => [#<Dexcom::BloodGlucose:0x0000555c19d7b7c8
72
+ @timestamp=Sun, 21 Jun 2020 11:23:05 +0000,
73
+ @trend=4,
74
+ @value=147>,
75
+ #<Dexcom::BloodGlucose:0x0000555c19d7b660
76
+ @timestamp=Sun, 21 Jun 2020 11:18:06 +0000,
77
+ @trend=4,
78
+ @value=148>,
79
+ #<Dexcom::BloodGlucose:0x0000555c19d7b4d0
80
+ @timestamp=Sun, 21 Jun 2020 11:13:06 +0000,
81
+ @trend=4,
82
+ @value=147>,
83
+ #<Dexcom::BloodGlucose:0x0000555c19d7b390
84
+ @timestamp=Sun, 21 Jun 2020 11:08:06 +0000,
85
+ @trend=4,
86
+ @value=148>,
87
+ #<Dexcom::BloodGlucose:0x0000555c19d7b138
88
+ @timestamp=Sun, 21 Jun 2020 11:03:06 +0000,
89
+ @trend=4,
90
+ @value=149>]
91
+
92
+
93
+ Dexcom::BloodGluocse.get_last(minutes: 15)
94
+ => [#<Dexcom::BloodGlucose:0x0000555c19d7b7c8
95
+ @timestamp=Sun, 21 Jun 2020 11:23:05 +0000,
96
+ @trend=4,
97
+ @value=147>,
98
+ #<Dexcom::BloodGlucose:0x0000555c19d7b660
99
+ @timestamp=Sun, 21 Jun 2020 11:18:06 +0000,
100
+ @trend=4,
101
+ @value=148>,
102
+ #<Dexcom::BloodGlucose:0x0000555c19d7b4d0
103
+ @timestamp=Sun, 21 Jun 2020 11:13:06 +0000,
104
+ @trend=4,
105
+ @value=147>]
106
+ ```
107
+
108
+ **NOTE:** You can retrieve data up to 1440 minutes (24 hours) in the past. Even if `minutes` is greater than 1440, or if you specify a `max_count` greater than the number of blood glucose values registered in the last 24 hours, you will only get data for that period
data/dexcom.gemspec CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ['lib']
23
23
 
24
+ spec.add_dependency 'activesupport'
24
25
  spec.add_dependency 'httparty'
25
26
 
26
27
  spec.add_development_dependency 'bundler'
@@ -28,5 +29,6 @@ Gem::Specification.new do |spec|
28
29
  spec.add_development_dependency 'factory_bot'
29
30
  spec.add_development_dependency 'pry'
30
31
  spec.add_development_dependency 'rspec'
32
+ spec.add_development_dependency 'timecop'
31
33
  spec.add_development_dependency 'webmock'
32
34
  end
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal
2
2
 
3
+ require 'active_support'
4
+ require 'active_support/core_ext'
5
+
3
6
  module Dexcom
4
7
  module BloodGlucoseUtils
5
8
  module ClassMethods
@@ -14,19 +17,23 @@ module Dexcom
14
17
  number_of_values = calculate_number_of_values(max_count, minutes)
15
18
 
16
19
  response = make_api_request(number_of_values)
17
- process_api_response(response)
20
+ blood_glucose_values = process_api_response(response)
21
+
22
+ if minutes.present?
23
+ blood_glucose_values.select! { |bg| bg.timestamp >= minutes.minutes.ago }
24
+ end
25
+
26
+ blood_glucose_values
18
27
  end
19
28
 
20
29
  private
21
30
 
22
31
  def calculate_number_of_values(max_count, minutes)
23
- if minutes.nil?
24
- max_count || DEFAULT_NUMBER_OF_VALUES
25
- elsif max_count.nil?
26
- minutes / MINUTES_PER_DATAPOINT
27
- else
28
- [max_count, minutes / MINUTES_PER_DATAPOINT].min
29
- end
32
+ return DEFAULT_NUMBER_OF_VALUES if (minutes.nil? && max_count.nil?)
33
+ return max_count if minutes.nil?
34
+ return (minutes / MINUTES_PER_DATAPOINT) if max_count.nil?
35
+
36
+ [max_count, minutes / MINUTES_PER_DATAPOINT].min
30
37
  end
31
38
  end
32
39
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dexcom
4
- VERSION = '0.2.2'
4
+ VERSION = '0.3.0'
5
5
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dexcom
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Gascon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-13 00:00:00.000000000 Z
11
+ date: 2021-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
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'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: httparty
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +108,20 @@ dependencies:
94
108
  - - ">="
95
109
  - !ruby/object:Gem::Version
96
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: timecop
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
97
125
  - !ruby/object:Gem::Dependency
98
126
  name: webmock
99
127
  requirement: !ruby/object:Gem::Requirement
@@ -149,7 +177,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
177
  - !ruby/object:Gem::Version
150
178
  version: '0'
151
179
  requirements: []
152
- rubygems_version: 3.0.3
180
+ rubyforge_project:
181
+ rubygems_version: 2.7.6
153
182
  signing_key:
154
183
  specification_version: 4
155
184
  summary: Gem to interact with Dexcom Share API