sugarsense-units 0.1.1 → 0.2.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 +4 -4
- data/README.md +2 -0
- data/lib/sugarsense/units/version.rb +1 -1
- data/lib/sugarsense/units.rb +8 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '028fede44078011e763d7918cc5c6b8fa09526cbe3957e19e7385b29aa70c208'
|
|
4
|
+
data.tar.gz: 88f258d06d5eef997b667969ffa94afbf0c30c052c398d10cdf552217edf0aac
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f6b639672dde3c66072464a4dcb540b35920ed8865c9752c758bfc596eacf4a538caf371060f23ced3ae6176887d5b25a6792ec72b59e460bbacb7be715bac01
|
|
7
|
+
data.tar.gz: fc61831c444a7446b0edee72f64da4e8e963f591f87df12f21f21e07193978f047672463634a0c13f500387ef811b97a4a5b86b43c9b09b1e90fb71e47d57223
|
data/README.md
CHANGED
|
@@ -22,6 +22,7 @@ SugarSense::Units.format_glucose(120, :mmol) # => "6.7" (display form, 1 deci
|
|
|
22
22
|
SugarSense::Units.trend_arrow(2) # => "↘"
|
|
23
23
|
SugarSense::Units.classify_zone(65) # => :low
|
|
24
24
|
SugarSense::Units.gmi(154) # => 6.99 (approximates lab A1C, %)
|
|
25
|
+
SugarSense::Units.stale?(reading_time_ms) # => true once a reading is over 15 min old
|
|
25
26
|
|
|
26
27
|
SugarSense::Units.time_in_range([50, 60, 100, 150, 200, 300])
|
|
27
28
|
# => { total: 6,
|
|
@@ -37,6 +38,7 @@ These match the Sugar Sense production apps and backend:
|
|
|
37
38
|
- **Trend codes** are integers 1 to 5: `1 ↓ falling fast, 2 ↘ falling, 3 → steady, 4 ↗ rising, 5 ↑ rising fast` (the same scheme Dexcom, Libre and Nightscout data can be normalized to).
|
|
38
39
|
- **Zones**: `:very_low, :low, :in_range, :high, :very_high`, with boundaries inclusive on the out-of-range side (a value exactly at the low limit is `:low`, exactly at the high limit is `:high`).
|
|
39
40
|
- **Default thresholds** are `55 / 70 / 180 / 250` mg/dL (`DEFAULT_THRESHOLDS`), aligned with ADA guidance. Every method accepts custom thresholds.
|
|
41
|
+
- **Staleness**: a reading strictly older than 15 minutes counts as stale (`stale?`) and should be presented as "no current data", never as a live value.
|
|
40
42
|
|
|
41
43
|
## About Sugar Sense
|
|
42
44
|
|
data/lib/sugarsense/units.rb
CHANGED
|
@@ -87,6 +87,14 @@ module SugarSense
|
|
|
87
87
|
3.31 + 0.02392 * Float(mean_mgdl)
|
|
88
88
|
end
|
|
89
89
|
|
|
90
|
+
# A reading older than stale_minutes (default 15, the Sugar Sense rule) is
|
|
91
|
+
# stale and should be presented as "no current data". Strictly greater: a
|
|
92
|
+
# reading exactly 15 minutes old is NOT stale. Timestamps in epoch ms,
|
|
93
|
+
# mirroring the npm package's isStale.
|
|
94
|
+
def stale?(reading_time_ms, now_ms = Time.now.to_f * 1000, stale_minutes = 15)
|
|
95
|
+
Float(now_ms) - Float(reading_time_ms) > Float(stale_minutes) * 60 * 1000
|
|
96
|
+
end
|
|
97
|
+
|
|
90
98
|
def validate_thresholds(t)
|
|
91
99
|
unless t[:very_low] < t[:low] && t[:low] < t[:high] && t[:high] < t[:very_high]
|
|
92
100
|
raise ArgumentError, "thresholds must satisfy very_low < low < high < very_high"
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sugarsense-units
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sugar Sense
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-08-
|
|
11
|
+
date: 2026-08-31 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: 'Glucose helpers extracted from the Sugar Sense CGM monitoring app: mg/dL
|
|
14
14
|
to mmol/L conversion, trend arrow codes, glucose zone classification, time in range
|