business_calendar 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -22,6 +22,8 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.add_development_dependency "bundler", "~> 1.3"
24
24
  spec.add_development_dependency "rake"
25
- spec.add_development_dependency "rspec"
25
+ spec.add_development_dependency "pry"
26
+ spec.add_development_dependency "pry-debugger"
27
+ spec.add_development_dependency "rspec", "~> 3.2"
26
28
  spec.add_development_dependency "timecop"
27
29
  end
data/data/holidays.yml CHANGED
@@ -71,25 +71,20 @@ CN:
71
71
  - '2014-10-06'
72
72
  - '2014-10-07'
73
73
  - '2015-01-01'
74
+ - '2015-01-02'
75
+ - '2015-01-03'
76
+ - '2015-02-18'
74
77
  - '2015-02-19'
75
78
  - '2015-02-20'
76
79
  - '2015-02-21'
77
80
  - '2015-02-22'
78
81
  - '2015-02-23'
79
82
  - '2015-02-24'
80
- - '2015-02-25'
81
83
  - '2015-04-05'
82
84
  - '2015-04-06'
83
- - '2015-04-07'
84
85
  - '2015-05-01'
85
- - '2015-05-02'
86
- - '2015-05-03'
87
- - '2015-06-20'
88
- - '2015-06-21'
89
86
  - '2015-06-22'
90
87
  - '2015-09-27'
91
- - '2015-09-28'
92
- - '2015-09-29'
93
88
  - '2015-10-01'
94
89
  - '2015-10-02'
95
90
  - '2015-10-03'
@@ -97,6 +92,34 @@ CN:
97
92
  - '2015-10-05'
98
93
  - '2015-10-06'
99
94
  - '2015-10-07'
95
+ - '2016-01-01'
96
+ - '2016-01-02'
97
+ - '2016-01-03'
98
+ - '2016-02-18'
99
+ - '2016-02-19'
100
+ - '2016-02-20'
101
+ - '2016-02-21'
102
+ - '2016-02-22'
103
+ - '2016-02-23'
104
+ - '2016-02-24'
105
+ - '2016-04-05'
106
+ - '2016-04-06'
107
+ - '2016-05-01'
108
+ - '2016-05-02'
109
+ - '2016-05-03'
110
+ - '2016-06-20'
111
+ - '2016-06-21'
112
+ - '2016-06-22'
113
+ - '2016-09-27'
114
+ - '2016-09-28'
115
+ - '2016-09-29'
116
+ - '2016-10-01'
117
+ - '2016-10-02'
118
+ - '2016-10-03'
119
+ - '2016-10-04'
120
+ - '2016-10-05'
121
+ - '2016-10-06'
122
+ - '2016-10-07'
100
123
  additions_only: true
101
124
  holiday_names: [] # Not needed cause all holidays are via manual +additions+
102
125
 
@@ -1,3 +1,3 @@
1
1
  module BusinessCalendar
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -20,7 +20,7 @@ describe "BR bank holidays" do
20
20
  2015-12-25
21
21
  ).map { |x| Date.parse x }.each do |expected_holiday|
22
22
  it "treats #{expected_holiday} as a holiday" do
23
- BusinessCalendar.for(:BR).is_holiday?(expected_holiday).should be_true
23
+ expect(BusinessCalendar.for(:BR).is_holiday?(expected_holiday)).to be true
24
24
  end
25
25
  end
26
26
 
@@ -31,7 +31,7 @@ describe "BR bank holidays" do
31
31
  2014-03-04
32
32
  ).map { |x| Date.parse x }.each do |date|
33
33
  it "treats #{date} as not a holiday" do
34
- BusinessCalendar.for(:BR).is_holiday?(date).should be_false
34
+ expect(BusinessCalendar.for(:BR).is_holiday?(date)).to be false
35
35
  end
36
36
  end
37
37
  end
@@ -30,25 +30,20 @@ describe "CN holidays" do
30
30
  2014-10-06
31
31
  2014-10-07
32
32
  2015-01-01
33
+ 2015-01-02
34
+ 2015-01-03
35
+ 2015-02-18
33
36
  2015-02-19
34
37
  2015-02-20
35
38
  2015-02-21
36
39
  2015-02-22
37
40
  2015-02-23
38
41
  2015-02-24
39
- 2015-02-25
40
42
  2015-04-05
