timeboss 1.0.1 → 1.1.2
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 +5 -5
- data/.github/workflows/gem-push.yml +31 -0
- data/.github/workflows/ruby.yml +6 -4
- data/.travis.yml +11 -1
- data/Gemfile +2 -1
- data/README.md +7 -2
- data/Rakefile +3 -1
- data/bin/tbsh +7 -6
- data/lib/tasks/calendars.rake +4 -4
- 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 +17 -14
- metadata +53 -23
- 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
@@ -1,48 +1,48 @@
|
|
1
1
|
module TimeBoss
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
super(basis: nil)
|
6
|
-
end
|
2
|
+
class TestMyCal < TimeBoss::Calendar
|
3
|
+
def initialize
|
4
|
+
super(basis: nil)
|
7
5
|
end
|
6
|
+
end
|
8
7
|
|
9
|
-
|
8
|
+
describe Calendars do
|
9
|
+
TimeBoss::Calendars.register(:my_amazing_calendar, TestMyCal)
|
10
10
|
|
11
|
-
describe
|
11
|
+
describe "#all" do
|
12
12
|
let(:all) { described_class.all }
|
13
13
|
|
14
|
-
it
|
14
|
+
it "can get a list of all the registered calendars" do
|
15
15
|
expect(all).to be_a Array
|
16
16
|
expect(all.length).to be > 1
|
17
17
|
all.each { |e| expect(e).to be_a described_class::Entry }
|
18
18
|
end
|
19
19
|
|
20
|
-
context
|
21
|
-
it
|
20
|
+
context "enumerability" do
|
21
|
+
it "can get a list of names" do
|
22
22
|
expect(described_class.map(&:name)).to include(:broadcast, :my_amazing_calendar)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
describe
|
28
|
-
it
|
27
|
+
describe "#[]" do
|
28
|
+
it "can return a baked-in calendar" do
|
29
29
|
c1 = described_class[:broadcast]
|
30
30
|
c2 = described_class[:broadcast]
|
31
31
|
expect(c1).to be_instance_of TimeBoss::Calendars::Broadcast
|
32
32
|
expect(c1).to be c2
|
33
33
|
|
34
|
-
expect(c1.name).to eq
|
35
|
-
expect(c1.title).to eq
|
34
|
+
expect(c1.name).to eq "broadcast"
|
35
|
+
expect(c1.title).to eq "Broadcast"
|
36
36
|
end
|
37
37
|
|
38
|
-
it
|
38
|
+
it "can return a new calendar" do
|
39
39
|
c1 = described_class[:my_amazing_calendar]
|
40
|
-
expect(c1).to be_instance_of
|
41
|
-
expect(c1.name).to eq
|
42
|
-
expect(c1.title).to eq
|
40
|
+
expect(c1).to be_instance_of TestMyCal
|
41
|
+
expect(c1.name).to eq "test_my_cal"
|
42
|
+
expect(c1.title).to eq "Test My Cal"
|
43
43
|
end
|
44
44
|
|
45
|
-
it
|
45
|
+
it "can graceully give you nothing" do
|
46
46
|
expect(described_class[:missing]).to be nil
|
47
47
|
end
|
48
48
|
end
|
data/spec/spec_helper.rb
CHANGED
data/timeboss.gemspec
CHANGED
@@ -1,26 +1,28 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
3
|
-
lib = File.expand_path(
|
2
|
+
|
3
|
+
lib = File.expand_path("../lib", __FILE__)
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
-
require
|
5
|
+
require "timeboss/version"
|
6
6
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
|
-
spec.name
|
9
|
-
spec.version
|
10
|
-
spec.authors
|
11
|
-
spec.email
|
12
|
-
spec.summary
|
13
|
-
spec.description
|
14
|
-
spec.homepage
|
15
|
-
spec.license
|
8
|
+
spec.name = "timeboss"
|
9
|
+
spec.version = TimeBoss::VERSION
|
10
|
+
spec.authors = ["Kevin McDonald"]
|
11
|
+
spec.email = ["kevinstuffandthings@gmail.com"]
|
12
|
+
spec.summary = "Broadcast Calendar navigation in Ruby made simple"
|
13
|
+
spec.description = spec.summary
|
14
|
+
spec.homepage = "https://github.com/kevinstuffandthings/timeboss"
|
15
|
+
spec.license = "MIT"
|
16
16
|
|
17
|
-
spec.files
|
18
|
-
spec.executables
|
19
|
-
spec.test_files
|
17
|
+
spec.files = `git ls-files -z`.split("\x0")
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
22
|
spec.add_dependency "activesupport"
|
23
23
|
|
24
|
+
spec.add_runtime_dependency "shellable"
|
25
|
+
|
24
26
|
spec.add_development_dependency "bundler"
|
25
27
|
spec.add_development_dependency "pry"
|
26
28
|
spec.add_development_dependency "pry-byebug"
|
@@ -28,5 +30,6 @@ Gem::Specification.new do |spec|
|
|
28
30
|
spec.add_development_dependency "rake"
|
29
31
|
spec.add_development_dependency "rspec"
|
30
32
|
spec.add_development_dependency "shellable"
|
33
|
+
spec.add_development_dependency "standard"
|
31
34
|
spec.add_development_dependency "yard"
|
32
35
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: timeboss
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin McDonald
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: shellable
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,6 +136,20 @@ dependencies:
|
|
122
136
|
- - ">="
|
123
137
|
- !ruby/object:Gem::Version
|
124
138
|
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: standard
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
125
153
|
- !ruby/object:Gem::Dependency
|
126
154
|
name: yard
|
127
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -146,6 +174,7 @@ extra_rdoc_files: []
|
|
146
174
|
files:
|
147
175
|
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
148
176
|
- ".github/ISSUE_TEMPLATE/feature_request.md"
|
177
|
+
- ".github/workflows/gem-push.yml"
|
149
178
|
- ".github/workflows/ruby.yml"
|
150
179
|
- ".gitignore"
|
151
180
|
- ".replit"
|
@@ -169,6 +198,8 @@ files:
|
|
169
198
|
- lib/timeboss/calendar/period.rb
|
170
199
|
- lib/timeboss/calendar/quarter.rb
|
171
200
|
- lib/timeboss/calendar/support/formatter.rb
|
201
|
+
- lib/timeboss/calendar/support/has_fiscal_weeks.rb
|
202
|
+
- lib/timeboss/calendar/support/has_iso_weeks.rb
|
172
203
|
- lib/timeboss/calendar/support/month_basis.rb
|
173
204
|
- lib/timeboss/calendar/support/monthly_unit.rb
|
174
205
|
- lib/timeboss/calendar/support/navigable.rb
|
@@ -184,21 +215,21 @@ files:
|
|
184
215
|
- lib/timeboss/calendars/broadcast.rb
|
185
216
|
- lib/timeboss/calendars/gregorian.rb
|
186
217
|
- lib/timeboss/version.rb
|
187
|
-
- spec/calendar/day_spec.rb
|
188
|
-
- spec/calendar/quarter_spec.rb
|
189
|
-
- spec/calendar/support/monthly_unit_spec.rb
|
190
|
-
- spec/calendar/support/unit_spec.rb
|
191
|
-
- spec/calendar/week_spec.rb
|
192
|
-
- spec/calendars/broadcast_spec.rb
|
193
|
-
- spec/calendars/gregorian_spec.rb
|
194
|
-
- spec/calendars_spec.rb
|
218
|
+
- spec/lib/timeboss/calendar/day_spec.rb
|
219
|
+
- spec/lib/timeboss/calendar/quarter_spec.rb
|
220
|
+
- spec/lib/timeboss/calendar/support/monthly_unit_spec.rb
|
221
|
+
- spec/lib/timeboss/calendar/support/unit_spec.rb
|
222
|
+
- spec/lib/timeboss/calendar/week_spec.rb
|
223
|
+
- spec/lib/timeboss/calendars/broadcast_spec.rb
|
224
|
+
- spec/lib/timeboss/calendars/gregorian_spec.rb
|
225
|
+
- spec/lib/timeboss/calendars_spec.rb
|
195
226
|
- spec/spec_helper.rb
|
196
227
|
- timeboss.gemspec
|
197
228
|
homepage: https://github.com/kevinstuffandthings/timeboss
|
198
229
|
licenses:
|
199
230
|
- MIT
|
200
231
|
metadata: {}
|
201
|
-
post_install_message:
|
232
|
+
post_install_message:
|
202
233
|
rdoc_options: []
|
203
234
|
require_paths:
|
204
235
|
- lib
|
@@ -213,18 +244,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
213
244
|
- !ruby/object:Gem::Version
|
214
245
|
version: '0'
|
215
246
|
requirements: []
|
216
|
-
|
217
|
-
|
218
|
-
signing_key:
|
247
|
+
rubygems_version: 3.0.3.1
|
248
|
+
signing_key:
|
219
249
|
specification_version: 4
|
220
250
|
summary: Broadcast Calendar navigation in Ruby made simple
|
221
251
|
test_files:
|
222
|
-
- spec/calendar/day_spec.rb
|
223
|
-
- spec/calendar/quarter_spec.rb
|
224
|
-
- spec/calendar/support/monthly_unit_spec.rb
|
225
|
-
- spec/calendar/support/unit_spec.rb
|
226
|
-
- spec/calendar/week_spec.rb
|
227
|
-
- spec/calendars/broadcast_spec.rb
|
228
|
-
- spec/calendars/gregorian_spec.rb
|
229
|
-
- spec/calendars_spec.rb
|
252
|
+
- spec/lib/timeboss/calendar/day_spec.rb
|
253
|
+
- spec/lib/timeboss/calendar/quarter_spec.rb
|
254
|
+
- spec/lib/timeboss/calendar/support/monthly_unit_spec.rb
|
255
|
+
- spec/lib/timeboss/calendar/support/unit_spec.rb
|
256
|
+
- spec/lib/timeboss/calendar/week_spec.rb
|
257
|
+
- spec/lib/timeboss/calendars/broadcast_spec.rb
|
258
|
+
- spec/lib/timeboss/calendars/gregorian_spec.rb
|
259
|
+
- spec/lib/timeboss/calendars_spec.rb
|
230
260
|
- spec/spec_helper.rb
|
@@ -1,85 +0,0 @@
|
|
1
|
-
module TimeBoss
|
2
|
-
class Calendar
|
3
|
-
module Support
|
4
|
-
describe MonthlyUnit do
|
5
|
-
class MonthBasedChunk < described_class
|
6
|
-
NUM_MONTHS = 2
|
7
|
-
|
8
|
-
def name
|
9
|
-
"#{year_index}C#{index}"
|
10
|
-
end
|
11
|
-
end
|
12
|
-
let(:described_class) { MonthBasedChunk }
|
13
|
-
let(:calendar) { double }
|
14
|
-
let(:start_date) { Date.parse('2018-06-25') }
|
15
|
-
let(:end_date) { Date.parse('2018-08-26') }
|
16
|
-
let(:subject) { described_class.new(calendar, 2018, 4, start_date, end_date) }
|
17
|
-
|
18
|
-
it 'knows its stuff' do
|
19
|
-
expect(subject.start_date).to eq start_date
|
20
|
-
expect(subject.end_date).to eq end_date
|
21
|
-
expect(subject.to_range).to eq start_date..end_date
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'can stringify itself' do
|
25
|
-
expect(subject.to_s).to eq "2018C4: 2018-06-25 thru 2018-08-26"
|
26
|
-
end
|
27
|
-
|
28
|
-
describe '#weeks' do
|
29
|
-
let(:base) { double(start_date: Date.parse('2018-01-01'), end_date: Date.parse('2018-12-30')) }
|
30
|
-
before(:each) { allow(calendar).to receive(:year).with(2018).and_return base }
|
31
|
-
|
32
|
-
it 'can get the relevant weeks for the period' do
|
33
|
-
allow(calendar).to receive(:supports_weeks?).and_return true
|
34
|
-
result = subject.weeks
|
35
|
-
result.each { |w| expect(w).to be_instance_of TimeBoss::Calendar::Week }
|
36
|
-
expect(result.map { |w| w.start_date.to_s }).to eq [
|
37
|
-
'2018-06-25',
|
38
|
-
'2018-07-02',
|
39
|
-
'2018-07-09',
|
40
|
-
'2018-07-16',
|
41
|
-
'2018-07-23',
|
42
|
-
'2018-07-30',
|
43
|
-
'2018-08-06',
|
44
|
-
'2018-08-13',
|
45
|
-
'2018-08-20'
|
46
|
-
]
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'blows up when weeks are not supported' do
|
50
|
-
allow(calendar).to receive(:supports_weeks?).and_return false
|
51
|
-
expect { subject.weeks }.to raise_error TimeBoss::Calendar::Support::Unit::UnsupportedUnitError
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
context 'navigation' do
|
56
|
-
let(:result) { double }
|
57
|
-
|
58
|
-
describe '#previous' do
|
59
|
-
it 'moves easily within itself' do
|
60
|
-
expect(calendar).to receive(:month_based_chunk).with(48, 3).and_return result
|
61
|
-
expect(described_class.new(calendar, 48, 4, nil, nil).previous).to eq result
|
62
|
-
end
|
63
|
-
|
64
|
-
it 'flips to the previous container' do
|
65
|
-
expect(calendar).to receive(:month_based_chunk).with(47, 6).and_return result
|
66
|
-
expect(described_class.new(calendar, 48, 1, nil, nil).previous).to eq result
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
describe '#next' do
|
71
|
-
it 'moves easily within itself' do
|
72
|
-
expect(calendar).to receive(:month_based_chunk).with(48, 3).and_return result
|
73
|
-
expect(described_class.new(calendar, 48, 2, nil, nil).next).to eq result
|
74
|
-
end
|
75
|
-
|
76
|
-
it 'flips to the previous container' do
|
77
|
-
expect(calendar).to receive(:month_based_chunk).with(48, 1).and_return result
|
78
|
-
expect(described_class.new(calendar, 47, 6, nil, nil).next).to eq result
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|