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
@@ -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,22 +1,22 @@
|
|
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"
|
@@ -27,5 +27,7 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.add_development_dependency "rack-test"
|
28
28
|
spec.add_development_dependency "rake"
|
29
29
|
spec.add_development_dependency "rspec"
|
30
|
+
spec.add_development_dependency "shellable"
|
31
|
+
spec.add_development_dependency "standard"
|
30
32
|
spec.add_development_dependency "yard"
|
31
33
|
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin McDonald
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -108,6 +108,34 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: shellable
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: standard
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
111
139
|
- !ruby/object:Gem::Dependency
|
112
140
|
name: yard
|
113
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -132,6 +160,8 @@ extra_rdoc_files: []
|
|
132
160
|
files:
|
133
161
|
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
134
162
|
- ".github/ISSUE_TEMPLATE/feature_request.md"
|
163
|
+
- ".github/workflows/gem-push.yml"
|
164
|
+
- ".github/workflows/ruby.yml"
|
135
165
|
- ".gitignore"
|
136
166
|
- ".replit"
|
137
167
|
- ".rspec"
|
@@ -154,6 +184,8 @@ files:
|
|
154
184
|
- lib/timeboss/calendar/period.rb
|
155
185
|
- lib/timeboss/calendar/quarter.rb
|
156
186
|
- lib/timeboss/calendar/support/formatter.rb
|
187
|
+
- lib/timeboss/calendar/support/has_fiscal_weeks.rb
|
188
|
+
- lib/timeboss/calendar/support/has_iso_weeks.rb
|
157
189
|
- lib/timeboss/calendar/support/month_basis.rb
|
158
190
|
- lib/timeboss/calendar/support/monthly_unit.rb
|
159
191
|
- lib/timeboss/calendar/support/navigable.rb
|
@@ -168,16 +200,15 @@ files:
|
|
168
200
|
- lib/timeboss/calendars.rb
|
169
201
|
- lib/timeboss/calendars/broadcast.rb
|
170
202
|
- lib/timeboss/calendars/gregorian.rb
|
171
|
-
- lib/timeboss/support/shellable.rb
|
172
203
|
- lib/timeboss/version.rb
|
173
|
-
- spec/calendar/day_spec.rb
|
174
|
-
- spec/calendar/quarter_spec.rb
|
175
|
-
- spec/calendar/support/monthly_unit_spec.rb
|
176
|
-
- spec/calendar/support/unit_spec.rb
|
177
|
-
- spec/calendar/week_spec.rb
|
178
|
-
- spec/calendars/broadcast_spec.rb
|
179
|
-
- spec/calendars/gregorian_spec.rb
|
180
|
-
- spec/calendars_spec.rb
|
204
|
+
- spec/lib/timeboss/calendar/day_spec.rb
|
205
|
+
- spec/lib/timeboss/calendar/quarter_spec.rb
|
206
|
+
- spec/lib/timeboss/calendar/support/monthly_unit_spec.rb
|
207
|
+
- spec/lib/timeboss/calendar/support/unit_spec.rb
|
208
|
+
- spec/lib/timeboss/calendar/week_spec.rb
|
209
|
+
- spec/lib/timeboss/calendars/broadcast_spec.rb
|
210
|
+
- spec/lib/timeboss/calendars/gregorian_spec.rb
|
211
|
+
- spec/lib/timeboss/calendars_spec.rb
|
181
212
|
- spec/spec_helper.rb
|
182
213
|
- timeboss.gemspec
|
183
214
|
homepage: https://github.com/kevinstuffandthings/timeboss
|
@@ -199,17 +230,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
199
230
|
- !ruby/object:Gem::Version
|
200
231
|
version: '0'
|
201
232
|
requirements: []
|
202
|
-
rubygems_version: 3.0.
|
233
|
+
rubygems_version: 3.0.3.1
|
203
234
|
signing_key:
|
204
235
|
specification_version: 4
|
205
236
|
summary: Broadcast Calendar navigation in Ruby made simple
|
206
237
|
test_files:
|
207
|
-
- spec/calendar/day_spec.rb
|
208
|
-
- spec/calendar/quarter_spec.rb
|
209
|
-
- spec/calendar/support/monthly_unit_spec.rb
|
210
|
-
- spec/calendar/support/unit_spec.rb
|
211
|
-
- spec/calendar/week_spec.rb
|
212
|
-
- spec/calendars/broadcast_spec.rb
|
213
|
-
- spec/calendars/gregorian_spec.rb
|
214
|
-
- spec/calendars_spec.rb
|
238
|
+
- spec/lib/timeboss/calendar/day_spec.rb
|
239
|
+
- spec/lib/timeboss/calendar/quarter_spec.rb
|
240
|
+
- spec/lib/timeboss/calendar/support/monthly_unit_spec.rb
|
241
|
+
- spec/lib/timeboss/calendar/support/unit_spec.rb
|
242
|
+
- spec/lib/timeboss/calendar/week_spec.rb
|
243
|
+
- spec/lib/timeboss/calendars/broadcast_spec.rb
|
244
|
+
- spec/lib/timeboss/calendars/gregorian_spec.rb
|
245
|
+
- spec/lib/timeboss/calendars_spec.rb
|
215
246
|
- spec/spec_helper.rb
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module TimeBoss
|
2
|
-
module Support
|
3
|
-
module Shellable
|
4
|
-
def self.open(context)
|
5
|
-
context.extend(self).open_shell
|
6
|
-
end
|
7
|
-
|
8
|
-
def open_shell
|
9
|
-
require 'irb'
|
10
|
-
IRB.setup nil
|
11
|
-
IRB.conf[:MAIN_CONTEXT] = IRB::Irb.new.context
|
12
|
-
require 'irb/ext/multi-irb'
|
13
|
-
IRB.irb nil, self
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -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
|