sugarsense-units 0.1.0 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dcc1213237aae5f99e43cf1f88dc91a40e62e8e285227223961022d23863c13b
4
- data.tar.gz: 5ef263aaa45acd74d33487b2a7657e702c566e4b6f208df7464953bf8426aa27
3
+ metadata.gz: '028fede44078011e763d7918cc5c6b8fa09526cbe3957e19e7385b29aa70c208'
4
+ data.tar.gz: 88f258d06d5eef997b667969ffa94afbf0c30c052c398d10cdf552217edf0aac
5
5
  SHA512:
6
- metadata.gz: 6d7833ba0a82dc6e8a2761807dae113954a856edf8855240176e0b9ae436c7577602a81d1bbdb6fe8652ebf9796718797f8f2b51cea3a84f0c9c9c6ba2d0fbf0
7
- data.tar.gz: 7bbe2fb05bbf457f2a62d902235e5422ff0188c6dd9b9d64991b71564b0105bf8a2d066753e3db0ff8834cd5b05106d0596bcfeb7c9b65924bddc88dea830016
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
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module SugarSense
4
4
  module Units
5
- VERSION = "0.1.0"
5
+ VERSION = "0.2.0"
6
6
  end
7
7
  end
@@ -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.1.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-01 00:00:00.000000000 Z
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
@@ -30,6 +30,8 @@ licenses:
30
30
  metadata:
31
31
  homepage_uri: https://sugarsense.io
32
32
  documentation_uri: https://www.rubydoc.info/gems/sugarsense-units
33
+ source_code_uri: https://github.com/sugarsense/sugarsense-oss/tree/main/sugarsense-units
34
+ bug_tracker_uri: https://github.com/sugarsense/sugarsense-oss/issues
33
35
  rubygems_mfa_required: 'true'
34
36
  post_install_message:
35
37
  rdoc_options: []