41
43
  2015-04-06
42
- 2015-04-07
43
44
  2015-05-01
44
- 2015-05-02
45
- 2015-05-03
46
- 2015-06-20
47
- 2015-06-21
48
45
  2015-06-22
49
46
  2015-09-27
50
- 2015-09-28
51
- 2015-09-29
52
47
  2015-10-01
53
48
  2015-10-02
54
49
  2015-10-03
@@ -56,9 +51,37 @@ describe "CN holidays" do
56
51
  2015-10-05
57
52
  2015-10-06
58
53
  2015-10-07
54
+ 2016-01-01
55
+ 2016-01-02
56
+ 2016-01-03
57
+ 2016-02-18
58
+ 2016-02-19
59
+ 2016-02-20
60
+ 2016-02-21
61
+ 2016-02-22
62
+ 2016-02-23
63
+ 2016-02-24
64
+ 2016-04-05
65
+ 2016-04-06
66
+ 2016-05-01
67
+ 2016-05-02
68
+ 2016-05-03
69
+ 2016-06-20
70
+ 2016-06-21
71
+ 2016-06-22
72
+ 2016-09-27
73
+ 2016-09-28
74
+ 2016-09-29
75
+ 2016-10-01
76
+ 2016-10-02
77
+ 2016-10-03
78
+ 2016-10-04
79
+ 2016-10-05
80
+ 2016-10-06
81
+ 2016-10-07
59
82
  ).map { |x| Date.parse x }.each do |expected_holiday|
60
83
  it "treats #{expected_holiday} as a holiday" do
61
- BusinessCalendar.for(:CN).is_holiday?(expected_holiday).should be_true
84
+ expect(BusinessCalendar.for(:CN).is_holiday?(expected_holiday)).to be true
62
85
  end
63
86
  end
64
87
  end
@@ -20,7 +20,7 @@ describe "GB bank holidays" do
20
20
  2015-12-28
21
21
  ).map { |x| Date.parse x }.each do |expected_holiday|
22
22
  it "treats #{expected_holiday} as a holiday" do
23
- BusinessCalendar.for(:GB).is_holiday?(expected_holiday).should be_true
23
+ expect(BusinessCalendar.for(:GB).is_holiday?(expected_holiday)).to be true
24
24
  end
25
25
  end
26
26
 
@@ -28,7 +28,7 @@ describe "GB bank holidays" do
28
28
  2012-05-28
29
29
  ).map { |x| Date.parse x }.each do |date|
30
30
  it "treats #{date} as not a holiday" do
31
- BusinessCalendar.for(:GB).is_holiday?(date).should be_false
31
+ expect(BusinessCalendar.for(:GB).is_holiday?(date)).to be false
32
32
  end
33
33
  end
34
34
  end
@@ -42,7 +42,7 @@ describe "US holidays" do
42
42
  2018-01-01
43
43
  ).map { |x| Date.parse x }.each do |expected_holiday|
44
44
  it "treats #{expected_holiday} as a holiday" do
45
- BusinessCalendar.for(:US).is_holiday?(expected_holiday).should be_true
45
+ expect(BusinessCalendar.for(:US).is_holiday?(expected_holiday)).to be true
46
46
  end
47
47
  end
48
48
  end
@@ -6,8 +6,8 @@ describe BusinessCalendar::HolidayDeterminer do
6
6
  subject { BusinessCalendar::HolidayDeterminer.new(regions, ["Independence Day"], opts) }
7
7
 
8
8
  it "initializes with list of regions and a list of accepted holidays" do
9
- subject.regions.should == regions
10
- subject.holiday_names.should == ["Independence Day"]
9
+ expect(subject.regions).to eq regions
10
+ expect(subject.holiday_names).to eq ["Independence Day"]
11
11
  end
12
12
 
13
13
  it "knows which dates are holidays" do
@@ -15,7 +15,7 @@ describe BusinessCalendar::HolidayDeterminer do
15
15
  (Date.today.year - 1 .. Date.today.year + 10).each do |year|
16
16
  fourth = Date.new year, 7, 4
17
17
  obs_date = fourth.sunday? ? fourth + 1 : (fourth.saturday? ? fourth - 1 : fourth)
18
- subject.call(obs_date).should be_true
18
+ expect(subject.call(obs_date)).to be true
19
19
  end
20
20
  end
21
21
 
