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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9a017e860726e71c63fe878689cae14a0b738b9d
4
- data.tar.gz: 3633a65fa4e14e8a603aa2611a48b32a8ac69fbb
3
+ metadata.gz: 38d7c459347f1741d925e77a8f359aed43320ac7
4
+ data.tar.gz: 45c96913b44c0e52db052928ff2fcc2229777c02
5
5
  SHA512:
6
- metadata.gz: a014c05af60a086b7f76c92e5976cbd29ef3ffadeb4097c08f7dd7dfc623ccf9a61159fc607ec4c0a214acbb163dbefdfdcfe60c7c4c673c0f760b9290726b9b
7
- data.tar.gz: 3f7636def162fbe9c27aa87d2ec20e5398c8e2759d58505d0fd118f13112d8756f70aedd3419a480ec7654595e46913cf94bfb62b6d9d940f17a25e69c206731
6
+ metadata.gz: fc3ca27a207f527ea0049e0f654d9b90f173824cefc06cd0397da811b17594988a0d7a5c30c9686902492a923fee263c490e5fff51096dceb060f249c0f951c0
7
+ data.tar.gz: 57097df722e522ad352dbca41cc1e109b0ffd5cf7f415df14fda5e34310a3ae4be57eeb42649a2224ef10f0277ea408e794ade3efedaf6583b09dfa55d2b7e92
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.4.1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 1.10.0 - September 20, 2017
2
+
3
+ - Add 2018-2019 Betalingsservice holiday definitions
4
+
1
5
  ## 1.9.0 - August 23, 2017
2
6
 
3
7
  - Add 2017 Betalingsservice holiday definitions
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Business
2
- VERSION = "1.9.0"
2
+ VERSION = "1.10.0"
3
3
  end
@@ -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 an invalid calendar" do
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
@@ -0,0 +1,9 @@
1
+ working_days:
2
+ - monday
3
+ - tuesday
4
+ - wednesday
5
+ - thursday
6
+ - friday
7
+
8
+ holidayswithtypo:
9
+ - January 1st, 2015
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.9.0
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-08-23 00:00:00.000000000 Z
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