is_business_day 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.md +5 -3
  3. data/lib/is_business_day.rb +19 -4
  4. data/lib/is_business_day/business_days.rb +11 -0
  5. data/lib/is_business_day/business_days/calculations.rb +29 -0
  6. data/lib/is_business_day/business_days/tests.rb +17 -0
  7. data/lib/is_business_day/christmas.rb +15 -0
  8. data/lib/is_business_day/christmas/day/calculations.rb +23 -0
  9. data/lib/is_business_day/christmas/day/tests.rb +21 -0
  10. data/lib/is_business_day/christmas/eve/calculations.rb +23 -0
  11. data/lib/is_business_day/christmas/eve/tests.rb +21 -0
  12. data/lib/is_business_day/fourth_of_july.rb +11 -0
  13. data/lib/is_business_day/fourth_of_july/calculations.rb +19 -0
  14. data/lib/is_business_day/fourth_of_july/tests.rb +17 -0
  15. data/lib/is_business_day/helpers.rb +53 -0
  16. data/lib/is_business_day/holidays.rb +31 -0
  17. data/lib/is_business_day/labor_day.rb +11 -0
  18. data/lib/is_business_day/labor_day/calculations.rb +22 -0
  19. data/lib/is_business_day/labor_day/tests.rb +18 -0
  20. data/lib/is_business_day/memorial_day.rb +11 -0
  21. data/lib/is_business_day/memorial_day/calculations.rb +24 -0
  22. data/lib/is_business_day/memorial_day/tests.rb +22 -0
  23. data/lib/is_business_day/new_years_day.rb +11 -0
  24. data/lib/is_business_day/new_years_day/calculations.rb +19 -0
  25. data/lib/is_business_day/new_years_day/tests.rb +17 -0
  26. data/lib/is_business_day/thanksgiving.rb +12 -0
  27. data/lib/is_business_day/thanksgiving/calculations.rb +24 -0
  28. data/lib/is_business_day/thanksgiving/tests.rb +22 -0
  29. data/lib/is_business_day/version.rb +1 -1
  30. data/spec/is_business_day/christmas_spec.rb +147 -0
  31. data/spec/is_business_day/fourth_of_july_spec.rb +70 -0
  32. data/spec/is_business_day/is_business_day_spec.rb +50 -0
  33. data/spec/is_business_day/labor_day_spec.rb +78 -0
  34. data/spec/is_business_day/memorial_day_spec.rb +73 -0
  35. data/spec/is_business_day/new_years_day_spec.rb +65 -0
  36. data/spec/is_business_day/thanksgiving_spec.rb +73 -0
  37. data/spec/spec_helper.rb +14 -0
  38. metadata +95 -36
  39. data/.gitignore +0 -4
  40. data/.travis.yml +0 -5
  41. data/Gemfile +0 -4
  42. data/Guardfile +0 -4
  43. data/is_business_day.gemspec +0 -26
  44. data/lib/is_business_day/active_support/core_ext/date/calculations.rb +0 -6
  45. data/lib/is_business_day/active_support/core_ext/time/calculations.rb +0 -6
  46. data/lib/is_business_day/digitalopera/business_day_calculations.rb +0 -55
  47. data/lib/is_business_day/digitalopera/holiday_calculations.rb +0 -130
  48. data/lib/rails/generators/is_business_day/install/install_generator.rb +0 -16
  49. data/lib/rails/generators/is_business_day/install/templates/is_business_day.rb +0 -1
  50. data/spec/active_support/core_ext/date/calculations_spec.rb +0 -165
  51. data/spec/active_support/core_ext/time/calculations_spec.rb +0 -165
