sof-cycle 0.1.5 → 0.1.7

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: b2a07b69c0b78ca93a453a9ff1ab0e7fb7afb489bcd95793b92aaa43b74b3625
4
- data.tar.gz: c8ef2c5af032e5a98f600677fabe41e117ec1470a00955b4254e6dfd87717b9b
3
+ metadata.gz: c3012f6707b4790074bd8d39619c93abbca8ffd333c4942365c1b995c321040a
4
+ data.tar.gz: a9b8032594afa34f6aada7bbd8709cf05898dfb68bdd4f45f3a7e64270853054
5
5
  SHA512:
6
- metadata.gz: '078492cab1d760a9db49da00326eab551bcf00486cbca9f8bbf026d192f398e24d9b156eaf222237936c0a86b9bdb06594daaefc724ffa9d7258eb89a71df6ad'
7
- data.tar.gz: ff0791da35ec67d02633b3200f44929f7627b6bc3d3f9414ec24570a1203f830c2142216f8d37d3e154ad0c157ec2b47f3054d633df40b0bff2e4e61cc13b782
6
+ metadata.gz: 97f6a123c55cc133347ee5cad99639f7105a19397b7a8bfeaad0f72ac9ef0da0748a51bc40a3976816f347e4075463bc18ee9184bfe6837308d2dcc438bd72dc
7
+ data.tar.gz: 6fa462d207af7d7fc7e659a5e586ad19d5cec3a6042814ba89254974b566054f27ee6dd2efbb661c2804deef174a99c6f3ae5e26e273d57edf7a0f0f0e8a2d4e
data/CHANGELOG.md CHANGED
@@ -5,14 +5,20 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
- ## [0.1.5] - 2024-09-02
8
+ ## [0.1.7] - 2025-06-09
9
+
10
+ ### Added
11
+
12
+ - `Cycle#considered_dates` to get the subset of `#covered_dates` that are
13
+ considered for the cycle's calculations.
9
14
 
10
15
  ### Fixed
11
16
 
12
- - `Cycle#last_completed` works for dormant cycles too
17
+ - `Cycles::Lookback.volume_to_delay_expiration` now computes correctly when the
18
+ `#considered_dates` is smaller than the `#covered_dates` of the cycle.
13
19
 
14
- ## [0.1.4] - 2024-09-02
20
+ ## [0.1.6] - 2024-09-04
15
21
 
16
22
  ### Added
17
23
 
18
- - `Cycle#last_completed` to return the last completion given the cycle and an array of dates
24
+ - `Cycle.extend_period(count)` to get a new cycle with the modified period count
@@ -0,0 +1 @@
1
+ 4a0a79b2c4566319f3a28a400b5c5e471a4d3e6acf979f02b38546cfab34c11d4dd1b1b5118eab0b5cbcab77ed54fb896dc81f4fa58afe41ae437ed79f44f235
@@ -2,6 +2,6 @@
2
2
 
3
3
  module SOF
4
4
  class Cycle
5
- VERSION = "0.1.5"
5
+ VERSION = "0.1.7"
6
6
  end
7
7
  end
data/lib/sof/cycle.rb CHANGED
@@ -165,6 +165,8 @@ module SOF
165
165
  # Return the most recent completion date from the supplied array of dates
166
166
  def last_completed(dates) = dates.compact.map(&:to_date).max
167
167
 
168
+ def extend_period(_ = nil) = self
169
+
168
170
  # From the supplied anchor date, are there enough in-window completions to
169
171
  # satisfy the cycle?
170
172
  #
@@ -173,6 +175,10 @@ module SOF
173
175
  covered_dates(completion_dates, anchor:).size >= volume
174
176
  end
175
177
 
178
+ def considered_dates(completion_dates, anchor: Date.current)
179
+ covered_dates(completion_dates, anchor:).max_by(volume) { _1 }
180
+ end
181
+
176
182
  def covered_dates(dates, anchor: Date.current)
177
183
  dates.select do |date|
178
184
  cover?(date, anchor:)
@@ -13,8 +13,12 @@ module SOF
13
13
  def to_s = "#{volume}x in the prior #{period_count} #{humanized_period}"
14
14
 
15
15
  def volume_to_delay_expiration(completion_dates, anchor:)
16
- oldest_relevant_completion = completion_dates.min
17
- [completion_dates.count(oldest_relevant_completion), volume].min
16
+ relevant_dates = considered_dates(completion_dates, anchor:)
17
+ return unless satisfied_by?(relevant_dates, anchor:)
18
+
19
+ # To move the expiration date, we need to displace each occurance of the
20
+ # oldest date within #considered_dates.
21
+ relevant_dates.count(relevant_dates.min)
18
22
  end
19
23
 
20
24
  # "Absent further completions, you go red on this date"
@@ -12,6 +12,14 @@ module SOF
12
12
 
13
13
  def to_s = "#{volume}x within #{date_range}"
14
14
 
15
+ def extend_period(count)
16
+ Cycle.for(
17
+ Parser.load(
18
+ parser.to_h.merge(period_count: period_count + count)
19
+ ).to_s
20
+ )
21
+ end
22
+
15
23
  def date_range
16
24
  return humanized_span unless active?
17
25
 
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sof-cycle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Gay
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-09-02 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: forwardable
@@ -38,7 +37,6 @@ dependencies:
38
37
  - - ">="
39
38
  - !ruby/object:Gem::Version
40
39
  version: '6.0'
41
- description:
42
40
  email:
43
41
  - jim@saturnflyer.com
44
42
  executables: []
@@ -53,6 +51,7 @@ files:
53
51
  - checksums/sof-cycle-0.1.0.gem.sha512
54
52
  - checksums/sof-cycle-0.1.1.gem.sha512
55
53
  - checksums/sof-cycle-0.1.2.gem.sha512
54
+ - checksums/sof-cycle-0.1.6.gem.sha512
56
55
  - lib/sof-cycle.rb
57
56
  - lib/sof/cycle.rb
58
57
  - lib/sof/cycle/version.rb
@@ -69,7 +68,6 @@ licenses: []
69
68
  metadata:
70
69
  homepage_uri: https://github.com/SOFware/sof-cycle
71
70
  changelog_uri: https://github.com/SOFware/sof-cycle/blob/main/CHANGELOG.md
72
- post_install_message:
73
71
  rdoc_options: []
74
72
  require_paths:
75
73
  - lib
@@ -84,8 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
82
  - !ruby/object:Gem::Version
85
83
  version: '0'
86
84
  requirements: []
87
- rubygems_version: 3.5.11
88
- signing_key:
85
+ rubygems_version: 3.6.7
89
86
  specification_version: 4
90
87
  summary: Parse and interact with SOF cycle notation.
91
88
  test_files: []