timeboss 1.0.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/gem-push.yml +31 -0
- data/.github/workflows/ruby.yml +35 -0
- data/.travis.yml +3 -2
- data/Gemfile +2 -1
- data/README.md +17 -2
- data/Rakefile +3 -1
- data/bin/tbsh +2 -2
- data/lib/tasks/calendars.rake +5 -5
- data/lib/tasks/timeboss.rake +2 -2
- data/lib/timeboss/calendar/day.rb +3 -2
- data/lib/timeboss/calendar/half.rb +2 -1
- data/lib/timeboss/calendar/month.rb +2 -1
- data/lib/timeboss/calendar/parser.rb +9 -8
- data/lib/timeboss/calendar/period.rb +9 -6
- data/lib/timeboss/calendar/quarter.rb +2 -1
- data/lib/timeboss/calendar/support/formatter.rb +5 -4
- data/lib/timeboss/calendar/support/has_fiscal_weeks.rb +17 -0
- data/lib/timeboss/calendar/support/has_iso_weeks.rb +30 -0
- data/lib/timeboss/calendar/support/month_basis.rb +1 -1
- data/lib/timeboss/calendar/support/monthly_unit.rb +8 -8
- data/lib/timeboss/calendar/support/navigable.rb +2 -1
- data/lib/timeboss/calendar/support/shiftable.rb +12 -11
- data/lib/timeboss/calendar/support/translatable.rb +3 -2
- data/lib/timeboss/calendar/support/unit.rb +20 -13
- data/lib/timeboss/calendar/waypoints/absolute.rb +4 -3
- data/lib/timeboss/calendar/waypoints/relative.rb +14 -13
- data/lib/timeboss/calendar/week.rb +3 -2
- data/lib/timeboss/calendar/year.rb +2 -1
- data/lib/timeboss/calendar.rb +8 -7
- data/lib/timeboss/calendars/broadcast.rb +10 -7
- data/lib/timeboss/calendars/gregorian.rb +4 -5
- data/lib/timeboss/calendars.rb +3 -2
- data/lib/timeboss/version.rb +2 -1
- data/lib/timeboss.rb +2 -0
- data/spec/{calendar → lib/timeboss/calendar}/day_spec.rb +14 -14
- data/spec/{calendar → lib/timeboss/calendar}/quarter_spec.rb +9 -9
- data/spec/lib/timeboss/calendar/support/monthly_unit_spec.rb +91 -0
- data/spec/{calendar → lib/timeboss/calendar}/support/unit_spec.rb +23 -22
- data/spec/{calendar → lib/timeboss/calendar}/week_spec.rb +20 -20
- data/spec/lib/timeboss/calendars/broadcast_spec.rb +796 -0
- data/spec/lib/timeboss/calendars/gregorian_spec.rb +793 -0
- data/spec/{calendars_spec.rb → lib/timeboss/calendars_spec.rb} +19 -19
- data/spec/spec_helper.rb +2 -2
- data/timeboss.gemspec +16 -14
- metadata +51 -20
- data/lib/timeboss/support/shellable.rb +0 -17
- data/spec/calendar/support/monthly_unit_spec.rb +0 -85
- data/spec/calendars/broadcast_spec.rb +0 -796
- data/spec/calendars/gregorian_spec.rb +0 -684
@@ -2,8 +2,8 @@ module TimeBoss
|
|
2
2
|
class Calendar
|
3
3
|
describe Week do
|
4
4
|
let(:calendar) { instance_double(TimeBoss::Calendar, supports_weeks?: true) }
|
5
|
-
let(:start_date) { Date.parse(
|
6
|
-
let(:end_date) { Date.parse(
|
5
|
+
let(:start_date) { Date.parse("2048-04-06") }
|
6
|
+
let(:end_date) { Date.parse("2048-04-12") }
|
7
7
|
let(:subject) { described_class.new(calendar, start_date, end_date) }
|
8
8
|
|
9
9
|
it "doesn't even exist if its calendar doesn't support weeks" do
|
@@ -11,65 +11,65 @@ module TimeBoss
|
|
11
11
|
expect { subject }.to raise_error TimeBoss::Calendar::Support::Unit::UnsupportedUnitError
|
12
12
|
end
|
13
13
|
|
14
|
-
it
|
14
|
+
it "knows its stuff" do
|
15
15
|
expect(subject.start_date).to eq start_date
|
16
16
|
expect(subject.end_date).to eq end_date
|
17
17
|
expect(subject.to_range).to eq start_date..end_date
|
18
18
|
end
|
19
19
|
|
20
|
-
it
|
20
|
+
it "knows its title" do
|
21
21
|
expect(subject.title).to eq "Week of April 6, 2048"
|
22
22
|
end
|
23
23
|
|
24
|
-
describe
|
25
|
-
it
|
24
|
+
describe "#current?" do
|
25
|
+
it "knows when it is" do
|
26
26
|
allow(Date).to receive(:today).and_return start_date
|
27
27
|
expect(subject).to be_current
|
28
28
|
end
|
29
29
|
|
30
|
-
it
|
30
|
+
it "knows when it is not" do
|
31
31
|
expect(subject).not_to be_current
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
context
|
35
|
+
context "navigation" do
|
36
36
|
let(:calendar) { TimeBoss::Calendars::Broadcast.new }
|
37
37
|
|
38
|
-
describe
|
39
|
-
it
|
38
|
+
describe "#previous" do
|
39
|
+
it "can back up simply" do
|
40
40
|
result = subject.previous
|
41
41
|
expect(result).to be_a described_class
|
42
42
|
expect(result.to_s).to eq "2048W14: 2048-03-30 thru 2048-04-05"
|
43
43
|
end
|
44
44
|
|
45
|
-
it
|
46
|
-
result = described_class.new(calendar, Date.parse(
|
45
|
+
it "can wrap to the previous 52-week year" do
|
46
|
+
result = described_class.new(calendar, Date.parse("2021-12-27"), Date.parse("2022-01-02")).previous
|
47
47
|
expect(result).to be_a described_class
|
48
48
|
expect(result.to_s).to eq "2021W52: 2021-12-20 thru 2021-12-26"
|
49
49
|
end
|
50
50
|
|
51
|
-
it
|
52
|
-
result = described_class.new(calendar, Date.parse(
|
51
|
+
it "can wrap to the previous 53-week year" do
|
52
|
+
result = described_class.new(calendar, Date.parse("2024-01-01"), Date.parse("2024-01-07")).previous
|
53
53
|
expect(result).to be_a described_class
|
54
54
|
expect(result.to_s).to eq "2023W53: 2023-12-25 thru 2023-12-31"
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
-
describe
|
59
|
-
it
|
58
|
+
describe "#next" do
|
59
|
+
it "can move forward simply" do
|
60
60
|
result = subject.next
|
61
61
|
expect(result).to be_a described_class
|
62
62
|
expect(result.to_s).to eq "2048W16: 2048-04-13 thru 2048-04-19"
|
63
63
|
end
|
64
64
|
|
65
|
-
it
|
66
|
-
result = described_class.new(calendar, Date.parse(
|
65
|
+
it "can wrap from week 52 to the next year" do
|
66
|
+
result = described_class.new(calendar, Date.parse("2021-12-20"), Date.parse("2021-12-26")).next
|
67
67
|
expect(result).to be_a described_class
|
68
68
|
expect(result.to_s).to eq "2022W1: 2021-12-27 thru 2022-01-02"
|
69
69
|
end
|
70
70
|
|
71
|
-
it
|
72
|
-
result = described_class.new(calendar, Date.parse(
|
71
|
+
it "can wrap from week 53 to the next year" do
|
72
|
+
result = described_class.new(calendar, Date.parse("2023-12-25"), Date.parse("2023-12-31")).next
|
73
73
|
expect(result).to be_a described_class
|
74
74
|
expect(result.to_s).to eq "2024W1: 2024-01-01 thru 2024-01-07"
|
75
75
|
end
|