@@ -0,0 +1,73 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'memorial day' do
4
+ let(:some_date){ Date.parse("06/06/1979") }
5
+ let(:some_time){ Time.parse("06/06/1979 6:45pm") }
6
+ let(:date){ Date.memorial_day }
7
+ let(:time){ Time.memorial_day }
8
+
9
+ it 'should return the correct object types' do
10
+ expect(date).to be_a Date
11
+ expect(time).to be_a Time
12
+ end
13
+
14
+ describe Date do
15
+ context 'Class' do
16
+ let(:may){ Date.parse("05/01/#{ date.year }") }
17
+ let(:last_monday){ may.get_all_specific_days_in_month(:monday).last }
18
+ subject{ date }
19
+
20
+ its(:month){ should be 5 }
21
+ its(:day){ should be last_monday.day }
22
+ its(:year){ should be Date.today.year }
23
+ its(:is_a_holiday?){ should be_true }
24
+ its(:is_memorial_day?){ should be_true }
25
+ its(:is_not_memorial_day?){ should be_false }
26
+ its(:is_a_business_day?){ should be_false }
27
+ end
28
+
29
+ context 'instance' do
30
+ let(:may){ Date.parse("05/01/#{ some_date.year }") }
31
+ let(:last_monday){ may.get_all_specific_days_in_month(:monday).last }
32
+ subject{ some_date.memorial_day }
33
+
34
+ its(:month){ should be 5 }
35
+ its(:day){ should be last_monday.day }
36
+ its(:year){ should be some_date.year }
37
+ its(:is_a_holiday?){ should be_true }
38
+ its(:is_memorial_day?){ should be_true }
39
+ its(:is_not_memorial_day?){ should be_false }
40
+ its(:is_a_business_day?){ should be_false }
41
+ end
42
+ end
43
+
44
+ describe Time do
45
+ context 'Class' do
46
+ let(:may){ Date.parse("05/01/#{ time.year }") }
47
+ let(:last_monday){ may.get_all_specific_days_in_month(:monday).last }
48
+ subject{ time }
49
+
50
+ its(:month){ should be 5 }
51
+ its(:day){ should be last_monday.day }
52
+ its(:year){ should be Date.today.year }
53
+ its(:is_a_holiday?){ should be_true }
54
+ its(:is_memorial_day?){ should be_true }
55
+ its(:is_not_memorial_day?){ should be_false }
56
+ its(:is_a_business_day?){ should be_false }
57
+ end
58
+
59
+ context 'instance' do
60
+ let(:may){ Date.parse("05/01/#{ some_time.year }") }
61
+ let(:last_monday){ may.get_all_specific_days_in_month(:monday).last }
62
+ subject{ some_time.memorial_day }
63
+
64
+ its(:month){ should be 5 }
65
+ its(:day){ should be last_monday.day }
66
+ its(:year){ should be some_date.year }
67
+ its(:is_a_holiday?){ should be_true }
68
+ its(:is_memorial_day?){ should be_true }
69
+ its(:is_not_memorial_day?){ should be_false }
70
+ its(:is_a_business_day?){ should be_false }
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,65 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'new years day' do
4
+ let(:some_date){ Date.parse("06/06/1979") }
5
+ let(:some_time){ Time.parse("06/06/1979 6:45pm") }
6
+ let(:date){ Date.new_years_day }
7
+ let(:time){ Time.new_years_day }
8
+
9
+ it 'should return the correct object types' do
10
+ expect(date).to be_a Date
11
+ expect(time).to be_a Time
12
+ end
13
+
14
+ describe Date do
15
+ context 'Class' do
16
+ subject{ date }
17
+
18
+ its(:month){ should be 1 }
19
+ its(:day){ should be 1 }
20
+ its(:year){ should be Date.today.year }
21
+ its(:is_a_holiday?){ should be_true }
22
+ its(:is_new_years_day?){ should be_true }
23
+ its(:is_not_new_years_day?){ should be_false }
24
+ its(:is_a_business_day?){ should be_false }
25
+ end
26
+
27
+ context 'instance' do
28
+ subject{ some_date.new_years_day }
29
+
30
+ its(:month){ should be 1 }
31
+ its(:day){ should be 1 }
32
+ its(:year){ should be some_date.year }
33
+ its(:is_a_holiday?){ should be_true }
34
+ its(:is_new_years_day?){ should be_true }
35
+ its(:is_not_new_years_day?){ should be_false }
36
+ its(:is_a_business_day?){ should be_false }
37
+ end
38
+ end
39
+
40
+ describe Time do
41
+ context 'Class' do
42
+ subject{ time }
43
+
44
+ its(:month){ should be 1 }
45
+ its(:day){ should be 1 }
46
+ its(:year){ should be Date.today.year }
47
+ its(:is_a_holiday?){ should be_true }
48
+ its(:is_new_years_day?){ should be_true }
49
+ its(:is_not_new_years_day?){ should be_false }
50
+ its(:is_a_business_day?){ should be_false }
51
+ end
52
+
53
+ context 'instance' do
54
+ subject{ some_time.new_years_day }
55
+
56
+ its(:month){ should be 1 }
57
+ its(:day){ should be 1 }
58
+ its(:year){ should be some_time.year }
59
+ its(:is_a_holiday?){ should be_true }
60
+ its(:is_new_years_day?){ should be_true }
61
+ its(:is_not_new_years_day?){ should be_false }
62
+ its(:is_a_business_day?){ should be_false }
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,73 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'thanksgiving day' do
4
+ let(:some_date){ Date.parse("06/06/1979") }
5
+ let(:some_time){ Time.parse("06/06/1979 6:45pm") }
6
+ let(:date){ Date.thanksgiving_day }
7
+ let(:time){ Time.thanksgiving_day }
8
+
9
+ it 'should return the correct object types' do
10
+ expect(date).to be_a Date
11
+ expect(time).to be_a Time
12
+ end
13
+
14
+ describe Date do
15
+ context 'Class' do
16
+ let(:november){ Date.parse("11/01/#{ date.year }") }
17
+ let(:last_thursday){ november.get_all_specific_days_in_month(:thursday).last }
18
+ subject{ date }
19
+
20
+ its(:month){ should be 11 }
21
+ its(:day){ should be last_thursday.day }
22
+ its(:year){ should be Date.today.year }
23
+ its(:is_a_holiday?){ should be_true }
24
+ its(:is_thanksgiving_day?){ should be_true }
25
+ its(:is_not_thanksgiving_day?){ should be_false }
26
+ its(:is_a_business_day?){ should be_false }
27
+ end
28
+
29
+ context 'instance' do
30
+ let(:november){ Date.parse("11/01/#{ some_date.year }") }
31
+ let(:last_thursday){ november.get_all_specific_days_in_month(:thursday).last }
32
+ subject{ some_date.thanksgiving_day }
33
+
34
+ its(:month){ should be 11 }
35
+ its(:day){ should be last_thursday.day }
36
+ its(:year){ should be some_date.year }
37
+ its(:is_a_holiday?){ should be_true }
38
+ its(:is_thanksgiving_day?){ should be_true }
39
+ its(:is_not_thanksgiving_day?){ should be_false }
40
+ its(:is_a_business_day?){ should be_false }
41
+ end
42
+ end
43
+
44
+ describe Time do
45
+ context 'Class' do
46
+ let(:november){ Date.parse("11/01/#{ time.year }") }
47
+ let(:last_thursday){ november.get_all_specific_days_in_month(:thursday).last }
48
+ subject{ time }
49
+
50
+ its(:month){ should be 11 }
51
+ its(:day){ should be last_thursday.day }
52
+ its(:year){ should be Date.today.year }
53
+ its(:is_a_holiday?){ should be_true }
54
+ its(:is_thanksgiving_day?){ should be_true }
55
+ its(:is_not_thanksgiving_day?){ should be_false }
56
+ its(:is_a_business_day?){ should be_false }
57
+ end
58
+
59
+ context 'instance' do
60
+ let(:november){ Date.parse("11/01/#{ some_time.year }") }
61
+ let(:last_thursday){ november.get_all_specific_days_in_month(:thursday).last }
62
+ subject{ some_time.thanksgiving_day }
63
+
64
+ its(:month){ should be 11 }
65
+ its(:day){ should be last_thursday.day }
66
+ its(:year){ should be some_time.year }
67
+ its(:is_a_holiday?){ should be_true }
68
+ its(:is_thanksgiving_day?){ should be_true }
69
+ its(:is_not_thanksgiving_day?){ should be_false }
70
+ its(:is_a_business_day?){ should be_false }
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,14 @@
1
+ require 'spork'
2
+ require 'active_support/all'
3
+ require 'american_date'
4
+
5
+ Spork.prefork do
6
+ require 'rspec'
7
+ require 'rspec/autorun'
8
+ require 'is_business_day'
9
+
10
+ # Configure RSpec ---------------------------------------
11
+ RSpec.configure do |config|
12
+ config.order = "random"
13
+ end
14
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: is_business_day
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,32 +9,48 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-30 00:00:00.000000000 Z
12
+ date: 2013-11-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ~>
19
+ - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: '2.6'
21
+ version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - ~>
27
+ - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
- version: '2.6'
29
+ version: '0'
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: guard-rspec
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: guard-spork
32
48
  requirement: !ruby/object:Gem::Requirement
