sof-cycle 0.1.10 → 0.1.12

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: efa206d4535b7a45567f643a71738506a7c5a3f318180cba1d576a618b178877
4
- data.tar.gz: 3946a1dbfc81ef89d33db3ca0bd1df0fd74dc86cc6aef967055dbdac755afd27
3
+ metadata.gz: 24c5b52ab1efb27e840af6448d16f2d74074310909a00d6d8a9bd10d42466b83
4
+ data.tar.gz: a7507d727a8c7d87b34a6cabeccd49abaabb9ae29374bed6c9eff70a800d9c9b
5
5
  SHA512:
6
- metadata.gz: 697ee468ec9ed5a57f2b1e33fa1ae38f865fac62082edca445f263b8862d368017a5ca42667c12bfa45c05853790dcc3163e7577f13ca60c0d8981085cebf4e1
7
- data.tar.gz: c20956003342ba14086a563430d04370872eff64eec0e63b9c7c153f892fe6973a6c805d95bf31f4ae05e12d566a33709858cb3dd35fc996c54c36851c7ab10e
6
+ metadata.gz: deb2c0b296fef6fdc65fb0db0e7d92934de2c8a402f96757ac357446e87c2dc4d5cd880e6a8a210aed4bc794ff1977bba1397fb2de96aadd909879566851e783
7
+ data.tar.gz: e238e4937718f34f644acf024ea4aae39742eee04a9b6d0b75a10df2306219ab8c3ac13abf6d7760e401d9554882f467518348ba0744e1eb51cf0fd2741452b9
data/CHANGELOG.md CHANGED
@@ -5,10 +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.10] - 2025-09-04
8
+ ## [0.1.12] - 2025-09-05
9
9
 
10
- ## [0.1.9] - 2025-09-04
10
+ ### Added
11
+
12
+ - Missing code coverage and updated EndOf to properly handle dormant cycles.
13
+
14
+ ## [0.1.11] - 2025-09-05
11
15
 
12
16
  ### Changed
13
17
 
14
- - Make use of scoping for `Cycle.cycle_handlers` to prevent collisions with other Cycle classes.
18
+ - Use `time_span.notation` instead of `TimeSpan.notation` in `Cycle#notation`.
@@ -0,0 +1 @@
1
+ 1dd8e44d63d65dc2efc605dc2957fde47f7b9dfb7b91ddc7cca43bbc420b10366c26512eb940261381f54ad41d3a240dfa13abeaf8d52688c0ba1075b425ac9f
@@ -0,0 +1 @@
1
+ 3ce0dfe7d95a5cde507d7563ca9aa834457913dff9861d36547cff571fa9371be9fdeb60ec6892edb23b14945ab7a25f569d86cb023b67adfd3028a4570ac381
@@ -2,6 +2,6 @@
2
2
 
3
3
  module SOF
4
4
  class Cycle
5
- VERSION = "0.1.10"
5
+ VERSION = "0.1.12"
6
6
  end
7
7
  end
data/lib/sof/cycle.rb CHANGED
@@ -236,7 +236,7 @@ module SOF
236
236
  [
237
237
  "V#{volume}",
238
238
  self.class.notation_id,
239
- TimeSpan.notation(hash.slice(:period, :period_count)),
239
+ time_span.notation,
240
240
  hash.fetch(:from, nil)
241
241
  ].compact.join
242
242
  end
@@ -27,7 +27,7 @@ module SOF
27
27
  end
28
28
 
29
29
  def to_s
30
- return dormant_to_s if dormant?
30
+ return dormant_to_s if parser.dormant? || from_date.nil?
31
31
 
32
32
  "#{volume}x by #{final_date.to_fs(:american)}"
33
33
  end
@@ -45,12 +45,18 @@ module SOF
45
45
  # Cycle.for("V1E18MF2020-01-09")
46
46
  # .expiration_of(anchor: "2020-06-04".to_date)
47
47
  # # => #<Date: 2021-06-30>
48
- def expiration_of(_ = nil, anchor: nil) = final_date
48
+ def expiration_of(_ = nil, anchor: nil)
49
+ return nil if parser.dormant? || from_date.nil?
50
+ final_date
51
+ end
49
52
 
50
53
  # Is the supplied anchor date prior to the final date?
51
54
  #
52
55
  # @return [Boolean] true if the cycle is satisfied, false otherwise
53
- def satisfied_by?(_ = nil, anchor: Date.current) = anchor <= final_date
56
+ def satisfied_by?(_ = nil, anchor: Date.current)
57
+ return false if parser.dormant? || from_date.nil?
58
+ anchor <= final_date
59
+ end
54
60
 
55
61
  # Calculates the final date of the cycle
56
62
  #
@@ -61,11 +67,14 @@ module SOF
61
67
  # @example
62
68
  # Cycle.for("V1E18MF2020-01-09").final_date
63
69
  # # => #<Date: 2021-06-30>
64
- def final_date(_ = nil) = time_span
65
- .end_date(start_date - 1.send(period))
66
- .end_of_month
70
+ def final_date(_ = nil)
71
+ return nil if parser.dormant? || from_date.nil?
72
+ time_span
73
+ .end_date(start_date - 1.send(period))
74
+ .end_of_month
75
+ end
67
76
 
68
- def start_date(_ = nil) = from_date.to_date
77
+ def start_date(_ = nil) = from_date&.to_date
69
78
 
70
79
  private
71
80
 
@@ -12,7 +12,7 @@ module SOF
12
12
  def handles?(sym) = sym.nil? || sym.to_s == "volume_only"
13
13
 
14
14
  def validate_period(period)
15
- raise InvalidPeriod, <<~ERR.squish unless period.nil?
15
+ raise Cycle::InvalidPeriod, <<~ERR.squish unless period.nil?
16
16
  Invalid period value of '#{period}' provided. Valid periods are:
17
17
  #{valid_periods.join(", ")}
18
18
  ERR
data/lib/sof/time_span.rb CHANGED
@@ -49,6 +49,10 @@ module SOF
49
49
  end
50
50
  end
51
51
 
52
+ def notation
53
+ [period_count, code].join
54
+ end
55
+
52
56
  # Class used to calculate the windows of time so that
53
57
  # a TimeSpan object will know the correct end of year,
54
58
  # quarter, etc.
@@ -63,7 +67,7 @@ module SOF
63
67
  end
64
68
 
65
69
  def for_notation(notation)
66
- types.find do |klass|
70
+ DatePeriod.types.find do |klass|
67
71
  klass.code == notation.to_s.upcase
68
72
  end
69
73
  end
@@ -189,7 +193,7 @@ module SOF
189
193
  end
190
194
  attr_reader :window
191
195
 
192
- delegate [:end_date, :begin_date] => :window
196
+ delegate [:end_date, :begin_date, :code] => :window
193
197
 
194
198
  def end_date_of_period(date)
195
199
  window.end_of_period(date)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sof-cycle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Gay
@@ -53,6 +53,8 @@ files:
53
53
  - Rakefile
54
54
  - checksums/sof-cycle-0.1.0.gem.sha512
55
55
  - checksums/sof-cycle-0.1.1.gem.sha512
56
+ - checksums/sof-cycle-0.1.10.gem.sha512
57
+ - checksums/sof-cycle-0.1.11.gem.sha512
56
58
  - checksums/sof-cycle-0.1.2.gem.sha512
57
59
  - checksums/sof-cycle-0.1.6.gem.sha512
58
60
  - checksums/sof-cycle-0.1.7.gem.sha512