biz 1.6.0 → 1.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +18 -4
- data/lib/biz/calculation/active.rb +3 -3
- data/lib/biz/calculation/on_break.rb +1 -1
- data/lib/biz/core_ext.rb +4 -4
- data/lib/biz/core_ext/{fixnum.rb → integer.rb} +1 -1
- data/lib/biz/day_of_week.rb +2 -4
- data/lib/biz/day_time.rb +7 -3
- data/lib/biz/periods/abstract.rb +2 -4
- data/lib/biz/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b83065efe295ea89da135b593191120dc58bcf6d
|
4
|
+
data.tar.gz: 97b8e746410d76e35145b0e41920a0ba04801e9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e8f3d0ae0c724ade11514895b7ce160d6303b76679bafb38d2ff6daf03b469f0dd47789696a4e58009f1ef2608d96f63af5abeee888b7fe5954d305927e4e58
|
7
|
+
data.tar.gz: 63c26133dd00077646bf011d34e22f5b869498c30ba13327e224bf2023c23e3d332e3a59ccd0424b39ea2be1256fda39ab347358a1681fd4c7d9441601759eaa
|
data/README.md
CHANGED
@@ -138,7 +138,21 @@ Biz.periods
|
|
138
138
|
# #<Biz::TimeSegment start_time=2015-04-27 20:36:57 UTC end_time=2015-04-28 00:00:00 UTC>]
|
139
139
|
```
|
140
140
|
|
141
|
-
|
141
|
+
#### Day calculation semantics
|
142
|
+
|
143
|
+
Unlike seconds, minutes, or hours, a "day" is an ambiguous concept, particularly
|
144
|
+
in relation to the vast number of potential schedule configurations. Because of
|
145
|
+
that, day calculations are implemented with the principle of making the logic as
|
146
|
+
straightforward as possible while knowing not all use cases will be satisfied
|
147
|
+
out of the box.
|
148
|
+
|
149
|
+
Here's the logic that's followed:
|
150
|
+
|
151
|
+
> Find the next day that contains business hours. Starting from the same minute
|
152
|
+
> on that day as the specified time, look forward (or back) to find the next
|
153
|
+
> moment in time that is in business hours.
|
154
|
+
|
155
|
+
## Schedule intersection
|
142
156
|
|
143
157
|
An intersection of two schedules can be found using `&`:
|
144
158
|
|
@@ -222,10 +236,10 @@ Biz::Schedule.new do |config|
|
|
222
236
|
end
|
223
237
|
```
|
224
238
|
|
225
|
-
## Core
|
239
|
+
## Core extensions
|
226
240
|
|
227
|
-
Optional extensions to core classes (`Date`, `
|
228
|
-
for additional expressiveness:
|
241
|
+
Optional extensions to core classes (`Date`, `Integer`, and `Time`) are
|
242
|
+
available for additional expressiveness:
|
229
243
|
|
230
244
|
```ruby
|
231
245
|
require 'biz/core_ext'
|
@@ -8,9 +8,9 @@ module Biz
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def result
|
11
|
-
schedule.intervals.any?
|
12
|
-
schedule.breaks.none? { |
|
13
|
-
schedule.holidays.none? { |holiday| holiday.contains?(time) }
|
11
|
+
schedule.intervals.any? { |interval| interval.contains?(time) } \
|
12
|
+
&& schedule.breaks.none? { |brake| brake.contains?(time) } \
|
13
|
+
&& schedule.holidays.none? { |holiday| holiday.contains?(time) }
|
14
14
|
end
|
15
15
|
|
16
16
|
protected
|
data/lib/biz/core_ext.rb
CHANGED
@@ -4,9 +4,9 @@ module Biz
|
|
4
4
|
end
|
5
5
|
|
6
6
|
require 'biz/core_ext/date'
|
7
|
-
require 'biz/core_ext/
|
7
|
+
require 'biz/core_ext/integer'
|
8
8
|
require 'biz/core_ext/time'
|
9
9
|
|
10
|
-
Date.class_eval
|
11
|
-
|
12
|
-
Time.class_eval
|
10
|
+
Date.class_eval do include Biz::CoreExt::Date end
|
11
|
+
Integer.class_eval do include Biz::CoreExt::Integer end
|
12
|
+
Time.class_eval do include Biz::CoreExt::Time end
|
data/lib/biz/day_of_week.rb
CHANGED
@@ -13,6 +13,8 @@ module Biz
|
|
13
13
|
ALL.fetch(SYMBOLS.index(symbol))
|
14
14
|
end
|
15
15
|
|
16
|
+
attr_reader :wday
|
17
|
+
|
16
18
|
def initialize(wday)
|
17
19
|
@wday = Integer(wday)
|
18
20
|
end
|
@@ -55,10 +57,6 @@ module Biz
|
|
55
57
|
wday <=> other.wday
|
56
58
|
end
|
57
59
|
|
58
|
-
protected
|
59
|
-
|
60
|
-
attr_reader :wday
|
61
|
-
|
62
60
|
ALL = (0..6).map(&method(:new)).freeze
|
63
61
|
|
64
62
|
private_constant :SYMBOLS,
|
data/lib/biz/day_time.rb
CHANGED
@@ -51,9 +51,7 @@ module Biz
|
|
51
51
|
def initialize(day_second)
|
52
52
|
@day_second = Integer(day_second)
|
53
53
|
|
54
|
-
unless
|
55
|
-
fail ArgumentError, 'second not within a day'
|
56
|
-
end
|
54
|
+
fail ArgumentError, 'second not within a day' unless valid_second?
|
57
55
|
end
|
58
56
|
|
59
57
|
attr_reader :day_second
|
@@ -88,6 +86,12 @@ module Biz
|
|
88
86
|
day_second <=> other.day_second
|
89
87
|
end
|
90
88
|
|
89
|
+
private
|
90
|
+
|
91
|
+
def valid_second?
|
92
|
+
VALID_SECONDS.cover?(day_second)
|
93
|
+
end
|
94
|
+
|
91
95
|
MIDNIGHT = from_hour(0)
|
92
96
|
ENDNIGHT = from_hour(24)
|
93
97
|
|
data/lib/biz/periods/abstract.rb
CHANGED
@@ -1,14 +1,12 @@
|
|
1
1
|
module Biz
|
2
2
|
module Periods
|
3
|
-
class Abstract <
|
4
|
-
|
5
|
-
extend Forwardable
|
3
|
+
class Abstract < SimpleDelegator
|
6
4
|
|
7
5
|
def initialize(schedule, origin)
|
8
6
|
@schedule = schedule
|
9
7
|
@origin = origin
|
10
8
|
|
11
|
-
super(periods)
|
9
|
+
super(periods)
|
12
10
|
end
|
13
11
|
|
14
12
|
def timeline
|
data/lib/biz/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: biz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Craig Little
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2017-01-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: clavius
|
@@ -45,14 +45,14 @@ dependencies:
|
|
45
45
|
requirements:
|
46
46
|
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '
|
48
|
+
version: '12.0'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: '
|
55
|
+
version: '12.0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: rspec
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,7 +86,7 @@ files:
|
|
86
86
|
- lib/biz/configuration.rb
|
87
87
|
- lib/biz/core_ext.rb
|
88
88
|
- lib/biz/core_ext/date.rb
|
89
|
-
- lib/biz/core_ext/
|
89
|
+
- lib/biz/core_ext/integer.rb
|
90
90
|
- lib/biz/core_ext/time.rb
|
91
91
|
- lib/biz/date.rb
|
92
92
|
- lib/biz/dates.rb
|
@@ -128,7 +128,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
128
128
|
requirements:
|
129
129
|
- - ">="
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: '2.
|
131
|
+
version: '2.1'
|
132
132
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
133
|
requirements:
|
134
134
|
- - ">="
|
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
136
|
version: '0'
|
137
137
|
requirements: []
|
138
138
|
rubyforge_project:
|
139
|
-
rubygems_version: 2.
|
139
|
+
rubygems_version: 2.6.8
|
140
140
|
signing_key:
|
141
141
|
specification_version: 4
|
142
142
|
summary: Business hours calculations
|