workpattern 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/.travis.yml +1 -1
- data/CHANGELOG +13 -1
- data/Gemfile.lock +1 -1
- data/lib/workpattern/hour.rb +24 -20
- data/lib/workpattern/version.rb +1 -1
- data/test/test_clock.rb +3 -3
- data/test/test_day.rb +325 -206
- data/test/test_helper.rb +1 -23
- data/test/test_hour.rb +365 -228
- data/test/test_week.rb +14 -14
- data/test/test_workpattern.rb +15 -15
- data/test/test_workpattern_module.rb +12 -12
- metadata +5 -5
data/test/test_week.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
2
|
|
3
|
-
class TestWeek <
|
3
|
+
class TestWeek < MiniTest::Unit::TestCase #:nodoc:
|
4
4
|
|
5
5
|
def setup
|
6
6
|
|
7
7
|
end
|
8
8
|
|
9
|
-
|
9
|
+
def test_must_create_a_working_week
|
10
10
|
start=DateTime.new(2000,1,1,11,3)
|
11
11
|
finish=DateTime.new(2005,12,31,16,41)
|
12
12
|
working_week=week(start,finish,1)
|
@@ -15,7 +15,7 @@ class TestWeek < Test::Unit::TestCase #:nodoc:
|
|
15
15
|
assert_equal 3156480, working_week.total#2192
|
16
16
|
end
|
17
17
|
|
18
|
-
|
18
|
+
def test_must_create_a_resting_week
|
19
19
|
start=DateTime.new(2000,1,1,11,3)
|
20
20
|
finish=DateTime.new(2005,12,31,16,41)
|
21
21
|
resting_week=week(start,finish,0)
|
@@ -25,7 +25,7 @@ class TestWeek < Test::Unit::TestCase #:nodoc:
|
|
25
25
|
assert_equal 0,resting_week.week_total
|
26
26
|
end
|
27
27
|
|
28
|
-
|
28
|
+
def test_must_duplicate_all_of_a_week
|
29
29
|
start=DateTime.new(2000,1,1,11,3)
|
30
30
|
finish=DateTime.new(2005,12,31,16,41)
|
31
31
|
week=week(start,finish,1)
|
@@ -36,7 +36,7 @@ class TestWeek < Test::Unit::TestCase #:nodoc:
|
|
36
36
|
|
37
37
|
end
|
38
38
|
|
39
|
-
|
39
|
+
def test_must_set_patterns_correctly
|
40
40
|
start=DateTime.new(2000,1,1,0,0)
|
41
41
|
finish=DateTime.new(2005,12,31,8,59)
|
42
42
|
working_week=week(start,finish,1)
|
@@ -62,7 +62,7 @@ class TestWeek < Test::Unit::TestCase #:nodoc:
|
|
62
62
|
|
63
63
|
end
|
64
64
|
|
65
|
-
|
65
|
+
def test_must_add_minutes_in_a_working_week
|
66
66
|
start=DateTime.new(2000,1,1,0,0)
|
67
67
|
finish=DateTime.new(2005,12,31,8,59)
|
68
68
|
working_week=week(start,finish,1)
|
@@ -81,7 +81,7 @@ class TestWeek < Test::Unit::TestCase #:nodoc:
|
|
81
81
|
}
|
82
82
|
end
|
83
83
|
|
84
|
-
|
84
|
+
def test_must_add_minutes_in_a_resting_week
|
85
85
|
start=DateTime.new(2000,1,1,0,0)
|
86
86
|
finish=DateTime.new(2005,12,31,8,59)
|
87
87
|
resting_week=week(start,finish,0)
|
@@ -106,7 +106,7 @@ class TestWeek < Test::Unit::TestCase #:nodoc:
|
|
106
106
|
}
|
107
107
|
end
|
108
108
|
|
109
|
-
|
109
|
+
def test_must_add_minutes_in_a_patterned_week
|
110
110
|
start=DateTime.new(2000,1,1,0,0) #saturday
|
111
111
|
finish=DateTime.new(2005,12,31,8,59) #saturday
|
112
112
|
working_week=week(start,finish,0)
|
@@ -138,7 +138,7 @@ class TestWeek < Test::Unit::TestCase #:nodoc:
|
|
138
138
|
}
|
139
139
|
end
|
140
140
|
|
141
|
-
|
141
|
+
def test_must_subtract_minutes_in_a_working_week
|
142
142
|
start=DateTime.new(2000,1,1,0,0)
|
143
143
|
finish=DateTime.new(2005,12,31,8,59)
|
144
144
|
working_week=week(start,finish,1)
|
@@ -162,7 +162,7 @@ class TestWeek < Test::Unit::TestCase #:nodoc:
|
|
162
162
|
}
|
163
163
|
end
|
164
164
|
|
165
|
-
|
165
|
+
def test_must_subtract_minutes_in_a_resting_week
|
166
166
|
start=DateTime.new(2000,1,1,0,0)
|
167
167
|
finish=DateTime.new(2005,12,31,8,59)
|
168
168
|
resting_week=week(start,finish,0)
|
@@ -181,7 +181,7 @@ class TestWeek < Test::Unit::TestCase #:nodoc:
|
|
181
181
|
}
|
182
182
|
end
|
183
183
|
|
184
|
-
|
184
|
+
def test_must_subtract_minutes_in_a_patterned_week
|
185
185
|
start=DateTime.new(2000,1,1,0,0) #saturday
|
186
186
|
finish=DateTime.new(2005,12,31,8,59) #saturday
|
187
187
|
working_week=week(start,finish,0)
|
@@ -213,7 +213,7 @@ class TestWeek < Test::Unit::TestCase #:nodoc:
|
|
213
213
|
}
|
214
214
|
end
|
215
215
|
|
216
|
-
|
216
|
+
def test_must_calculate_difference_between_dates_in_working_week
|
217
217
|
start=DateTime.new(2012,10,1)
|
218
218
|
finish=DateTime.new(2012,10,7)
|
219
219
|
week=week(start,finish,1)
|
@@ -247,7 +247,7 @@ class TestWeek < Test::Unit::TestCase #:nodoc:
|
|
247
247
|
}
|
248
248
|
end
|
249
249
|
|
250
|
-
|
250
|
+
def test_must_calculate_difference_between_dates_in_resting_week
|
251
251
|
|
252
252
|
start=DateTime.new(2012,10,1)
|
253
253
|
finish=DateTime.new(2012,10,7)
|
@@ -281,7 +281,7 @@ class TestWeek < Test::Unit::TestCase #:nodoc:
|
|
281
281
|
}
|
282
282
|
end
|
283
283
|
|
284
|
-
|
284
|
+
def test_must_calculate_difference_between_dates_in_pattern_week
|
285
285
|
start=DateTime.new(2000,1,1)
|
286
286
|
finish=DateTime.new(2012,12,31)
|
287
287
|
week=week(start,finish,1)
|
data/test/test_workpattern.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
2
|
|
3
|
-
class TestWorkpattern <
|
3
|
+
class TestWorkpattern < MiniTest::Unit::TestCase #:nodoc:
|
4
4
|
|
5
5
|
def setup
|
6
6
|
Workpattern.clear()
|
7
7
|
end
|
8
8
|
|
9
|
-
|
9
|
+
def test_must_create_a_working_workpattern
|
10
10
|
name='mywp'
|
11
11
|
base=2001
|
12
12
|
span=11
|
@@ -18,7 +18,7 @@ class TestWorkpattern < Test::Unit::TestCase #:nodoc:
|
|
18
18
|
assert_equal DateTime.new(base+span-1,12,31,23,59), wp.to
|
19
19
|
end
|
20
20
|
|
21
|
-
|
21
|
+
def test_must_set_patterns_correctly
|
22
22
|
name='mypattern'
|
23
23
|
base=2000
|
24
24
|
span=11
|
@@ -48,7 +48,7 @@ class TestWorkpattern < Test::Unit::TestCase #:nodoc:
|
|
48
48
|
|
49
49
|
end
|
50
50
|
|
51
|
-
|
51
|
+
def test_must_add_minutes_in_a_working_workpattern
|
52
52
|
name='mypattern'
|
53
53
|
base=1999
|
54
54
|
span=11
|
@@ -66,7 +66,7 @@ class TestWorkpattern < Test::Unit::TestCase #:nodoc:
|
|
66
66
|
calc_test(wp,tests,clue)
|
67
67
|
end
|
68
68
|
|
69
|
-
|
69
|
+
def test_must_add_minutes_in_a_resting_workpattern
|
70
70
|
name='mypattern'
|
71
71
|
base=1999
|
72
72
|
span=11
|
@@ -87,11 +87,11 @@ class TestWorkpattern < Test::Unit::TestCase #:nodoc:
|
|
87
87
|
calc_test(wp,tests,clue)
|
88
88
|
end
|
89
89
|
|
90
|
-
|
90
|
+
def test_must_add_minutes_in_a_patterned_workpattern
|
91
91
|
assert true
|
92
92
|
end
|
93
93
|
|
94
|
-
|
94
|
+
def test_must_subtract_minutes_in_a_working_workpattern
|
95
95
|
name='mypattern'
|
96
96
|
base=1999
|
97
97
|
span=11
|
@@ -109,7 +109,7 @@ class TestWorkpattern < Test::Unit::TestCase #:nodoc:
|
|
109
109
|
calc_test(wp,tests,clue)
|
110
110
|
end
|
111
111
|
|
112
|
-
|
112
|
+
def test_must_subtract_minutes_in_a_resting_workpattern
|
113
113
|
name='mypattern'
|
114
114
|
base=1999
|
115
115
|
span=11
|
@@ -130,12 +130,12 @@ class TestWorkpattern < Test::Unit::TestCase #:nodoc:
|
|
130
130
|
calc_test(wp,tests,clue)
|
131
131
|
end
|
132
132
|
|
133
|
-
|
133
|
+
def test_must_subtract_minutes_in_a_patterned_workpattern
|
134
134
|
assert true
|
135
135
|
end
|
136
136
|
|
137
137
|
|
138
|
-
|
138
|
+
def test_must_calculate_difference_between_dates_in_working_calender
|
139
139
|
name='mypattern'
|
140
140
|
base=1999
|
141
141
|
span=40
|
@@ -167,15 +167,15 @@ class TestWorkpattern < Test::Unit::TestCase #:nodoc:
|
|
167
167
|
}
|
168
168
|
end
|
169
169
|
|
170
|
-
|
170
|
+
def test_must_calculate_difference_between_minutes_in_resting_workpattern
|
171
171
|
assert true
|
172
172
|
end
|
173
173
|
|
174
|
-
|
174
|
+
def test_must_calculate_difference_between_minutes_in_pattern_workpattern
|
175
175
|
assert true
|
176
176
|
end
|
177
177
|
|
178
|
-
|
178
|
+
def test_must_follow_the_example_in_workpattern
|
179
179
|
mywp=Workpattern.new('My Workpattern',2011,10)
|
180
180
|
mywp.resting(:days => :weekend)
|
181
181
|
mywp.resting(:days =>:weekday, :from_time=>Workpattern.clock(0,0),:to_time=>Workpattern.clock(8,59))
|
@@ -186,7 +186,7 @@ class TestWorkpattern < Test::Unit::TestCase #:nodoc:
|
|
186
186
|
assert_equal DateTime.civil(2011,9,6,18,0), result_date, 'example in workpattern'
|
187
187
|
end
|
188
188
|
|
189
|
-
|
189
|
+
def test_must_calculate_across_week_patterns
|
190
190
|
name='mypattern'
|
191
191
|
base=2011
|
192
192
|
span=11
|
@@ -228,7 +228,7 @@ class TestWorkpattern < Test::Unit::TestCase #:nodoc:
|
|
228
228
|
calc_test(wp,tests,clue)
|
229
229
|
end
|
230
230
|
|
231
|
-
|
231
|
+
def test_must_know_whether_a_time_is_working_or_resting
|
232
232
|
name='working?'
|
233
233
|
base=2011
|
234
234
|
span=11
|
@@ -1,12 +1,12 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
2
|
|
3
|
-
class TestWorkpatternModule <
|
3
|
+
class TestWorkpatternModule < MiniTest::Unit::TestCase #:nodoc:
|
4
4
|
|
5
5
|
def setup
|
6
6
|
Workpattern.clear()
|
7
7
|
end
|
8
8
|
|
9
|
-
|
9
|
+
def test_must_create_workpattern_with_given_name
|
10
10
|
|
11
11
|
wp = Workpattern.new()
|
12
12
|
assert_equal Workpattern::DEFAULT_WORKPATTERN_NAME, wp.name, 'not returned the default workpattern name'
|
@@ -23,9 +23,9 @@ class TestWorkpatternModule < Test::Unit::TestCase #:nodoc:
|
|
23
23
|
|
24
24
|
end
|
25
25
|
|
26
|
-
|
26
|
+
def test_must_raise_error_when_creating_workpattern_with_existing_name
|
27
27
|
|
28
|
-
|
28
|
+
assert_raises NameError do
|
29
29
|
mywp_name='duplicate'
|
30
30
|
wp=Workpattern.new(mywp_name)
|
31
31
|
wp=Workpattern.new(mywp_name)
|
@@ -33,7 +33,7 @@ class TestWorkpatternModule < Test::Unit::TestCase #:nodoc:
|
|
33
33
|
|
34
34
|
end
|
35
35
|
|
36
|
-
|
36
|
+
def test_must_return_an_array_of_all_known_workpattern_objects
|
37
37
|
|
38
38
|
names =%w{fred harry sally}
|
39
39
|
names.each {|name| wp=Workpattern.new(name)}
|
@@ -44,12 +44,12 @@ class TestWorkpatternModule < Test::Unit::TestCase #:nodoc:
|
|
44
44
|
wp_names.each {|name, wp| assert names.include?(name)}
|
45
45
|
end
|
46
46
|
|
47
|
-
|
47
|
+
def test_must_return_empty_array_when_no_workpatterns_exist
|
48
48
|
|
49
49
|
assert Workpattern.to_a.empty?
|
50
50
|
end
|
51
51
|
|
52
|
-
|
52
|
+
def test_must_return_existing_workpattern
|
53
53
|
|
54
54
|
names =%w{fred harry sally}
|
55
55
|
names.each {|name| wp=Workpattern.new(name)}
|
@@ -59,29 +59,29 @@ class TestWorkpatternModule < Test::Unit::TestCase #:nodoc:
|
|
59
59
|
}
|
60
60
|
end
|
61
61
|
|
62
|
-
|
62
|
+
def test_must_raise_error_when_workpattern_does_not_exist
|
63
63
|
|
64
64
|
names =%w{fred harry sally}
|
65
65
|
names.each {|name| wp=Workpattern.new(name)}
|
66
|
-
|
66
|
+
assert_raises NameError do
|
67
67
|
wp=Workpattern.get('missing')
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
-
|
71
|
+
def test_must_delete_existing_workpattern_returning_true
|
72
72
|
|
73
73
|
names =%w{fred harry sally}
|
74
74
|
names.each {|name| wp=Workpattern.new(name)}
|
75
75
|
names.each {|name| assert Workpattern.delete(name)}
|
76
76
|
end
|
77
77
|
|
78
|
-
|
78
|
+
def test_must_return_false_deleting_workpattern_that_does_not_exist
|
79
79
|
names =%w{fred harry sally}
|
80
80
|
names.each {|name| wp=Workpattern.new(name)}
|
81
81
|
assert !Workpattern.delete('missing')
|
82
82
|
end
|
83
83
|
|
84
|
-
|
84
|
+
def test_must_delete_all_workpatterns
|
85
85
|
|
86
86
|
names =%w{fred harry sally}
|
87
87
|
names.each {|name| wp=Workpattern.new(name)}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: workpattern
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Barrie Callender
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -69,17 +69,17 @@ require_paths:
|
|
69
69
|
- lib
|
70
70
|
required_ruby_version: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
|
-
- -
|
72
|
+
- - '>='
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '0'
|
75
75
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
76
|
requirements:
|
77
|
-
- -
|
77
|
+
- - '>='
|
78
78
|
- !ruby/object:Gem::Version
|
79
79
|
version: '0'
|
80
80
|
requirements: []
|
81
81
|
rubyforge_project: workpattern
|
82
|
-
rubygems_version: 2.0.
|
82
|
+
rubygems_version: 2.0.4
|
83
83
|
signing_key:
|
84
84
|
specification_version: 4
|
85
85
|
summary: temporal calculations
|