business 1.9.0 → 1.10.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/.ruby-version +1 -0
- data/CHANGELOG.md +4 -0
- data/lib/business/calendar.rb +6 -0
- data/lib/business/data/betalingsservice.yml +26 -1
- data/lib/business/version.rb +1 -1
- data/spec/calendar_spec.rb +23 -6
- data/spec/fixtures/calendars/invalid-keys.yml +9 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38d7c459347f1741d925e77a8f359aed43320ac7
|
4
|
+
data.tar.gz: 45c96913b44c0e52db052928ff2fcc2229777c02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc3ca27a207f527ea0049e0f654d9b90f173824cefc06cd0397da811b17594988a0d7a5c30c9686902492a923fee263c490e5fff51096dceb060f249c0f951c0
|
7
|
+
data.tar.gz: 57097df722e522ad352dbca41cc1e109b0ffd5cf7f415df14fda5e34310a3ae4be57eeb42649a2224ef10f0277ea408e794ade3efedaf6583b09dfa55d2b7e92
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.4.1
|
data/CHANGELOG.md
CHANGED
data/lib/business/calendar.rb
CHANGED
@@ -19,6 +19,12 @@ module Business
|
|
19
19
|
raise "No such calendar '#{calendar}'" unless directory
|
20
20
|
|
21
21
|
yaml = YAML.load_file(File.join(directory, "#{calendar}.yml"))
|
22
|
+
valid_keys = ['holidays', 'working_days']
|
23
|
+
|
24
|
+
unless (yaml.keys - valid_keys).empty?
|
25
|
+
raise "Only valid keys are: #{valid_keys.join(', ')}"
|
26
|
+
end
|
27
|
+
|
22
28
|
self.new(holidays: yaml['holidays'], working_days: yaml['working_days'])
|
23
29
|
end
|
24
30
|
|
@@ -15,6 +15,31 @@ holidays:
|
|
15
15
|
- May 25th, 2017
|
16
16
|
- May 26th, 2017
|
17
17
|
- June 5th, 2017
|
18
|
-
- December 24th, 2017
|
19
18
|
- December 25th, 2017
|
20
19
|
- December 26th, 2017
|
20
|
+
- January 1st, 2018
|
21
|
+
- March 29th, 2018
|
22
|
+
- March 30th, 2018
|
23
|
+
- April 2nd, 2018
|
24
|
+
- April 27th, 2018
|
25
|
+
- May 10th, 2018
|
26
|
+
- May 11th, 2018
|
27
|
+
- May 21st, 2018
|
28
|
+
- June 5th, 2018
|
29
|
+
- December 24th, 2018
|
30
|
+
- December 25th, 2018
|
31
|
+
- December 26th, 2018
|
32
|
+
- December 31st, 2018
|
33
|
+
- January 1st, 2019
|
34
|
+
- April 18th, 2019
|
35
|
+
- April 19th, 2019
|
36
|
+
- April 22nd, 2019
|
37
|
+
- May 17th, 2019
|
38
|
+
- May 30th, 2019
|
39
|
+
- May 31st, 2019
|
40
|
+
- June 5th, 2019
|
41
|
+
- June 10th, 2019
|
42
|
+
- December 24th, 2019
|
43
|
+
- December 25th, 2019
|
44
|
+
- December 26th, 2019
|
45
|
+
- December 31st, 2019
|
data/lib/business/version.rb
CHANGED
data/spec/calendar_spec.rb
CHANGED
@@ -8,6 +8,11 @@ end
|
|
8
8
|
|
9
9
|
describe Business::Calendar do
|
10
10
|
describe ".load" do
|
11
|
+
before do
|
12
|
+
fixture_path = File.join(File.dirname(__FILE__), 'fixtures', 'calendars')
|
13
|
+
Business::Calendar.additional_load_paths = [fixture_path]
|
14
|
+
end
|
15
|
+
|
11
16
|
context "when given a valid calendar" do
|
12
17
|
subject { Business::Calendar.load("weekdays") }
|
13
18
|
|
@@ -22,11 +27,6 @@ describe Business::Calendar do
|
|
22
27
|
end
|
23
28
|
|
24
29
|
context "when given a calendar from a custom directory" do
|
25
|
-
before do
|
26
|
-
Business::Calendar.additional_load_paths = [
|
27
|
-
File.join(File.dirname(__FILE__), 'fixtures', 'calendars')
|
28
|
-
]
|
29
|
-
end
|
30
30
|
after { Business::Calendar.additional_load_paths = nil }
|
31
31
|
subject { Business::Calendar.load("ecb") }
|
32
32
|
|
@@ -49,10 +49,27 @@ describe Business::Calendar do
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
context "when given
|
52
|
+
context "when given a calendar that does not exist" do
|
53
53
|
subject { Business::Calendar.load("invalid-calendar") }
|
54
54
|
specify { expect { subject }.to raise_error(/No such calendar/) }
|
55
55
|
end
|
56
|
+
|
57
|
+
context "when given a calendar that has invalid keys" do
|
58
|
+
subject { Business::Calendar.load("invalid-keys") }
|
59
|
+
specify { expect { subject }.to raise_error("Only valid keys are: holidays, working_days") }
|
60
|
+
end
|
61
|
+
|
62
|
+
context "when given real business data" do
|
63
|
+
let(:data_path) { File.join(File.dirname(__FILE__), '..', 'lib', 'business', 'data') }
|
64
|
+
it "validates they are all loadable by the calendar" do
|
65
|
+
Dir.glob("#{data_path}/*").each do |filename|
|
66
|
+
calendar_name = File.basename(filename, ".yml")
|
67
|
+
calendar = Business::Calendar.load(calendar_name)
|
68
|
+
|
69
|
+
expect(calendar.working_days.length).to be >= 1
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
56
73
|
end
|
57
74
|
|
58
75
|
describe "#set_working_days" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: business
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Harry Marr
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -46,6 +46,7 @@ extensions: []
|
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
48
|
- ".gitignore"
|
49
|
+
- ".ruby-version"
|
49
50
|
- ".travis.yml"
|
50
51
|
- CHANGELOG.md
|
51
52
|
- Gemfile
|
@@ -63,6 +64,7 @@ files:
|
|
63
64
|
- spec/calendar_spec.rb
|
64
65
|
- spec/fixtures/calendars/bacs.yml
|
65
66
|
- spec/fixtures/calendars/ecb.yml
|
67
|
+
- spec/fixtures/calendars/invalid-keys.yml
|
66
68
|
homepage: https://github.com/gocardless/business
|
67
69
|
licenses:
|
68
70
|
- MIT
|
@@ -91,3 +93,4 @@ test_files:
|
|
91
93
|
- spec/calendar_spec.rb
|
92
94
|
- spec/fixtures/calendars/bacs.yml
|
93
95
|
- spec/fixtures/calendars/ecb.yml
|
96
|
+
- spec/fixtures/calendars/invalid-keys.yml
|