work_days 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 76a33459c3f10963229fca52b563cfafee50e726
4
+ data.tar.gz: 000a737240d1f3ac3aa37b47b7d8a5157e93308d
5
+ SHA512:
6
+ metadata.gz: 2c4dc00162f2b032eedc4040a4e734e62633c94645d615da225439e99b4f8ca5db0b441ea32de9fb39bee2bceb6164ca9eb633acf16ee5e07364b585032d8a2f
7
+ data.tar.gz: 1e635eba2a16e13d621c948c8ac78c8dbdb2e2bca1e1e5d250e932a157fb31861b84f406c1ade7b22bc38733e53acc0661cf7fe1498c8d57cef3f728dced236d
data/.travis.yml ADDED
@@ -0,0 +1,10 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ script: rspec
5
+ notifications:
6
+ irc:
7
+ channels:
8
+ - "chat.freenode.net#rwjblue"
9
+ on_success: always
10
+ on_failure: always
data/Gemfile CHANGED
@@ -4,6 +4,5 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  gem 'pry'
7
- gem 'rspec'
8
7
  gem 'guard-rspec'
9
8
  gem 'rb-fsevent'
data/README.md CHANGED
@@ -18,13 +18,13 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- Use your own custom work schedule by creating a class implementing
21
+ Use your own custom work schedule by creating a class implementing
22
22
  your custom holiday methods and including the WorkDays::CalculationMethods module
23
- (and optionally the WorkDays::HolidayMethods module for a few of the presets).
23
+ (and optionally the WorkDays::HolidayMethods module for a few of the presets).
24
24
 
25
25
  class SampleSchedule
26
- WorkDays::CalculationMethods
27
- WorkDays::HolidayMethods
26
+ include WorkDays::CalculationMethods
27
+ include WorkDays::HolidayMethods
28
28
 
29
29
  def observed_holidays
30
30
  [:new_years_day, :christmas_day]
@@ -53,6 +53,10 @@ on the WorkDays module (as long as you set the WorkDays.work_schedule).
53
53
  * Returns an array of the work days between the start and end dates.
54
54
  * work_days_in_month(date)
55
55
  * Returns an array of the work days for the year and month of the passed in date.
56
+ * holiday?(date)
57
+ * Returns true for any date that is an observed holiday.
58
+ * holidays_in_range(start_date, end_date)
59
+ * Returns an array of the holidays between the start and end dates.
56
60
 
57
61
  ## Contributing
58
62
 
@@ -32,6 +32,16 @@ module WorkDays::CalculationMethods
32
32
  working_days
33
33
  end
34
34
 
35
+ def holidays_in_range(start, stop)
36
+ holidays = []
37
+
38
+ (start.to_date..stop.to_date).each do |date|
39
+ holidays << date if holiday?(date)
40
+ end
41
+
42
+ holidays
43
+ end
44
+
35
45
  def work_days_in_month(date)
36
46
  start_date = Date.new(date.year, date.month, 1)
37
47
  end_date = Date.new(date.year, date.month, -1)
@@ -1,3 +1,3 @@
1
1
  module WorkDays
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -105,6 +105,24 @@ describe WorkDays::CalculationMethods, :type => :holiday_helpers do
105
105
  end
106
106
  end
107
107
 
108
+ context "#holidays_in_range" do
109
+ let(:start_date) {random_date}
110
+ let(:end_date) {start_date + rand(45)}
111
+
112
+ it "should return an array of the observed holidays between two dates" do
113
+ valid_holidays = []
114
+
115
+ (start_date..end_date).each do |date|
116
+ holiday = random_boolean
117
+
118
+ valid_holidays << date if holiday
119
+ subject.should_receive(:holiday?).with(date).and_return(holiday)
120
+ end
121
+
122
+ subject.holidays_in_range(start_date, end_date).should eq(valid_holidays)
123
+ end
124
+ end
125
+
108
126
  context "#work_days_in_month" do