@@ -26,11 +26,11 @@ describe BusinessCalendar::HolidayDeterminer do
26
26
  }}
27
27
 
28
28
  it "correctly determines false for the exceptions" do
29
- subject.call('2101-07-04'.to_date).should be_false
29
+ expect(subject.call('2101-07-04'.to_date)).to be false
30
30
  end
31
31
 
32
32
  it "correctly determines true for the additions" do
33
- subject.call('2101-07-05'.to_date).should be_true
33
+ expect(subject.call('2101-07-05'.to_date)).to be true
34
34
  end
35
35
  end
36
36
 
@@ -41,11 +41,11 @@ describe BusinessCalendar::HolidayDeterminer do
41
41
  }}
42
42
 
43
43
  it "correctly determines true for the additions" do
44
- subject.call('2101-07-05'.to_date).should be_true
44
+ expect(subject.call('2101-07-05'.to_date)).to be true
45
45
  end
46
46
 
47
47
  it "correctly determines false for dates not in additions, nor exceptions" do
48
- subject.call('2101-07-04'.to_date).should be_false
48
+ expect(subject.call('2101-07-04'.to_date)).to be_falsy
49
49
  end
50
50
  end
51
51
  end
@@ -6,72 +6,72 @@ describe BusinessCalendar do
6
6
 
7
7
  shared_examples_for "standard business time" do
8
8
  specify "a weekend is not a business day" do
9
- subject.is_business_day?('2014-03-09'.to_date).should be_false
9
+ expect(subject.is_business_day?('2014-03-09'.to_date)).to be false
10
10
  end
11
11
 
12
12
  specify "a normal weekday is a business day" do
13
- subject.is_business_day?('2014-03-10'.to_date).should be_true
13
+ expect(subject.is_business_day?('2014-03-10'.to_date)).to be true
14
14
  end
15
15
 
16
16
  specify 'the nearest business day to monday is monday in both directions' do
17
- subject.nearest_business_day('2014-03-10'.to_date) .should == '2014-03-10'.to_date
18
- subject.nearest_business_day('2014-03-10'.to_date, :backward) .should == '2014-03-10'.to_date
19
- subject.nearest_business_day('2014-03-10'.to_date, :forward) .should == '2014-03-10'.to_date
17
+ expect(subject.nearest_business_day('2014-03-10'.to_date)).to eq '2014-03-10'.to_date
18
+ expect(subject.nearest_business_day('2014-03-10'.to_date, :backward)).to eq '2014-03-10'.to_date
19
+ expect(subject.nearest_business_day('2014-03-10'.to_date, :forward)).to eq '2014-03-10'.to_date
20
20
  end
21
21
 
22
22
  specify 'the nearest business day to a saturday, forward, is monday' do
23
- subject.nearest_business_day('2014-03-08'.to_date) .should == '2014-03-10'.to_date
24
- subject.nearest_business_day('2014-03-08'.to_date, :forward).should == '2014-03-10'.to_date
23
+ expect(subject.nearest_business_day('2014-03-08'.to_date)).to eq '2014-03-10'.to_date
24
+ expect(subject.nearest_business_day('2014-03-08'.to_date, :forward)).to eq '2014-03-10'.to_date
25
25
  end
26
26
 
27
27
  specify 'the nearest business day to a saturday, backward, is friday' do
28
- subject.nearest_business_day('2014-03-08'.to_date, :backward).should == '2014-03-07'.to_date
28
+ expect(subject.nearest_business_day('2014-03-08'.to_date, :backward)).to eq '2014-03-07'.to_date
29
29
  end
30
30
 
31
31
  specify 'one business day added to a monday is the next day' do
32
- subject.add_business_day('2014-03-10'.to_date).should == '2014-03-11'.to_date
32
+ expect(subject.add_business_day('2014-03-10'.to_date)).to eq '2014-03-11'.to_date
33
33
  end
34
34
 
35
35
  specify 'one business day added to a friday is the coming monday' do
36
- subject.add_business_day('2014-03-07'.to_date).should == '2014-03-10'.to_date
36
+ expect(subject.add_business_day('2014-03-07'.to_date)).to eq '2014-03-10'.to_date
37
37
  end
38
38
 
39
39
  specify 'one business day added to a weekend is the coming tuesday' do
