sof-cycle 0.1.2 → 0.1.3

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: ea1c2c9a48bba72114b7681278cd467c57ee147f6f8b1ff176b4508de355920b
4
- data.tar.gz: 93a7560799df4730a5eaf2d14708b9a24199c0a95d2b01f1487ddc587b0846da
3
+ metadata.gz: e06eb27369a120ec1af76b5d96d6131e10dd7c5293a77a3a9f9a871f7782ccf9
4
+ data.tar.gz: f11c960b91981332057aba2bf3d5226d841b3e87b558f1b526f5e9a33fc7b011
5
5
  SHA512:
6
- metadata.gz: baf569f5fb7e0500b8a28915c8f19b86dc97ebee380301787182216d162fd02e659645345d369440959ebde737b59bb8ddd4372dae0bf014a9e3b448e8455e03
7
- data.tar.gz: 84756e0428c56a7f6dd72e5dc7aa545a587bbffd49479a436e4f8bee2d60ec3496e128f713a36b0169799ff908e0690e4518b147e750eaa0fb662681f0e036a0
6
+ metadata.gz: '0808c221b655153d9bb4ae49cbf004586e320bc83f445a493b8dce07d0c15ab6c4c4b6675f1a7ff0f5be0698cd6d2b3961ee9cf0cfebfdd8173c812dc9c672ad'
7
+ data.tar.gz: 551deeaedd7f8a54667af773685e46d19d24b43a49a4f1578ac04e2482038f21ae4ac20a17a0adc99d91189f5a7966712e9b271eb45c14d46baa6b1dba8e568c
data/CHANGELOG.md CHANGED
@@ -5,18 +5,14 @@ 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.2] - 2024-08-09
8
+ ## [0.1.3] - 2024-09-01
9
9
 
10
- ### Added
10
+ ### Fixed
11
11
 
12
- - `Cycle#recurring?` to reveal if a given Cycle is one-and-done or must be repeated.
12
+ - `Cycles::EndOf` to have the correct behavior
13
13
 
14
- ## [0.1.1] - 2024-08-09
14
+ ## [0.1.2] - 2024-08-09
15
15
 
16
16
  ### Added
17
17
 
18
- - Basic example in README.md
19
- - Add `Cycles::EndOf` to handle cycles that cover through the end of the nth
20
- subsequent period
21
- - Add predicate methods for each `Cycle` subclass. E.g. `#dormant?`, `#within?`, etc
22
- - Refactor into namespaces
18
+ - `Cycle#recurring?` to reveal if a given Cycle is one-and-done or must be repeated.
@@ -2,6 +2,6 @@
2
2
 
3
3
  module SOF
4
4
  class Cycle
5
- VERSION = "0.1.2"
5
+ VERSION = "0.1.3"
6
6
  end
7
7
  end
@@ -1,5 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Captures the logic for enforcing the EndOf cycle variant
4
+ # E.g. "V1E18MF2020-01-05" means:
5
+ # You're good until the end of the 17th subsequent month from 2020-01-05.
6
+ # Complete 1 by that date to reset the cycle.
7
+ #
8
+ # Some of the calculations are quite different from other cycles.
9
+ # Whereas other cycles look at completion dates to determine if the cycle is
10
+ # satisfied, this cycle checks whether the anchor date is prior to the final date.
3
11
  module SOF
4
12
  module Cycles
5
13
  class EndOf < Cycle
@@ -16,8 +24,34 @@ module SOF
16
24
  "#{volume}x by #{final_date.to_fs(:american)}"
17
25
  end
18
26
 
27
+ # Returns the expiration date for the cycle
28
+ #
29
+ # @param [nil] _ Unused parameter, maintained for compatibility
30
+ # @param anchor [nil] _ Unused parameter, maintained for compatibility
31
+ # @return [Date] The final date of the cycle
32
+ #
33
+ # @example
34
+ # Cycle.for("V1E18MF2020-01-09")
35
+ # .expiration_of(anchor: "2020-06-04".to_date)
36
+ # # => #<Date: 2021-06-30>
37
+ def expiration_of(_ = nil, anchor: nil) = final_date
38
+
39
+ # Is the supplied anchor date prior to the final date?
40
+ #
41
+ # @return [Boolean] true if the cycle is satisfied, false otherwise
42
+ def satisfied_by?(_ = nil, anchor: Date.current) = anchor <= final_date
43
+
44
+ # Calculates the final date of the cycle
45
+ #
46
+ # @param [nil] _ Unused parameter, maintained for compatibility
47
+ # @return [Date] The final date of the cycle calculated as the end of the
48
+ # nth subsequent period after the FROM date, where n = (period count - 1)
49
+ #
50
+ # @example
51
+ # Cycle.for("V1E18MF2020-01-09").final_date
52
+ # # => #<Date: 2021-06-30>
19
53
  def final_date(_ = nil) = time_span
20
- .end_date(start_date)
54
+ .end_date(start_date - 1.send(period))
21
55
  .end_of_month
22
56
 
23
57
  def start_date(_ = nil) = from_date.to_date
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sof-cycle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Gay
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-08-09 00:00:00.000000000 Z
11
+ date: 2024-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: forwardable
@@ -84,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
84
  - !ruby/object:Gem::Version
85
85
  version: '0'
86
86
  requirements: []
87
- rubygems_version: 3.4.13
87
+ rubygems_version: 3.5.11
88
88
  signing_key:
89
89
  specification_version: 4
90
90
  summary: Parse and interact with SOF cycle notation.