109
127
  let(:date) {random_date}
110
128
  let(:range_start_date) {Date.new(date.year, date.month, 1)}
data/work_days.gemspec CHANGED
@@ -2,9 +2,10 @@
2
2
  require File.expand_path('../lib/work_days/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
+ gem.license = 'MIT'
5
6
  gem.authors = ["Robert Jackson"]
6
- gem.email = ["robertj@promedicalinc.com"]
7
- gem.description = %q{Calculate the number of business days in a given period. Also, add convenience methods to Range, Date, DateTime, and Time.}
7
+ gem.email = ["robert.w.jackson@me.com"]
8
+ gem.description = %q{Calculate the number of work days in a given period. Also, add convenience methods to Range, Date, DateTime, and Time.}
8
9
  gem.summary = %q{Simple business day calculations.}
9
10
  gem.homepage = "https://github.com/rjackson/work_days"
10
11
 
@@ -15,5 +16,5 @@ Gem::Specification.new do |gem|
15
16
  gem.require_paths = ["lib"]
16
17
  gem.version = WorkDays::VERSION
17
18
 
18
- gem.add_development_dependency 'rspec'
19
+ gem.add_development_dependency 'rspec', '~> 2.14'
19
20
  end
metadata CHANGED
@@ -1,42 +1,40 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: work_days
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
5
- prerelease:
4
+ version: 0.0.4
6
5
  platform: ruby
7
6
  authors:
8
7
  - Robert Jackson
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-12-31 00:00:00.000000000 Z
11
+ date: 2014-04-28 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rspec
16
- prerelease: false
17
15
  requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ! '>='
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
- version: '0'
22
- none: false
19
+ version: '2.14'
23
20
  type: :development
21
+ prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
23
  requirements:
26
- - - ! '>='
24
+ - - "~>"
27
25
  - !ruby/object:Gem::Version
28
- version: '0'
29
- none: false
30
- description: Calculate the number of business days in a given period. Also, add convenience
26
+ version: '2.14'
27
+ description: Calculate the number of work days in a given period. Also, add convenience
31
28
  methods to Range, Date, DateTime, and Time.
32
29
  email:
33
- - robertj@promedicalinc.com
30
+ - robert.w.jackson@me.com
34
31
  executables: []
35
32
  extensions: []
36
33
  extra_rdoc_files: []
37
34
  files:
38
- - .gitignore
39
- - .rspec
35
+ - ".gitignore"
36
+ - ".rspec"
37
+ - ".travis.yml"
40
38
  - Gemfile
41
39
  - Guardfile
42
40
  - LICENSE
@@ -67,28 +65,28 @@ files:
67
65
  - spec/support/work_day_proxy.rb
68
66
  - work_days.gemspec
69
67
  homepage: https://github.com/rjackson/work_days
70
- licenses: []
68
+ licenses:
69
+ - MIT
70
+ metadata: {}
71
71
  post_install_message:
72
72
  rdoc_options: []
73
73
  require_paths:
74
74
  - lib
75
75
  required_ruby_version: !ruby/object:Gem::Requirement
76
76
  requirements:
77
- - - ! '>='
77
+ - - ">="
78
78
  - !ruby/object:Gem::Version
79
79
  version: '0'
80
- none: false
81
80
  required_rubygems_version: !ruby/object:Gem::Requirement
82
81
  requirements:
83
- - - ! '>='
82
+ - - ">="
84
83
  - !ruby/object:Gem::Version
85
84
  version: '0'
86
- none: false
87
85
  requirements: []
88
86
  rubyforge_project:
89
- rubygems_version: 1.8.24
87
+ rubygems_version: 2.2.0
90
88
  signing_key:
91
- specification_version: 3
89
+ specification_version: 4
92
90
  summary: Simple business day calculations.
93
91
  test_files:
94
92
  - spec/lib/work_days/calculation_methods_spec.rb