40
- subject.add_business_day('2014-03-08'.to_date).should == '2014-03-11'.to_date
40
+ expect(subject.add_business_day('2014-03-08'.to_date)).to eq '2014-03-11'.to_date
41
41
  end
42
42
 
43
43
  specify 'one business day added to a monday as well as a tuesday is tuesday and wednesday' do
44
44
  d1, d2 = subject.add_business_days ['2014-03-10'.to_date, '2014-03-11'.to_date]
45
- d1.should == '2014-03-11'.to_date
46
- d2.should == '2014-03-12'.to_date
45
+ expect(d1).to eq '2014-03-11'.to_date
46
+ expect(d2).to eq '2014-03-12'.to_date
47
47
  end
48
48
 
49
49
  specify 'the following business day of a saturday is the coming monday' do
50
- subject.following_business_day('2014-03-08'.to_date).should == '2014-03-10'.to_date
50
+ expect(subject.following_business_day('2014-03-08'.to_date)).to eq '2014-03-10'.to_date
51
51
  end
52
52
 
53
53
  specify 'a saturday plus zero business days is the nearest business day, monday' do
54
- subject.add_business_days('2014-03-08'.to_date, 0).should == '2014-03-10'.to_date
54
+ expect(subject.add_business_days('2014-03-08'.to_date, 0)).to eq '2014-03-10'.to_date
55
55
  end
56
56
 
57
57
  specify 'a saturday plus zero business days with initial direction backward is the nearest preceding business day, friday' do
58
- subject.add_business_days('2014-03-08'.to_date, 0, :backward).should == '2014-03-07'.to_date
58
+ expect(subject.add_business_days('2014-03-08'.to_date, 0, :backward)).to eq '2014-03-07'.to_date
59
59
  end
60
60
 
61
61
  specify 'the following business day of a monday is tuesday' do
62
- subject.following_business_day('2014-03-10'.to_date).should == '2014-03-11'.to_date
62
+ expect(subject.following_business_day('2014-03-10'.to_date)).to eq '2014-03-11'.to_date
63
63
  end
64
64
 
65
65
  specify 'the preceding business day of a monday is friday' do
66
- subject.preceding_business_day('2014-03-10'.to_date).should == '2014-03-07'.to_date
66
+ expect(subject.preceding_business_day('2014-03-10'.to_date)).to eq '2014-03-07'.to_date
67
67
  end
68
68
 
69
69
  specify 'a monday less three business days is the previous wednesday' do
70
- subject.add_business_days('2014-03-10'.to_date, -3).should == '2014-03-05'.to_date
70
+ expect(subject.add_business_days('2014-03-10'.to_date, -3)).to eq '2014-03-05'.to_date
71
71
  end
72
72
 
73
73
  specify 'a saturday less one business day is the previous friday' do
74
- subject.subtract_business_day('2014-03-08'.to_date).should == '2014-03-07'.to_date
74
+ expect(subject.subtract_business_day('2014-03-08'.to_date)).to eq '2014-03-07'.to_date
75
75
  end
76
76
  end
77
77
 
@@ -81,7 +81,7 @@ describe BusinessCalendar do
81
81
  it_behaves_like "standard business time"
82
82
 
83
83
  specify "American Independence Day is not a business day" do
84
- subject.is_business_day?('2014-07-04'.to_date).should be_false
84
+ expect(subject.is_business_day?('2014-07-04'.to_date)).to be false
85
85
  end
86
86
  end
87
87
 
@@ -91,11 +91,11 @@ describe BusinessCalendar do
91
91
  it_behaves_like "standard business time"
92
92
 
93
93
  specify "American Independence Day is a business day" do
94
- subject.is_business_day?('2014-07-04'.to_date).should be_true
94
+ expect(subject.is_business_day?('2014-07-04'.to_date)).to be true
95
95
  end
96
96
 
97
97
  specify 'Boxing Day is observed on a weekday' do
98
- subject.is_business_day?('2015-12-28'.to_date).should be_false
98
+ expect(subject.is_business_day?('2015-12-28'.to_date)).to be false
99
99
  end
100
100
  end
101
101
 
metadata CHANGED
@@ -1,83 +1,126 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: business_calendar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Robert Nubel
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-05-23 00:00:00.000000000 Z
12
+ date: 2015-02-09 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: holidays
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
- - - "~>"
19
+ - - ~>
18
20
  - !ruby/object:Gem::Version
