business_time 0.9.2 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/business_time/business_days.rb +4 -4
- data/lib/business_time/business_hours.rb +4 -4
- data/lib/business_time/config.rb +11 -7
- data/lib/business_time/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5fe356eb4f4e620e3f3db2aa9242df1c63213500
|
4
|
+
data.tar.gz: d1f662a4f576662e3f6d140970d5b2191016fda8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86434d31fbf26aa3372510db883266643431a449fa2980cee43e9d34198c140a560d0606d41911aa0a47e030b373eeba0442f38dad07c36a5b5113a811c97213
|
7
|
+
data.tar.gz: 5c1ae7866418a21538030ba2129698eaafb2016b5d715cd2c13e31e1739b8732ff625af6f87e48e98bbe697ea06005d74c35bfab7c8610b306f7ba7c9d0121b5
|
@@ -17,14 +17,14 @@ module BusinessTime
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def after(time = Time.current)
|
20
|
-
|
20
|
+
non_negative_days? ? calculate_after(time, @days) : calculate_before(time, -@days)
|
21
21
|
end
|
22
22
|
|
23
23
|
alias_method :from_now, :after
|
24
24
|
alias_method :since, :after
|
25
25
|
|
26
26
|
def before(time = Time.current)
|
27
|
-
|
27
|
+
non_negative_days? ? calculate_before(time, @days) : calculate_after(time, -@days)
|
28
28
|
end
|
29
29
|
|
30
30
|
alias_method :ago, :before
|
@@ -32,8 +32,8 @@ module BusinessTime
|
|
32
32
|
|
33
33
|
private
|
34
34
|
|
35
|
-
def
|
36
|
-
@days
|
35
|
+
def non_negative_days?
|
36
|
+
@days >= 0
|
37
37
|
end
|
38
38
|
|
39
39
|
def calculate_after(time, days)
|
@@ -24,18 +24,18 @@ module BusinessTime
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def after(time)
|
27
|
-
|
27
|
+
non_negative_hours? ? calculate_after(time, @hours) : calculate_before(time, -@hours)
|
28
28
|
end
|
29
29
|
alias_method :since, :after
|
30
30
|
|
31
31
|
def before(time)
|
32
|
-
|
32
|
+
non_negative_hours? ? calculate_before(time, @hours) : calculate_after(time, -@hours)
|
33
33
|
end
|
34
34
|
|
35
35
|
private
|
36
36
|
|
37
|
-
def
|
38
|
-
@hours
|
37
|
+
def non_negative_hours?
|
38
|
+
@hours >= 0
|
39
39
|
end
|
40
40
|
|
41
41
|
def calculate_after(time, hours)
|
data/lib/business_time/config.rb
CHANGED
@@ -47,15 +47,19 @@ module BusinessTime
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def local_config
|
50
|
-
|
50
|
+
local_config_stack.last
|
51
51
|
end
|
52
52
|
|
53
53
|
def local_config=(config)
|
54
|
-
|
54
|
+
local_config_stack.last.replace(config)
|
55
|
+
end
|
56
|
+
|
57
|
+
def local_config_stack
|
58
|
+
Thread.current[:business_time_local_config] ||= []
|
55
59
|
end
|
56
60
|
|
57
61
|
def local_config?
|
58
|
-
!
|
62
|
+
!local_config_stack.empty?
|
59
63
|
end
|
60
64
|
|
61
65
|
def threadsafe_cattr_accessor(name)
|
@@ -173,11 +177,11 @@ module BusinessTime
|
|
173
177
|
end
|
174
178
|
|
175
179
|
def with(config)
|
176
|
-
|
180
|
+
local_config_stack.push(config().dup)
|
177
181
|
config.each { |k,v| send("#{k}=", v) } # calculations are done on setting
|
178
182
|
yield
|
179
183
|
ensure
|
180
|
-
|
184
|
+
local_config_stack.pop
|
181
185
|
end
|
182
186
|
|
183
187
|
def default_config
|
@@ -196,8 +200,8 @@ module BusinessTime
|
|
196
200
|
end
|
197
201
|
|
198
202
|
def reset
|
199
|
-
|
200
|
-
self.
|
203
|
+
local_config_stack.clear
|
204
|
+
self.config = default_config
|
201
205
|
end
|
202
206
|
|
203
207
|
def deep_dup(object)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: business_time
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bokmann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -138,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
138
|
version: '0'
|
139
139
|
requirements: []
|
140
140
|
rubyforge_project:
|
141
|
-
rubygems_version: 2.6.
|
141
|
+
rubygems_version: 2.6.13
|
142
142
|
signing_key:
|
143
143
|
specification_version: 4
|
144
144
|
summary: Support for doing time math in business hours and days
|