business_time 0.2.0 → 0.2.1
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/VERSION +1 -1
- data/lib/business_time/business_days.rb +10 -11
- data/lib/business_time/config.rb +24 -9
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
@@ -5,15 +5,7 @@ module BusinessTime
|
|
5
5
|
@days = days
|
6
6
|
end
|
7
7
|
|
8
|
-
def
|
9
|
-
before(Time.now)
|
10
|
-
end
|
11
|
-
|
12
|
-
def from_now
|
13
|
-
after(Time.now)
|
14
|
-
end
|
15
|
-
|
16
|
-
def after(time)
|
8
|
+
def after(time = Time.now)
|
17
9
|
@days.times do
|
18
10
|
begin
|
19
11
|
time = time + 1.day
|
@@ -21,8 +13,11 @@ module BusinessTime
|
|
21
13
|
end
|
22
14
|
time
|
23
15
|
end
|
24
|
-
|
25
|
-
|
16
|
+
|
17
|
+
alias_method :from_now, :after
|
18
|
+
alias_method :since, :after
|
19
|
+
|
20
|
+
def before(time = Time.now)
|
26
21
|
@days.times do
|
27
22
|
begin
|
28
23
|
time = time - 1.day
|
@@ -30,6 +25,10 @@ module BusinessTime
|
|
30
25
|
end
|
31
26
|
time
|
32
27
|
end
|
28
|
+
|
29
|
+
alias_method :ago, :before
|
30
|
+
alias_method :until, :before
|
31
|
+
|
33
32
|
end
|
34
33
|
|
35
34
|
end
|
data/lib/business_time/config.rb
CHANGED
@@ -1,12 +1,26 @@
|
|
1
1
|
module BusinessTime
|
2
2
|
|
3
|
-
# controls the behavior of
|
3
|
+
# controls the behavior of this gem. You can change
|
4
4
|
# the beginning_of_workday, end_of_workday, and the list of holidays
|
5
|
-
#manually, or with a yaml file and the load method.
|
5
|
+
# manually, or with a yaml file and the load method.
|
6
6
|
class Config
|
7
7
|
class << self
|
8
|
+
# You can set this yourself, either by the load method below, or
|
9
|
+
# by saying
|
10
|
+
# BusinessTime::Config.beginning_of_workday = "8:30 am"
|
11
|
+
# someplace in the initializers of your application.
|
8
12
|
attr_accessor :beginning_of_workday
|
13
|
+
|
14
|
+
# You can set this yourself, either by the load method below, or
|
15
|
+
# by saying
|
16
|
+
# BusinessTime::Config.end_of_workday = "5:30 pm"
|
17
|
+
# someplace in the initializers of your application.
|
9
18
|
attr_accessor :end_of_workday
|
19
|
+
|
20
|
+
# You can set this yourself, either by the load method below, or
|
21
|
+
# by saying
|
22
|
+
# BusinessTime::Config.holidays << my_holiday_date_object
|
23
|
+
# someplace in the initializers of your application.
|
10
24
|
attr_accessor :holidays
|
11
25
|
end
|
12
26
|
|
@@ -17,13 +31,14 @@ module BusinessTime
|
|
17
31
|
end
|
18
32
|
|
19
33
|
# loads the config data from a yaml file written as:
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
34
|
+
#
|
35
|
+
# business_time:
|
36
|
+
# beginning_od_workday: 8:30 am
|
37
|
+
# end_of_workday: 5:30 pm
|
38
|
+
# holidays:
|
39
|
+
# - Jan 1st, 2010
|
40
|
+
# - July 4th, 2010
|
41
|
+
# - Dec 25th, 2010
|
27
42
|
def self.load(filename)
|
28
43
|
self.reset
|
29
44
|
data = YAML::load(File.open(filename))
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
8
|
+
- 1
|
9
|
+
version: 0.2.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- bokmann
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-04-
|
17
|
+
date: 2010-04-22 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|