33
49
  none: false
34
50
  requirements:
35
51
  - - ~>
36
52
  - !ruby/object:Gem::Version
37
- version: '0.0'
53
+ version: 1.5.0
38
54
  type: :development
39
55
  prerelease: false
40
56
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,29 +58,29 @@ dependencies:
42
58
  requirements:
43
59
  - - ~>
44
60
  - !ruby/object:Gem::Version
45
- version: '0.0'
61
+ version: 1.5.0
46
62
  - !ruby/object:Gem::Dependency
47
63
  name: rake
48
64
  requirement: !ruby/object:Gem::Requirement
49
65
  none: false
50
66
  requirements:
51
- - - ~>
67
+ - - ! '>='
52
68
  - !ruby/object:Gem::Version
53
- version: 0.9.2
69
+ version: '0'
54
70
  type: :development
55
71
  prerelease: false
56
72
  version_requirements: !ruby/object:Gem::Requirement
57
73
  none: false
58
74
  requirements:
59
- - - ~>
75
+ - - ! '>='
60
76
  - !ruby/object:Gem::Version
61
- version: 0.9.2
77
+ version: '0'
62
78
  - !ruby/object:Gem::Dependency
63
79
  name: activesupport
64
80
  requirement: !ruby/object:Gem::Requirement
