nextday 0.2.0 → 0.3.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.
- data/.gitignore +2 -1
- data/.travis.yml +2 -0
- data/Gemfile +0 -11
- data/README.md +24 -0
- data/Rakefile +5 -0
- data/lib/nextday/config.rb +5 -2
- data/lib/nextday/date_extension.rb +19 -28
- data/lib/nextday/version.rb +1 -1
- data/nextday.gemspec +2 -1
- data/spec/spec_helper.rb +1 -1
- metadata +42 -9
- data/Guardfile +0 -6
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/Gemfile
CHANGED
@@ -2,14 +2,3 @@ source "http://rubygems.org"
|
|
2
2
|
|
3
3
|
# Specify your gem's dependencies in nextday.gemspec
|
4
4
|
gemspec
|
5
|
-
|
6
|
-
gem 'rake'
|
7
|
-
|
8
|
-
require 'rbconfig'
|
9
|
-
|
10
|
-
if RbConfig::CONFIG['target_os'] =~ /darwin/i
|
11
|
-
gem 'rb-fsevent', '>= 0.4.0', :require => false
|
12
|
-
gem 'growl_notify', :require => false
|
13
|
-
gem 'guard', '~> 0.6.0', :require => false
|
14
|
-
gem 'guard-rspec', '~> 0.4.0', :require => false
|
15
|
-
end
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Nextday
|
2
2
|
|
3
|
+
[](http://travis-ci.org/robwilliams/nextday)
|
4
|
+
|
3
5
|
Finds the Next Working Day even if holidays are in the way.
|
4
6
|
|
5
7
|
Extends ```Date```, ```Time``` and ```DateTime``` to allow you to find the next working day
|
@@ -29,6 +31,28 @@ DateTime.today.working_day?
|
|
29
31
|
Time.now.working_day?
|
30
32
|
```
|
31
33
|
|
34
|
+
### When will an item be despatched?
|
35
|
+
```ruby
|
36
|
+
Date.today.despatch_day
|
37
|
+
DateTime.today.despatch_day
|
38
|
+
Time.now.despatch_day
|
39
|
+
```
|
40
|
+
|
41
|
+
### When will an item be delivered?
|
42
|
+
```ruby
|
43
|
+
Date.today.delivery_day
|
44
|
+
DateTime.today.delivery_day
|
45
|
+
Time.now.delivery_day
|
46
|
+
```
|
47
|
+
|
48
|
+
## Configuration
|
49
|
+
|
50
|
+
To set the cut off time to a different value:
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
Nextday::Config.cut_off_time = "18:47"
|
54
|
+
```
|
55
|
+
|
32
56
|
## Installation
|
33
57
|
|
34
58
|
To use with bundler add nextday to your gem file.
|
data/Rakefile
CHANGED
data/lib/nextday/config.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
module Nextday
|
2
|
-
|
3
2
|
module DateExtension
|
4
|
-
|
5
3
|
##
|
4
|
+
# The day an item or service will be despatched.
|
5
|
+
# If the warehouse closes at say 4:00pm then this will
|
6
|
+
# be taken into account and the despatch day will be the
|
7
|
+
# next working day.
|
6
8
|
#
|
9
|
+
# @return [Date]
|
7
10
|
def despatch_day
|
8
11
|
if working_day?
|
9
12
|
if to_time < cut_off_time
|
@@ -15,29 +18,33 @@ module Nextday
|
|
15
18
|
next_working_day
|
16
19
|
end
|
17
20
|
end
|
18
|
-
|
21
|
+
|
22
|
+
##
|
23
|
+
# The next working day after an item has been despatched.
|
24
|
+
#
|
25
|
+
# @return [Date]
|
19
26
|
def delivery_day
|
20
27
|
despatch_day.next_working_day
|
21
28
|
end
|
22
|
-
|
29
|
+
|
23
30
|
def cut_off_time
|
24
31
|
hour, minute = Config.cut_off_hour, Config.cut_off_minute
|
25
|
-
|
32
|
+
|
26
33
|
Time.new(year, month, day, hour, minute)
|
27
34
|
end
|
28
|
-
|
35
|
+
|
29
36
|
##
|
30
37
|
# The next working day after the current date
|
31
38
|
#
|
32
39
|
# @return [Date] Next Working Day
|
33
40
|
def next_working_day
|
34
41
|
next_day = to_date + 1
|
35
|
-
|
42
|
+
|
36
43
|
# keep going until the next day is a working day
|
37
44
|
while !next_day.working_day?
|
38
45
|
next_day = next_day + 1
|
39
46
|
end
|
40
|
-
|
47
|
+
|
41
48
|
next_day
|
42
49
|
end
|
43
50
|
|
@@ -47,12 +54,12 @@ module Nextday
|
|
47
54
|
# @return [Date] Previous Working Day
|
48
55
|
def previous_working_day
|
49
56
|
previous_day = to_date - 1
|
50
|
-
|
57
|
+
|
51
58
|
# keep going until the next day is a working day
|
52
59
|
while !previous_day.working_day?
|
53
60
|
previous_day = previous_day - 1
|
54
61
|
end
|
55
|
-
|
62
|
+
|
56
63
|
previous_day
|
57
64
|
end
|
58
65
|
|
@@ -63,7 +70,7 @@ module Nextday
|
|
63
70
|
def working_day?
|
64
71
|
!weekend? and !public_holiday?
|
65
72
|
end
|
66
|
-
|
73
|
+
|
67
74
|
##
|
68
75
|
# Is the current date a public holiday?
|
69
76
|
#
|
@@ -71,7 +78,7 @@ module Nextday
|
|
71
78
|
def public_holiday?
|
72
79
|
Holidays.dates.include?(to_date)
|
73
80
|
end
|
74
|
-
|
81
|
+
|
75
82
|
##
|
76
83
|
# Is the current date on the weekend?
|
77
84
|
#
|
@@ -79,21 +86,5 @@ module Nextday
|
|
79
86
|
def weekend?
|
80
87
|
saturday? or sunday?
|
81
88
|
end
|
82
|
-
|
83
|
-
##
|
84
|
-
# Is the current date a saturday?
|
85
|
-
#
|
86
|
-
# @return [Boolean]
|
87
|
-
def saturday?
|
88
|
-
to_date.wday == 6
|
89
|
-
end if RUBY_VERSION < '1.9'
|
90
|
-
|
91
|
-
##
|
92
|
-
# Is the current date a saturday?
|
93
|
-
#
|
94
|
-
# @return [Boolean]
|
95
|
-
def sunday?
|
96
|
-
to_date.wday == 0
|
97
|
-
end if RUBY_VERSION < '1.9'
|
98
89
|
end
|
99
90
|
end
|
data/lib/nextday/version.rb
CHANGED
data/nextday.gemspec
CHANGED
@@ -22,7 +22,8 @@ Gem::Specification.new do |s|
|
|
22
22
|
s.require_paths = ["lib"]
|
23
23
|
|
24
24
|
# specify any dependencies here; for example:
|
25
|
-
s.add_development_dependency('rspec', '~> 2.
|
25
|
+
s.add_development_dependency('rspec', '~> 2.10.0')
|
26
26
|
s.add_development_dependency('yard')
|
27
|
+
s.add_development_dependency('rake')
|
27
28
|
# s.add_runtime_dependency "rest-client"
|
28
29
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nextday
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,22 +9,43 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-06-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 2.
|
21
|
+
version: 2.10.0
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 2.10.0
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: yard
|
27
|
-
requirement:
|
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: rake
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
28
49
|
none: false
|
29
50
|
requirements:
|
30
51
|
- - ! '>='
|
@@ -32,7 +53,12 @@ dependencies:
|
|
32
53
|
version: '0'
|
33
54
|
type: :development
|
34
55
|
prerelease: false
|
35
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
36
62
|
description: ! "\n Finds the Next Working Day even if holidays are in the way.\n
|
37
63
|
\ Extends Date with a .next_working_day instance method.\n "
|
38
64
|
email:
|
@@ -43,8 +69,8 @@ extra_rdoc_files: []
|
|
43
69
|
files:
|
44
70
|
- .gitignore
|
45
71
|
- .rspec
|
72
|
+
- .travis.yml
|
46
73
|
- Gemfile
|
47
|
-
- Guardfile
|
48
74
|
- README.md
|
49
75
|
- Rakefile
|
50
76
|
- lib/nextday.rb
|
@@ -74,15 +100,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
74
100
|
- - ! '>='
|
75
101
|
- !ruby/object:Gem::Version
|
76
102
|
version: '0'
|
103
|
+
segments:
|
104
|
+
- 0
|
105
|
+
hash: 798981716380311647
|
77
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
107
|
none: false
|
79
108
|
requirements:
|
80
109
|
- - ! '>='
|
81
110
|
- !ruby/object:Gem::Version
|
82
111
|
version: '0'
|
112
|
+
segments:
|
113
|
+
- 0
|
114
|
+
hash: 798981716380311647
|
83
115
|
requirements: []
|
84
116
|
rubyforge_project: nextday
|
85
|
-
rubygems_version: 1.8.
|
117
|
+
rubygems_version: 1.8.24
|
86
118
|
signing_key:
|
87
119
|
specification_version: 3
|
88
120
|
summary: Finds the Next Working Day even if holidays are in the way.
|
@@ -92,3 +124,4 @@ test_files:
|
|
92
124
|
- spec/lib/nextday/holiday_spec.rb
|
93
125
|
- spec/lib/nextday/holidays_spec.rb
|
94
126
|
- spec/spec_helper.rb
|
127
|
+
has_rdoc:
|