biz 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/biz.rb +2 -0
- data/lib/biz/configuration.rb +2 -0
- data/lib/biz/error.rb +7 -0
- data/lib/biz/time.rb +1 -1
- data/lib/biz/validation.rb +50 -0
- data/lib/biz/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89a15e7c6f5161b0a1b5e1132b1f9b4cc0b2e7c4
|
4
|
+
data.tar.gz: ff36ac8b0a4f6d2f6971c6fb8beaf36df09ac251
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71f2ab477908d44026f15f4a10a09dd8ba6396ae871e998f29ebe58b15c1f2919959b8bf1fc11f648ab726050f9aa16272ccf5ce52f9b87ca73a8444485cc150
|
7
|
+
data.tar.gz: 93a8e96e6e8e3df4957cb66844b1d0b253db0e300cde2deec5cb6a01b73a2dcfbd179b26d7943687129968cbca559782f6e27213992c5023071cb26b13b6ce71
|
data/lib/biz.rb
CHANGED
@@ -51,6 +51,7 @@ require 'biz/day'
|
|
51
51
|
require 'biz/day_of_week'
|
52
52
|
require 'biz/day_time'
|
53
53
|
require 'biz/duration'
|
54
|
+
require 'biz/error'
|
54
55
|
require 'biz/holiday'
|
55
56
|
require 'biz/interval'
|
56
57
|
require 'biz/periods'
|
@@ -59,4 +60,5 @@ require 'biz/timeline'
|
|
59
60
|
require 'biz/time_segment'
|
60
61
|
require 'biz/week'
|
61
62
|
require 'biz/week_time'
|
63
|
+
require 'biz/validation'
|
62
64
|
require 'biz/version'
|
data/lib/biz/configuration.rb
CHANGED
data/lib/biz/error.rb
ADDED
data/lib/biz/time.rb
CHANGED
@@ -0,0 +1,50 @@
|
|
1
|
+
module Biz
|
2
|
+
class Validation
|
3
|
+
|
4
|
+
def self.perform(raw)
|
5
|
+
new(raw).perform
|
6
|
+
end
|
7
|
+
|
8
|
+
def initialize(raw)
|
9
|
+
@raw = raw
|
10
|
+
end
|
11
|
+
|
12
|
+
def perform
|
13
|
+
RULES.each do |rule| rule.check(raw) end
|
14
|
+
|
15
|
+
self
|
16
|
+
end
|
17
|
+
|
18
|
+
protected
|
19
|
+
|
20
|
+
attr_reader :raw
|
21
|
+
|
22
|
+
class Rule
|
23
|
+
|
24
|
+
def initialize(message, &condition)
|
25
|
+
@message = message
|
26
|
+
@condition = condition
|
27
|
+
end
|
28
|
+
|
29
|
+
def check(raw)
|
30
|
+
fail Error::Configuration, message unless condition.call(raw)
|
31
|
+
end
|
32
|
+
|
33
|
+
protected
|
34
|
+
|
35
|
+
attr_reader :message,
|
36
|
+
:condition
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
RULES = Set.new([
|
41
|
+
Rule.new('Hours must be hash-like.') { |raw|
|
42
|
+
raw.hours.respond_to?(:to_h)
|
43
|
+
},
|
44
|
+
Rule.new('Hours must be provided.') { |raw|
|
45
|
+
raw.hours.to_h.any?
|
46
|
+
}
|
47
|
+
])
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
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.3.
|
4
|
+
version: 1.3.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: 2015-
|
12
|
+
date: 2015-10-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: abstract_type
|
@@ -135,6 +135,7 @@ files:
|
|
135
135
|
- lib/biz/day_of_week.rb
|
136
136
|
- lib/biz/day_time.rb
|
137
137
|
- lib/biz/duration.rb
|
138
|
+
- lib/biz/error.rb
|
138
139
|
- lib/biz/holiday.rb
|
139
140
|
- lib/biz/interval.rb
|
140
141
|
- lib/biz/periods.rb
|
@@ -150,6 +151,7 @@ files:
|
|
150
151
|
- lib/biz/timeline/backward.rb
|
151
152
|
- lib/biz/timeline/forward.rb
|
152
153
|
- lib/biz/timeline/proxy.rb
|
154
|
+
- lib/biz/validation.rb
|
153
155
|
- lib/biz/version.rb
|
154
156
|
- lib/biz/week.rb
|
155
157
|
- lib/biz/week_time.rb
|
@@ -176,9 +178,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
176
178
|
version: '0'
|
177
179
|
requirements: []
|
178
180
|
rubyforge_project:
|
179
|
-
rubygems_version: 2.4.5
|
181
|
+
rubygems_version: 2.4.5.1
|
180
182
|
signing_key:
|
181
183
|
specification_version: 4
|
182
184
|
summary: Business hours calculations
|
183
185
|
test_files: []
|
184
|
-
has_rdoc:
|