Skip to content

Commit

Permalink
Add Cycle#notation_extended_by(count)
Browse files Browse the repository at this point in the history
For most Cycle types this just returns the original notation
  • Loading branch information
jdowd committed Sep 4, 2024
1 parent 229405c commit 6966074
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/sof/cycle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ def ==(other) = to_h == other.to_h
# Return the most recent completion date from the supplied array of dates
def last_completed(dates) = dates.compact.map(&:to_date).max

def notation_extended_by(_ = nil) = notation

# From the supplied anchor date, are there enough in-window completions to
# satisfy the cycle?
#
Expand Down
1 change: 1 addition & 0 deletions spec/sof/cycles/calendar_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ module SOF
it_behaves_like "it computes #final_date(given)",
given: "1971-01-01", returns: "1971-12-31".to_date
it_behaves_like "last_completed is", :recent_date
it_behaves_like "it cannot be extended"

describe "#recurring?" do
it "repeats" do
Expand Down
1 change: 1 addition & 0 deletions spec/sof/cycles/end_of_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ module SOF
it_behaves_like "#as_json returns the notation"
it_behaves_like "it computes #final_date(given)",
given: nil, returns: ("2020-01-01".to_date + 17.months).end_of_month
it_behaves_like "it cannot be extended"

describe "#last_completed" do
context "with an activated cycle" do
Expand Down
1 change: 1 addition & 0 deletions spec/sof/cycles/lookback_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ module SOF
it_behaves_like "it computes #final_date(given)",
given: "2003-03-08", returns: ("2003-03-08".to_date + 180.days)
it_behaves_like "last_completed is", :recent_date
it_behaves_like "it cannot be extended"

describe "#recurring?" do
it "repeats" do
Expand Down
6 changes: 6 additions & 0 deletions spec/sof/cycles/shared_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,9 @@
expect(subject.last_completed(dates)).to eq(expected)
end
end

shared_examples_for "it cannot be extended" do
it "returns its original notation" do
expect(subject.notation_extended_by(999)).to eq(subject.notation)
end
end
1 change: 1 addition & 0 deletions spec/sof/cycles/volume_only_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ module SOF
it_behaves_like "it computes #final_date(given)",
given: "2003-03-08", returns: nil
it_behaves_like "last_completed is", :recent_date
it_behaves_like "it cannot be extended"

describe "#recurring?" do
it "does not repeat" do
Expand Down

0 comments on commit 6966074

Please sign in to comment.