65
81
  none: false
66
82
  requirements:
67
- - - ~>
83
+ - - ! '>='
68
84
  - !ruby/object:Gem::Version
69
85
  version: '3.0'
70
86
  type: :runtime
@@ -72,9 +88,25 @@ dependencies:
72
88
  version_requirements: !ruby/object:Gem::Requirement
73
89
  none: false
74
90
  requirements:
75
- - - ~>
91
+ - - ! '>='
76
92
  - !ruby/object:Gem::Version
77
93
  version: '3.0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: american_date
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: 1.1.0
102
+ type: :runtime
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 1.1.0
78
110
  description: Adds some methods to the Ruby Date object for testing whether or not
79
111
  a specific date falls on a valid business day or not
80
112
  email:
@@ -83,25 +115,47 @@ executables: []
83
115
  extensions: []
84
116
  extra_rdoc_files: []
85
117
  files:
86
- - .gitignore
87
- - .travis.yml
88
- - Gemfile
89
- - Guardfile
90
- - README.md
91
- - Rakefile
92
- - is_business_day.gemspec
93
- - lib/is_business_day.rb
94
- - lib/is_business_day/active_support/core_ext/date/calculations.rb
95
- - lib/is_business_day/active_support/core_ext/time/calculations.rb
96
- - lib/is_business_day/digitalopera/business_day_calculations.rb
97
- - lib/is_business_day/digitalopera/holiday_calculations.rb
118
+ - lib/is_business_day/business_days/calculations.rb
119
+ - lib/is_business_day/business_days/tests.rb
120
+ - lib/is_business_day/business_days.rb
121
+ - lib/is_business_day/christmas/day/calculations.rb
122
+ - lib/is_business_day/christmas/day/tests.rb
123
+ - lib/is_business_day/christmas/eve/calculations.rb
124
+ - lib/is_business_day/christmas/eve/tests.rb
125
+ - lib/is_business_day/christmas.rb
126
+ - lib/is_business_day/fourth_of_july/calculations.rb
127
+ - lib/is_business_day/fourth_of_july/tests.rb
128
+ - lib/is_business_day/fourth_of_july.rb
129
+ - lib/is_business_day/helpers.rb
130
+ - lib/is_business_day/holidays.rb
131
+ - lib/is_business_day/labor_day/calculations.rb
132
+ - lib/is_business_day/labor_day/tests.rb
133
+ - lib/is_business_day/labor_day.rb
134
+ - lib/is_business_day/memorial_day/calculations.rb
135
+ - lib/is_business_day/memorial_day/tests.rb
136
+ - lib/is_business_day/memorial_day.rb
137
+ - lib/is_business_day/new_years_day/calculations.rb
138
+ - lib/is_business_day/new_years_day/tests.rb
139
+ - lib/is_business_day/new_years_day.rb
140
+ - lib/is_business_day/thanksgiving/calculations.rb
141
+ - lib/is_business_day/thanksgiving/tests.rb
142
+ - lib/is_business_day/thanksgiving.rb
98
143
  - lib/is_business_day/version.rb
