dexby 0.0.1 → 0.1.0

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
  SHA1:
3
- metadata.gz: 8153c9251fcba95236518886b09959b1bf2d93d1
4
- data.tar.gz: 0c7d22c5eab90e356e7e1db04f1645f2abbbabc9
3
+ metadata.gz: b222557ba64f49c1a1a498f5e1b7b2c1b872e2a4
4
+ data.tar.gz: 9a87fc562ddb21efbc79baa99fe1f2a9a3dd5943
5
5
  SHA512:
6
- metadata.gz: c6ccd65924e2e1972d69834ce2bf0f0aa38ef4c2f9d2001f9518b0b8de3315b42c55856d1c5e15c0abacc13351271d800a902e8b68604a081eda74d663f9d619
7
- data.tar.gz: 1e60a24c031814d7e8a64b6fdd60293742444517a9bb0eb491d4d949714c0ad5733dcb066f784cb66960c7bcdca471a6b689e4cd4494ba12e34c6806f946e7d7
6
+ metadata.gz: 310d4d0e734c35833adab31d6216c4583597c606b3d1ff82058475bf6448f8331e82f8f81b83bddd81436a427e0cc428571e93bfc5f9290c1f78c00ed0ae0f4b
7
+ data.tar.gz: 9915e46f839d4502da31ebba8151122e88a84f2ebd8c2104cceed27fedfe3f1abda438f32bab70be3e2e65c1452d925728caf45294d0608e1092790ebf6abeac
data/README.md CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
  [![Build Status](https://travis-ci.org/jcantara/dexby.svg?branch=master)](https://travis-ci.org/jcantara/dexby)
4
4
 
5
- Dexcom API wrapper for Ruby
5
+ Dexcom API wrapper for Ruby. Supply your dexcom username and password and get your real-time blood-glucose
6
+ data from Dexcom for your own use outside of the phone apps or website. Useful for historic data archival and
7
+ analysis; dashboards; etc.
6
8
 
7
9
  Just so this is said right off: this software should NEVER be relied upon for medical use.
8
10
  It is a toy project I am using to compile blood-glucode information for my own uses.
@@ -16,7 +18,13 @@ with Dexcom in any way and do not represent them, nor does this library.
16
18
 
17
19
  With that out of the way, we can get to the fun stuff:
18
20
 
19
- ## Installation
21
+ ## Getting Started
22
+
23
+ ### Prerequisites
24
+
25
+ Have a ruby installed on your system, we recommend RVM or RBEnv. Tests are run on MRI >2.2 and latest jruby, but should run on most rubies.
26
+
27
+ ### Installation
20
28
 
21
29
  Add this line to your application's Gemfile:
22
30
 
@@ -30,9 +38,26 @@ Or install it yourself as:
30
38
 
31
39
  $ gem install dexby
32
40
 
33
- ## Usage
41
+ ### Usage
42
+
43
+ "#read" method takes optional `minutes` and `count` arguments for number of minutes backward in time to ask the API for, and maximum number
44
+ of records to return
45
+
46
+ ```ruby
47
+ require 'dexby'
48
+
49
+ dex = Dexby.new('YourDexcomUsername','dexcomPassword12345')
50
+
51
+ dex.read
52
+
53
+ => [{:trend=>:steady, :date=>#<DateTime: 2017-08-01T19:20:09-04:00 ((2457967j,84009s,920284537n),-14400s,2299161j)>, :value=>105}]
54
+ ```
55
+
56
+ ## Running tests
57
+
58
+ Default rake task will run rspec tests:
34
59
 
35
- TODO: Write usage instructions here
60
+ $ bundle exec rake
36
61
 
37
62
  ## Contributing
38
63
 
@@ -28,7 +28,7 @@ class Dexby::Connection
28
28
  [response.body.tr('"',''), response.code]
29
29
  end
30
30
 
31
- def self.read(session_id, minutes=1440, count=1)
31
+ def self.read(session_id, minutes, count)
32
32
  response = self.post(READ_ENDPOINT, query: read_query(session_id, minutes, count))
33
33
  [response.parsed_response, response.code]
34
34
  end
@@ -18,26 +18,30 @@ class Dexby::Reader
18
18
  @parser_class
19
19
  end
20
20
 
21
- def read
21
+ def read(minutes=1440, count=1)
22
22
  ensure_session_id
23
- result = session_connection_read
23
+ result = session_connection_read(minutes, count)
24
24
  if result[1] != 200
25
25
  raise ::StandardError
26
26
  end
27
27
  parser.parse_all(result[0])
28
28
  end
29
29
 
30
- def session_connection_read
31
- result = connection.read(@session_id)
30
+ def session_connection_read(minutes, count)
31
+ result = read_connection(minutes, count)
32
32
  if result[1] == 401 # expired session_id
33
- result = get_session_reread
33
+ result = get_session_reread(minutes, count)
34
34
  end
35
35
  return result
36
36
  end
37
37
 
38
- def get_session_reread
38
+ def get_session_reread(minutes, count)
39
39
  get_session_id
40
- connection.read(@session_id)
40
+ read_connection(minutes, count)
41
+ end
42
+
43
+ def read_connection(minutes, count)
44
+ connection.read(@session_id, minutes, count)
41
45
  end
42
46
 
43
47
  def ensure_session_id
@@ -1,3 +1,3 @@
1
1
  module Dexby
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -55,6 +55,20 @@ RSpec.describe Dexby::Reader do
55
55
  end
56
56
 
57
57
  describe "#read" do
58
+ context "arguments" do
59
+ before(:example) do
60
+ allow(fake_connection_class).to receive(:login).and_return(['banana', 200])
61
+ allow(fake_parser_class).to receive(:parse_all).and_return([])
62
+ end
63
+ it "accepts optional minutes and count arguments" do
64
+ expect(fake_connection_class).to receive(:read).with('banana', 23,24).and_return([[],200])
65
+ subject.read(23,24)
66
+ end
67
+ it "has default minutes and count arguments" do
68
+ expect(fake_connection_class).to receive(:read).with('banana', 1440, 1).and_return([[],200])
69
+ subject.read
70
+ end
71
+ end
58
72
  context "without an existing session_id" do
59
73
  before(:example) do
60
74
  allow(fake_connection_class).to receive(:read).and_return([[],200])
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dexby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jesse Cantara
@@ -110,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
110
  version: '0'
111
111
  requirements: []
112
112
  rubyforge_project:
113
- rubygems_version: 2.6.12
113
+ rubygems_version: 2.2.2
114
114
  signing_key:
115
115
  specification_version: 4
116
116
  summary: Ruby API wrapper for Dexcom data