timeboss 0.1.1 → 0.2.0
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/README.md +3 -1
- data/lib/timeboss/calendar.rb +4 -0
- data/lib/timeboss/calendar/support/formatter.rb +1 -0
- data/lib/timeboss/calendar/support/unit.rb +2 -0
- data/lib/timeboss/calendar/week.rb +1 -0
- data/lib/timeboss/calendars/broadcast.rb +4 -0
- data/lib/timeboss/calendars/gregorian.rb +24 -0
- data/lib/timeboss/version.rb +1 -1
- data/spec/calendar/support/monthly_unit_spec.rb +6 -0
- data/spec/calendar/week_spec.rb +6 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8b4b4481ef5554103855a604563c4db3a4deddb298af24a219315f1a658c7ba
|
4
|
+
data.tar.gz: 8be65df968e3a044a81cf492f3be16a03e9d79a61fb80ac6ff4218c8a5b71aa3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df28f604bbea294960ff8131b65b5b3315bf2cd2c2663866ee3b28e208abc25ef7811535482931620d4886ec8b39249967ed38cfa63cf4a865eba6ea31f11022
|
7
|
+
data.tar.gz: 8b8f043b358f21970af342263154ac3bcd40f9322b37c7e7c0587740c703214e77798e8b28ff56d627c9b6bab3f5306bb1e6e21ca52dd7589fa2d6e450a75178
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# TimeBoss [](https://travis-ci.com/kevinstuffandthings/timeboss) [](https://badge.fury.io/rb/timeboss)
|
2
|
-
|
2
|
+
|
3
|
+
A gem providing convenient navigation of the [Broadcast Calendar](https://en.wikipedia.org/wiki/Broadcast_calendar), the standard Gregorian calendar, and is easily extensible to support multiple financial calendars.
|
4
|
+
|
3
5
|
Originally developed for [Simulmedia](https://simulmedia.com).
|
4
6
|
|
5
7
|
## Installation
|
data/lib/timeboss/calendar.rb
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative '../calendar'
|
3
|
+
|
4
|
+
module TimeBoss
|
5
|
+
module Calendars
|
6
|
+
class Gregorian < Calendar
|
7
|
+
def initialize
|
8
|
+
super(basis: Basis)
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
class Basis < Calendar::Support::MonthBasis
|
14
|
+
def start_date
|
15
|
+
@_start_date ||= Date.civil(year, month, 1)
|
16
|
+
end
|
17
|
+
|
18
|
+
def end_date
|
19
|
+
@_end_date ||= Date.civil(year, month, -1)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/timeboss/version.rb
CHANGED
@@ -30,6 +30,7 @@ module TimeBoss
|
|
30
30
|
before(:each) { allow(calendar).to receive(:year).with(2018).and_return base }
|
31
31
|
|
32
32
|
it 'can get the relevant weeks for the period' do
|
33
|
+
allow(calendar).to receive(:supports_weeks?).and_return true
|
33
34
|
result = subject.weeks
|
34
35
|
result.each { |w| expect(w).to be_instance_of TimeBoss::Calendar::Week }
|
35
36
|
expect(result.map { |w| w.start_date.to_s }).to eq [
|
@@ -44,6 +45,11 @@ module TimeBoss
|
|
44
45
|
'2018-08-20'
|
45
46
|
]
|
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
|
47
53
|
end
|
48
54
|
|
49
55
|
context 'navigation' do
|
data/spec/calendar/week_spec.rb
CHANGED
@@ -1,11 +1,16 @@
|
|
1
1
|
module TimeBoss
|
2
2
|
class Calendar
|
3
3
|
describe Week do
|
4
|
-
let(:calendar) { instance_double(TimeBoss::Calendar) }
|
4
|
+
let(:calendar) { instance_double(TimeBoss::Calendar, supports_weeks?: true) }
|
5
5
|
let(:start_date) { Date.parse('2048-04-06') }
|
6
6
|
let(:end_date) { Date.parse('2048-04-12') }
|
7
7
|
let(:subject) { described_class.new(calendar, start_date, end_date) }
|
8
8
|
|
9
|
+
it "doesn't even exist if its calendar doesn't support weeks" do
|
10
|
+
allow(calendar).to receive(:supports_weeks?).and_return false
|
11
|
+
expect { subject }.to raise_error TimeBoss::Calendar::Support::Unit::UnsupportedUnitError
|
12
|
+
end
|
13
|
+
|
9
14
|
it 'knows its stuff' do
|
10
15
|
expect(subject.start_date).to eq start_date
|
11
16
|
expect(subject.end_date).to eq end_date
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: timeboss
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin McDonald
|
@@ -166,6 +166,7 @@ files:
|
|
166
166
|
- lib/timeboss/calendar/year.rb
|
167
167
|
- lib/timeboss/calendars.rb
|
168
168
|
- lib/timeboss/calendars/broadcast.rb
|
169
|
+
- lib/timeboss/calendars/gregorian.rb
|
169
170
|
- lib/timeboss/support/shellable.rb
|
170
171
|
- lib/timeboss/version.rb
|
171
172
|
- spec/calendar/day_spec.rb
|