99
- - lib/rails/generators/is_business_day/install/install_generator.rb
100
- - lib/rails/generators/is_business_day/install/templates/is_business_day.rb
101
- - spec/active_support/core_ext/date/calculations_spec.rb
102
- - spec/active_support/core_ext/time/calculations_spec.rb
103
- homepage: ''
104
- licenses: []
144
+ - lib/is_business_day.rb
145
+ - MIT-LICENSE
146
+ - Rakefile
147
+ - README.md
148
+ - spec/is_business_day/christmas_spec.rb
149
+ - spec/is_business_day/fourth_of_july_spec.rb
150
+ - spec/is_business_day/is_business_day_spec.rb
151
+ - spec/is_business_day/labor_day_spec.rb
152
+ - spec/is_business_day/memorial_day_spec.rb
153
+ - spec/is_business_day/new_years_day_spec.rb
154
+ - spec/is_business_day/thanksgiving_spec.rb
155
+ - spec/spec_helper.rb
156
+ homepage: http://www.digitalopera.com/
157
+ licenses:
158
+ - MIT
105
159
  post_install_message:
106
160
  rdoc_options: []
107
161
  require_paths:
@@ -120,11 +174,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
174
  version: '0'
121
175
  requirements: []
122
176
  rubyforge_project: is_business_day
123
- rubygems_version: 1.8.21
177
+ rubygems_version: 1.8.24
124
178
  signing_key:
125
179
  specification_version: 3
126
180
  summary: Simple business day detection
127
181
  test_files:
128
- - spec/active_support/core_ext/date/calculations_spec.rb
129
- - spec/active_support/core_ext/time/calculations_spec.rb
130
- has_rdoc:
182
+ - spec/is_business_day/christmas_spec.rb
183
+ - spec/is_business_day/fourth_of_july_spec.rb
184
+ - spec/is_business_day/is_business_day_spec.rb
185
+ - spec/is_business_day/labor_day_spec.rb
186
+ - spec/is_business_day/memorial_day_spec.rb
187
+ - spec/is_business_day/new_years_day_spec.rb
188
+ - spec/is_business_day/thanksgiving_spec.rb
189
+ - spec/spec_helper.rb
data/.gitignore DELETED
@@ -1,4 +0,0 @@
1
- *.gem
2
- .bundle
3
- Gemfile.lock
4
- pkg/*
@@ -1,5 +0,0 @@
1
- rvm:
2
- - 1.9.2
3
- - 1.9.3
4
- before_script: bundle exec rspec spec
5
- script: rake build