timeboss 1.1.0 → 1.1.3
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 +4 -4
- data/bin/tbsh +7 -6
- data/lib/timeboss/calendar/support/unit.rb +9 -0
- data/lib/timeboss/version.rb +1 -1
- data/lib/timeboss.rb +1 -1
- data/spec/{calendar → lib/timeboss/calendar}/day_spec.rb +0 -0
- data/spec/{calendar → lib/timeboss/calendar}/quarter_spec.rb +0 -0
- data/spec/{calendar → lib/timeboss/calendar}/support/monthly_unit_spec.rb +0 -0
- data/spec/{calendar → lib/timeboss/calendar}/support/unit_spec.rb +51 -0
- data/spec/{calendar → lib/timeboss/calendar}/week_spec.rb +0 -0
- data/spec/{calendars → lib/timeboss/calendars}/broadcast_spec.rb +0 -0
- data/spec/{calendars → lib/timeboss/calendars}/gregorian_spec.rb +0 -0
- data/spec/{calendars_spec.rb → lib/timeboss/calendars_spec.rb} +0 -0
- data/timeboss.gemspec +2 -0
- metadata +32 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65f9e2cd955a728e0efd00e99f530f1ff6dbb7ee0c8cee7e25499466fb10edc9
|
4
|
+
data.tar.gz: 9523e2983ffff0d5d33cf9b07e7fd4cd1b26b54c68e8a3f77d8996aaa7ad991d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f850961e4659cee0b07e59d4421f1444c39e3882338f5189cd5821e5d4ec00228c4043aef7c001df8a2181cf4161671943653e7e0c843f419f4f7d91b6bb99d
|
7
|
+
data.tar.gz: 24a8f28844c20caf7f0294a5e5db155ff809f46ad76e421e97d807b929ceca37035d9b89539a5600713d9420ba8f799fa1668c61e47b040a8728c41df12a67df
|
data/bin/tbsh
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "timeboss"
|
4
|
+
require "timeboss/calendars"
|
5
|
+
require "shellable"
|
5
6
|
|
6
7
|
calendar = if ARGV.length == 1
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
TimeBoss::Calendars[ARGV.first]
|
9
|
+
else
|
10
|
+
TimeBoss::Calendars.first.calendar
|
11
|
+
end
|
11
12
|
|
12
13
|
abort "Unknown calendar" if calendar.nil?
|
13
14
|
|
@@ -84,6 +84,15 @@ module TimeBoss
|
|
84
84
|
@_to_range ||= start_date..end_date
|
85
85
|
end
|
86
86
|
|
87
|
+
# Clamp this unit to the range of the provided unit.
|
88
|
+
# @return [Period]
|
89
|
+
def clamp(unit)
|
90
|
+
new_start_date = start_date.clamp(unit.start_date, unit.end_date)
|
91
|
+
new_end_date = end_date.clamp(unit.start_date, unit.end_date)
|
92
|
+
return unless new_start_date.between?(start_date, end_date) && new_end_date.between?(start_date, end_date)
|
93
|
+
calendar.parse("#{new_start_date}..#{new_end_date}")
|
94
|
+
end
|
95
|
+
|
87
96
|
def inspect
|
88
97
|
"#<#{self.class.name} start_date=#{start_date}, end_date=#{end_date}>"
|
89
98
|
end
|
data/lib/timeboss/version.rb
CHANGED
data/lib/timeboss.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
@@ -28,6 +28,57 @@ module TimeBoss
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
+
describe "#clamp" do
|
32
|
+
let(:clamp_start_date) { Date.parse("2018-06-21") }
|
33
|
+
let(:clamp_end_date) { Date.parse("2018-08-30") }
|
34
|
+
let(:result) { subject.clamp(described_class.new(calendar, clamp_start_date, clamp_end_date)) }
|
35
|
+
let(:period) { double }
|
36
|
+
|
37
|
+
context "open" do
|
38
|
+
it "does not restrict the returned period" do
|
39
|
+
expect(calendar).to receive(:parse).with("#{start_date}..#{end_date}").and_return period
|
40
|
+
expect(result).to eq period
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context "left clamped" do
|
45
|
+
let(:clamp_start_date) { Date.parse("2018-06-30") }
|
46
|
+
|
47
|
+
it "brings the beginning date inward" do
|
48
|
+
expect(calendar).to receive(:parse).with("#{clamp_start_date}..#{end_date}").and_return period
|
49
|
+
expect(result).to eq period
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context "right clamped" do
|
54
|
+
let(:clamp_end_date) { Date.parse("2018-07-30") }
|
55
|
+
|
56
|
+
it "brings the beginning date inward" do
|
57
|
+
expect(calendar).to receive(:parse).with("#{start_date}..#{clamp_end_date}").and_return period
|
58
|
+
expect(result).to eq period
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
context "fully clamped" do
|
63
|
+
let(:clamp_start_date) { Date.parse("2018-06-30") }
|
64
|
+
let(:clamp_end_date) { Date.parse("2018-07-30") }
|
65
|
+
|
66
|
+
it "brings the beginning date inward" do
|
67
|
+
expect(calendar).to receive(:parse).with("#{clamp_start_date}..#{clamp_end_date}").and_return period
|
68
|
+
expect(result).to eq period
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
context "obliterated" do
|
73
|
+
let(:clamp_start_date) { Date.parse("2018-09-01") }
|
74
|
+
let(:clamp_end_date) { Date.parse("2018-09-06") }
|
75
|
+
|
76
|
+
it "returns nil" do
|
77
|
+
expect(result).to be_nil
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
31
82
|
context "periods" do
|
32
83
|
before(:each) do
|
33
84
|
allow(calendar).to receive(:days_for).with(subject).and_return %w[D1 D2 D3 D4 D5 D6 D7 D8]
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/timeboss.gemspec
CHANGED
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.1.
|
4
|
+
version: 1.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin McDonald
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-03-22 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
|
@@ -201,14 +215,14 @@ files:
|
|
201
215
|
- lib/timeboss/calendars/broadcast.rb
|
202
216
|
- lib/timeboss/calendars/gregorian.rb
|
203
217
|
- lib/timeboss/version.rb
|
204
|
-
- spec/calendar/day_spec.rb
|
205
|
-
- spec/calendar/quarter_spec.rb
|
206
|
-
- spec/calendar/support/monthly_unit_spec.rb
|
207
|
-
- spec/calendar/support/unit_spec.rb
|
208
|
-
- spec/calendar/week_spec.rb
|
209
|
-
- spec/calendars/broadcast_spec.rb
|
210
|
-
- spec/calendars/gregorian_spec.rb
|
211
|
-
- 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
|
212
226
|
- spec/spec_helper.rb
|
213
227
|
- timeboss.gemspec
|
214
228
|
homepage: https://github.com/kevinstuffandthings/timeboss
|
@@ -235,12 +249,12 @@ signing_key:
|
|
235
249
|
specification_version: 4
|
236
250
|
summary: Broadcast Calendar navigation in Ruby made simple
|
237
251
|
test_files:
|
238
|
-
- spec/calendar/day_spec.rb
|
239
|
-
- spec/calendar/quarter_spec.rb
|
240
|
-
- spec/calendar/support/monthly_unit_spec.rb
|
241
|
-
- spec/calendar/support/unit_spec.rb
|
242
|
-
- spec/calendar/week_spec.rb
|
243
|
-
- spec/calendars/broadcast_spec.rb
|
244
|
-
- spec/calendars/gregorian_spec.rb
|
245
|
-
- 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
|
246
260
|
- spec/spec_helper.rb
|