biz 0.0.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +110 -11
- data/lib/biz.rb +54 -2
- data/lib/biz/calculation.rb +8 -0
- data/lib/biz/calculation/active.rb +20 -0
- data/lib/biz/calculation/duration_within.rb +17 -0
- data/lib/biz/calculation/for_duration.rb +33 -0
- data/lib/biz/configuration.rb +74 -0
- data/lib/biz/core_ext.rb +12 -0
- data/lib/biz/core_ext/date.rb +15 -0
- data/lib/biz/core_ext/fixnum.rb +11 -0
- data/lib/biz/core_ext/time.rb +11 -0
- data/lib/biz/date.rb +11 -0
- data/lib/biz/day.rb +51 -0
- data/lib/biz/day_of_week.rb +81 -0
- data/lib/biz/day_time.rb +95 -0
- data/lib/biz/duration.rb +100 -0
- data/lib/biz/holiday.rb +26 -0
- data/lib/biz/interval.rb +35 -0
- data/lib/biz/periods.rb +24 -0
- data/lib/biz/periods/abstract.rb +49 -0
- data/lib/biz/periods/after.rb +24 -0
- data/lib/biz/periods/before.rb +27 -0
- data/lib/biz/schedule.rb +37 -0
- data/lib/biz/time.rb +49 -0
- data/lib/biz/time_segment.rb +63 -0
- data/lib/biz/timeline.rb +24 -0
- data/lib/biz/timeline/abstract.rb +41 -0
- data/lib/biz/timeline/backward.rb +24 -0
- data/lib/biz/timeline/forward.rb +24 -0
- data/lib/biz/version.rb +3 -1
- data/lib/biz/week.rb +67 -0
- data/lib/biz/week_time.rb +26 -0
- data/lib/biz/week_time/abstract.rb +75 -0
- data/lib/biz/week_time/end.rb +20 -0
- data/lib/biz/week_time/start.rb +22 -0
- metadata +122 -5
@@ -0,0 +1,20 @@
|
|
1
|
+
module Biz
|
2
|
+
module WeekTime
|
3
|
+
class End < Abstract
|
4
|
+
|
5
|
+
private
|
6
|
+
|
7
|
+
def day_of_week
|
8
|
+
DayOfWeek::DAYS.find { |day| day.contains?(week_minute) }
|
9
|
+
end
|
10
|
+
|
11
|
+
def day_time
|
12
|
+
DayTime.new(day_of_week.day_minute(week_minute))
|
13
|
+
end
|
14
|
+
|
15
|
+
memoize :day_of_week,
|
16
|
+
:day_time
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Biz
|
2
|
+
module WeekTime
|
3
|
+
class Start < Abstract
|
4
|
+
|
5
|
+
private
|
6
|
+
|
7
|
+
def day_of_week
|
8
|
+
DayOfWeek::DAYS.fetch(
|
9
|
+
week_minute / Time::MINUTES_IN_DAY % Time::DAYS_IN_WEEK
|
10
|
+
)
|
11
|
+
end
|
12
|
+
|
13
|
+
def day_time
|
14
|
+
DayTime.new(week_minute % Time::MINUTES_IN_DAY)
|
15
|
+
end
|
16
|
+
|
17
|
+
memoize :day_of_week,
|
18
|
+
:day_time
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
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: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Craig Little
|
@@ -9,9 +9,93 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
13
|
-
dependencies:
|
14
|
-
|
12
|
+
date: 2015-02-17 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: abstract_type
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 0.0.0
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 0.0.0
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: equalizer
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 0.0.0
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 0.0.0
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: memoizable
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 0.4.0
|
49
|
+
type: :runtime
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 0.4.0
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: tzinfo
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rake
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '10.0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '10.0'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: rspec
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '3.0'
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '3.0'
|
98
|
+
description: Time calculations using business hours.
|
15
99
|
email:
|
16
100
|
- clittle@zendesk.com
|
17
101
|
- astone@zendesk.com
|
@@ -21,7 +105,39 @@ extra_rdoc_files: []
|
|
21
105
|
files:
|
22
106
|
- README.md
|
23
107
|
- lib/biz.rb
|
108
|
+
- lib/biz/calculation.rb
|
109
|
+
- lib/biz/calculation/active.rb
|
110
|
+
- lib/biz/calculation/duration_within.rb
|
111
|
+
- lib/biz/calculation/for_duration.rb
|
112
|
+
- lib/biz/configuration.rb
|
113
|
+
- lib/biz/core_ext.rb
|
114
|
+
- lib/biz/core_ext/date.rb
|
115
|
+
- lib/biz/core_ext/fixnum.rb
|
116
|
+
- lib/biz/core_ext/time.rb
|
117
|
+
- lib/biz/date.rb
|
118
|
+
- lib/biz/day.rb
|
119
|
+
- lib/biz/day_of_week.rb
|
120
|
+
- lib/biz/day_time.rb
|
121
|
+
- lib/biz/duration.rb
|
122
|
+
- lib/biz/holiday.rb
|
123
|
+
- lib/biz/interval.rb
|
124
|
+
- lib/biz/periods.rb
|
125
|
+
- lib/biz/periods/abstract.rb
|
126
|
+
- lib/biz/periods/after.rb
|
127
|
+
- lib/biz/periods/before.rb
|
128
|
+
- lib/biz/schedule.rb
|
129
|
+
- lib/biz/time.rb
|
130
|
+
- lib/biz/time_segment.rb
|
131
|
+
- lib/biz/timeline.rb
|
132
|
+
- lib/biz/timeline/abstract.rb
|
133
|
+
- lib/biz/timeline/backward.rb
|
134
|
+
- lib/biz/timeline/forward.rb
|
24
135
|
- lib/biz/version.rb
|
136
|
+
- lib/biz/week.rb
|
137
|
+
- lib/biz/week_time.rb
|
138
|
+
- lib/biz/week_time/abstract.rb
|
139
|
+
- lib/biz/week_time/end.rb
|
140
|
+
- lib/biz/week_time/start.rb
|
25
141
|
homepage: https://github.com/zendesk/biz
|
26
142
|
licenses:
|
27
143
|
- Copyright Zendesk. All Rights Reserved.
|
@@ -45,5 +161,6 @@ rubyforge_project:
|
|
45
161
|
rubygems_version: 2.4.5
|
46
162
|
signing_key:
|
47
163
|
specification_version: 4
|
48
|
-
summary:
|
164
|
+
summary: Business hours calculations
|
49
165
|
test_files: []
|
166
|
+
has_rdoc:
|