kalendor 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/kalendor/factory.rb +4 -0
- data/lib/kalendor/instance/union.rb +3 -0
- data/lib/kalendor/instance.rb +17 -0
- data/lib/kalendor/version.rb +1 -1
- data/spec/append_spec.rb +32 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8444d0694397d073104ded49efd8c0f3d67cd4a2cff9227214b35c9cc2a01b34
|
4
|
+
data.tar.gz: 488d82824e4643d8802f4a6707bd074ff74973e8c12ac14fc6c890ebcfc67565
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9599ebca8914d341d2c94acc78461131d5aadbfa869599bad0902e045427ee2b673c6bf5bdc880ad2a5bd1badf4415af2f18f62234ad26d191cae9898364ac2
|
7
|
+
data.tar.gz: 180e1b7ed41294247dffd69ef5ed0e52ca50ef80a343398c105fde2ebe13044a58b29bc24944622f5484fb772a12876c10f850ba4e3632e455e59d0b3729a357
|
data/lib/kalendor/factory.rb
CHANGED
data/lib/kalendor/instance.rb
CHANGED
@@ -2,6 +2,23 @@ module Kalendor
|
|
2
2
|
module Instance
|
3
3
|
class Base < Aduki::Initializable
|
4
4
|
attr_accessor :name, :label
|
5
|
+
|
6
|
+
def append other
|
7
|
+
me = self
|
8
|
+
Kalendor.build { union me, other }
|
9
|
+
end
|
10
|
+
|
11
|
+
def union *others
|
12
|
+
Kalendor::Instance::Union.new(schedules: [self, *others])
|
13
|
+
end
|
14
|
+
|
15
|
+
def intersect *others
|
16
|
+
Kalendor::Instance::Intersect.new(schedules: [self, *others])
|
17
|
+
end
|
18
|
+
|
19
|
+
def subtract other
|
20
|
+
Kalendor::Instance::Subtract.new include_dates: self, exclude_dates: other
|
21
|
+
end
|
5
22
|
end
|
6
23
|
end
|
7
24
|
end
|
data/lib/kalendor/version.rb
CHANGED
data/spec/append_spec.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'kalendor'
|
2
|
+
require 'kalendor/instance/annual'
|
3
|
+
require 'kalendor/instance/union'
|
4
|
+
require 'kalendor/instance/weekday'
|
5
|
+
|
6
|
+
RSpec.describe "#append" do
|
7
|
+
it "produces every weekend in oct - dec 2016" do
|
8
|
+
sats = Kalendor.build { weekday(6) }
|
9
|
+
suns = Kalendor.build { weekday(7) }
|
10
|
+
|
11
|
+
weekends = Kalendor.build { append sats, suns }
|
12
|
+
|
13
|
+
weekends_in_oct_2016 = [1,2,8,9,15,16,22,23,29,30].map { |d| date("2016-10-#{d}") }
|
14
|
+
weekends_in_nov_2016 = [5,6,12,13,19,20,26,27 ].map { |d| date("2016-11-#{d}") }
|
15
|
+
weekends_in_dec_2016 = [3,4,10,11,17,18,24,25,31 ].map { |d| date("2016-12-#{d}") }
|
16
|
+
weekends_in_end_2016 = weekends_in_oct_2016 + weekends_in_nov_2016 + weekends_in_dec_2016
|
17
|
+
|
18
|
+
expect(weekends.get_dates date("2016-10-01"), date("2016-12-31")).to eq weekends_in_end_2016
|
19
|
+
end
|
20
|
+
|
21
|
+
it "appends to a union" do
|
22
|
+
mix = Kalendor.build { union annual(12,3), annual(21,6), annual(8,6) }
|
23
|
+
|
24
|
+
more = Kalendor.build { append mix, annual(18,11) }
|
25
|
+
|
26
|
+
bd2015 = %w{ 2015-03-12 2015-06-08 2015-06-21 2015-11-18 }
|
27
|
+
bd2016 = %w{ 2016-03-12 2016-06-08 2016-06-21 2016-11-18 }
|
28
|
+
expected = (bd2015 + bd2016).map { |d| date d }.sort
|
29
|
+
|
30
|
+
expect(more.get_dates date("2015-01-01"), date("2016-12-31")).to eq expected
|
31
|
+
end
|
32
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kalendor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Conan Dalton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aduki
|
@@ -121,6 +121,7 @@ files:
|
|
121
121
|
- lib/kalendor/version.rb
|
122
122
|
- lib/kalendor/weekday.rb
|
123
123
|
- spec/annual_spec.rb
|
124
|
+
- spec/append_spec.rb
|
124
125
|
- spec/date_list_spec.rb
|
125
126
|
- spec/date_spec.rb
|
126
127
|
- spec/intersect_spec.rb
|
@@ -151,13 +152,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
151
152
|
- !ruby/object:Gem::Version
|
152
153
|
version: '0'
|
153
154
|
requirements: []
|
154
|
-
|
155
|
-
rubygems_version: 2.5.2.3
|
155
|
+
rubygems_version: 3.0.3.1
|
156
156
|
signing_key:
|
157
157
|
specification_version: 4
|
158
158
|
summary: Utility classes for generating sets of dates
|
159
159
|
test_files:
|
160
160
|
- spec/annual_spec.rb
|
161
|
+
- spec/append_spec.rb
|
161
162
|
- spec/date_list_spec.rb
|
162
163
|
- spec/date_spec.rb
|
163
164
|
- spec/intersect_spec.rb
|