19
21
  version: '1.0'
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
- - - "~>"
27
+ - - ~>
25
28
  - !ruby/object:Gem::Version
26
29
  version: '1.0'
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: bundler
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
- - - "~>"
35
+ - - ~>
32
36
  - !ruby/object:Gem::Version
33
37
  version: '1.3'
34
38
  type: :development
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
- - - "~>"
43
+ - - ~>
39
44
  - !ruby/object:Gem::Version
40
45
  version: '1.3'
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: rake
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
- - - ">="
51
+ - - ! '>='
46
52
  - !ruby/object:Gem::Version
47
53
  version: '0'
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
- - - ">="
59
+ - - ! '>='
53
60
  - !ruby/object:Gem::Version
54
61
  version: '0'
55
62
  - !ruby/object:Gem::Dependency
56
- name: rspec
63
+ name: pry
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: pry-debugger
57
80
  requirement: !ruby/object:Gem::Requirement
81
+ none: false
58
82
  requirements:
59
- - - ">="
83
+ - - ! '>='
60
84
  - !ruby/object:Gem::Version
61
85
  version: '0'
62
86
  type: :development
63
87
  prerelease: false
64
88
  version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
65
90
  requirements:
66
- - - ">="
91
+ - - ! '>='
67
92
  - !ruby/object:Gem::Version
68
93
  version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: rspec
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: '3.2'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: '3.2'
69
110
  - !ruby/object:Gem::Dependency
70
111
  name: timecop
71
112
  requirement: !ruby/object:Gem::Requirement
113
+ none: false
72
114
  requirements:
73
- - - ">="
115
+ - - ! '>='
74
116
  - !ruby/object:Gem::Version
75
117
  version: '0'
76
118
  type: :development
77
119
  prerelease: false
78
120
  version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
79
122
  requirements:
80
- - - ">="
123
+ - - ! '>='
81
124
  - !ruby/object:Gem::Version
82
125
  version: '0'
83
126
  description: Helper gem for dealing with business days and date adjustment in multiple
@@ -88,8 +131,8 @@ executables: []
88
131
  extensions: []
89
132
  extra_rdoc_files: []
90
133
  files:
91
- - ".gitignore"
92
- - ".rspec"
134
+ - .gitignore
135
+ - .rspec
93
136
  - Gemfile
94
137
  - LICENSE.txt
95
138
  - README.md
@@ -110,26 +153,33 @@ files:
110
153
  homepage: ''
111
154
  licenses:
112
155
  - MIT
113
- metadata: {}
114
156
  post_install_message:
115
157
  rdoc_options: []
116
158
  require_paths:
117
159
  - lib
118
160
  required_ruby_version: !ruby/object:Gem::Requirement
161
+ none: false
119
162
  requirements:
120
- - - ">="
163
+ - - ! '>='
121
164
  - !ruby/object:Gem::Version
122
165
  version: '0'
166
+ segments:
167
+ - 0
168
+ hash: -788360373610172520
123
169
  required_rubygems_version: !ruby/object:Gem::Requirement
170
+ none: false
124
171
  requirements:
125
- - - ">="
172
+ - - ! '>='
126
173
  - !ruby/object:Gem::Version
127
174
  version: '0'
175
+ segments:
176
+ - 0
177
+ hash: -788360373610172520
128
178
  requirements: []
129
179
  rubyforge_project:
130
- rubygems_version: 2.2.0
180
+ rubygems_version: 1.8.23
131
181
  signing_key:
132
- specification_version: 4
182
+ specification_version: 3
133
183
  summary: Country-aware business-date logic and handling.
134
184
  test_files:
135
185
  - spec/acceptance_br_spec.rb
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: d352073cba3980654ef7cbcd0acbbd1bc0e080b2
4
- data.tar.gz: 6f7462eed85e8198eac0508cfafd96fa3c8e0289
5
- SHA512:
6
- metadata.gz: 173699885a116dbffea3fb7556c7f64cc22b03146528b1cb9cbcbc18918e412f4a73e656f69408afa9524f42db664be61783ad1800be311343954a9e4adae3b8
7
- data.tar.gz: f4eaef2695e82cc87fe6d4309bb4fef56d1bf3e3dbf8da9c7f0be2ae342b0e75d6bb6b308a8985fbe50abfac634f895bc0d7c4d50c1d7bd50b6832e4455c7cc6