time_distribution 1.1.0 → 2.0.0
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.
- checksums.yaml +4 -4
- data/lib/time_distribution/task.rb +20 -0
- data/lib/time_distribution/task_list.rb +43 -0
- data/lib/time_distribution/version.rb +1 -1
- data/lib/time_distribution/work_day.rb +21 -24
- data/lib/time_distribution/work_day_collection.rb +72 -0
- data/spec/support/spec_helper.rb +2 -15
- data/spec/task_spec.rb +22 -0
- data/spec/work_day_collection_spec.rb +239 -0
- data/spec/work_day_spec.rb +49 -5
- data/time_distribution.gemspec +6 -7
- metadata +20 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 012a184af7a05689a0630e43e9c313e0b113f760
|
4
|
+
data.tar.gz: 3c317bb55c5975a74b533df95a9c41ae737ad20b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb4e33e7f23e2f97e0c55c6df47d50282702dae2b1cda502e9717fb13c2d382c29147f806ce36d5505e69420a339509b4855568343dcc01f2a583aec703b9ff3
|
7
|
+
data.tar.gz: 0c6553388a4124e172df1669db9d011ea460bb375f8134d0f61c08a6fdac2fb97dc64431f5ecfba8cd7195ce9853a9a713297f2a0d62e90633a0b6de21b18f6f
|
@@ -12,5 +12,25 @@ module TimeDistribution
|
|
12
12
|
@time_taken = SmartDuration.parse(time_taken)
|
13
13
|
@desc = desc
|
14
14
|
end
|
15
|
+
|
16
|
+
def to_s() "#{to_headline}: #{to_desc}" end
|
17
|
+
|
18
|
+
def to_desc() @desc.strip end
|
19
|
+
|
20
|
+
def to_headline
|
21
|
+
"#{to_hours_s} hours of #{@subject}"
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_hours
|
25
|
+
@time_taken.total / (60 * 60).to_f
|
26
|
+
end
|
27
|
+
|
28
|
+
def to_hours_s
|
29
|
+
format('%0.2f', to_hours)
|
30
|
+
end
|
31
|
+
|
32
|
+
def to_ssv
|
33
|
+
format("%-25s%10s", @subject, to_hours_s)
|
34
|
+
end
|
15
35
|
end
|
16
36
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'chronic'
|
2
|
+
require 'ruby-duration'
|
3
|
+
|
4
|
+
module TimeDistribution
|
5
|
+
class TaskList < Array
|
6
|
+
attr_reader :date, :tasks
|
7
|
+
|
8
|
+
def time_worked(*subjects)
|
9
|
+
inject({}) do |times, t|
|
10
|
+
t_subject = t.subject
|
11
|
+
if subjects.empty? || subjects.include?(t_subject)
|
12
|
+
if times[t_subject]
|
13
|
+
times[t_subject] += t.time_taken
|
14
|
+
else
|
15
|
+
times[t_subject] = Duration.new(t.time_taken)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
times
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def to_hours(*subjects)
|
23
|
+
inject(0) do |hours, task|
|
24
|
+
if subjects.empty? || subjects.include?(task.subject)
|
25
|
+
hours += task.to_hours
|
26
|
+
end
|
27
|
+
hours
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def to_md
|
32
|
+
inject('') do |task_string, t|
|
33
|
+
task_string += "- #{t.to_s}\n"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def to_ssv
|
38
|
+
inject('') do |task_string, t|
|
39
|
+
task_string += "#{t.to_ssv}\n"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -1,45 +1,42 @@
|
|
1
1
|
require 'chronic'
|
2
2
|
require 'ruby-duration'
|
3
3
|
|
4
|
+
require 'time_distribution/task_list'
|
5
|
+
|
4
6
|
module TimeDistribution
|
5
7
|
class WorkDay
|
6
8
|
attr_reader :date, :tasks
|
7
9
|
|
8
10
|
# @param [#to_s] date Date of this work day in +Chronic+ compatible format.
|
9
11
|
# @param [Array<Task>] tasks List of tasks done in this work day. Defaults to an empty list.
|
10
|
-
def initialize(date, tasks
|
12
|
+
def initialize(date, *tasks)
|
11
13
|
@date = Chronic.parse(date)
|
12
|
-
@tasks = tasks
|
14
|
+
@tasks = TaskList.new(*tasks)
|
13
15
|
end
|
14
16
|
|
15
17
|
# @param [Task] task Adds +task+ to the list of tasks completed on this work day.
|
16
18
|
def add_task!(task)
|
17
19
|
@tasks << task
|
18
|
-
|
19
20
|
self
|
20
21
|
end
|
21
22
|
|
22
|
-
def time_worked(*subjects)
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
times_to_return.values.first
|
40
|
-
else
|
41
|
-
times_to_return
|
42
|
-
end
|
23
|
+
def time_worked(*subjects) @tasks.time_worked *subjects end
|
24
|
+
|
25
|
+
def to_hours(*subjects) @tasks.to_hours *subjects end
|
26
|
+
|
27
|
+
def to_md
|
28
|
+
(
|
29
|
+
@date.strftime('%b %-d, %Y') +
|
30
|
+
"\n============================\n" +
|
31
|
+
@tasks.to_md
|
32
|
+
)
|
33
|
+
end
|
34
|
+
|
35
|
+
def to_ssv
|
36
|
+
(
|
37
|
+
"# #{@date.strftime('%b %-d, %Y')}\n" +
|
38
|
+
@tasks.to_ssv
|
39
|
+
)
|
43
40
|
end
|
44
41
|
end
|
45
42
|
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'time'
|
2
|
+
|
3
|
+
require_relative 'smart_duration'
|
4
|
+
require_relative 'task'
|
5
|
+
require_relative 'work_day'
|
6
|
+
|
7
|
+
module TimeDistribution
|
8
|
+
class WorkDayCollection < Array
|
9
|
+
# @returns [Hash<symbol,Integer>] Hash from calendar month to the
|
10
|
+
# => number of official work days in that month. Initialized to zero.
|
11
|
+
attr_reader :official_work_days
|
12
|
+
|
13
|
+
MONTHS = [:january, :february, :march, :april, :may, :june, :july, :august, :september, :october, :november, :december]
|
14
|
+
|
15
|
+
private
|
16
|
+
def provide_methods_for_setting_work_days_in_months
|
17
|
+
MONTHS.each do |m|
|
18
|
+
self.class().send(:define_method, "set_official_work_days_in_#{m.to_s}") do |num_days|
|
19
|
+
@official_work_days[m] = num_days
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
public
|
25
|
+
|
26
|
+
def initialize(*days, official_work_days: {})
|
27
|
+
super(days)
|
28
|
+
provide_methods_for_setting_work_days_in_months
|
29
|
+
@official_work_days = official_work_days.dup
|
30
|
+
MONTHS.each do |m|
|
31
|
+
@official_work_days[m] ||= 0
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def time_worked
|
36
|
+
inject({}) do |hash, d|
|
37
|
+
t = d.time_worked
|
38
|
+
if t.respond_to?(:each_key)
|
39
|
+
t.each_key do |key|
|
40
|
+
hash[key] = Duration.new(0) unless hash[key]
|
41
|
+
hash[key] += t[key]
|
42
|
+
end
|
43
|
+
else
|
44
|
+
d_subject = d.tasks.first.subject
|
45
|
+
hash[d_subject] = Duration.new(0) unless hash[d_subject]
|
46
|
+
hash[d_subject] += t
|
47
|
+
end
|
48
|
+
hash
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def avg_hours_per_official_work_day(*subjects)
|
53
|
+
hours(*subjects) / @official_work_days.values.inject(:+).to_f
|
54
|
+
end
|
55
|
+
|
56
|
+
def avg_hours_per_day_worked(*subjects)
|
57
|
+
hours(*subjects) / length.to_f
|
58
|
+
end
|
59
|
+
|
60
|
+
def hours(*subjects)
|
61
|
+
inject(0) { |sum, d| sum += d.to_hours(*subjects) }
|
62
|
+
end
|
63
|
+
|
64
|
+
def to_md
|
65
|
+
inject('') { |s, d| s += "#{d.to_md}\n" }
|
66
|
+
end
|
67
|
+
|
68
|
+
def to_ssv
|
69
|
+
inject('') { |s, d| s += "#{d.to_ssv}" }
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
data/spec/support/spec_helper.rb
CHANGED
@@ -3,22 +3,9 @@ SimpleCov.start
|
|
3
3
|
|
4
4
|
require 'minitest/spec'
|
5
5
|
require 'minitest/mock'
|
6
|
+
require 'minitest/autorun'
|
6
7
|
|
7
8
|
begin
|
8
|
-
require 'turn/autorun'
|
9
|
-
Turn.config do |c|
|
10
|
-
# use one of output formats:
|
11
|
-
# :outline - turn's original case/test outline mode [default]
|
12
|
-
# :progress - indicates progress with progress bar
|
13
|
-
# :dotted - test/unit's traditional dot-progress mode
|
14
|
-
# :pretty - new pretty reporter
|
15
|
-
# :marshal - dump output as YAML (normal run mode only)
|
16
|
-
# :cue - interactive testing
|
17
|
-
c.format = :dotted
|
18
|
-
# use humanized test names (works only with :outline format)
|
19
|
-
c.natural = true
|
20
|
-
end
|
21
|
-
|
22
9
|
require 'awesome_print'
|
23
10
|
module Minitest::Assertions
|
24
11
|
def mu_pp(obj)
|
@@ -26,7 +13,7 @@ begin
|
|
26
13
|
end
|
27
14
|
end
|
28
15
|
|
29
|
-
require 'pry-rescue/minitest'
|
16
|
+
# require 'pry-rescue/minitest'
|
30
17
|
rescue LoadError
|
31
18
|
end
|
32
19
|
|
data/spec/task_spec.rb
CHANGED
@@ -19,4 +19,26 @@ describe Task do
|
|
19
19
|
patient.desc.must_equal x_description
|
20
20
|
end
|
21
21
|
end
|
22
|
+
describe 'to_s' do
|
23
|
+
it 'works' do
|
24
|
+
x_subject = 'subject'
|
25
|
+
x_time_taken = '10 min'
|
26
|
+
x_description = 'interesting description'
|
27
|
+
|
28
|
+
patient = Task.new(x_subject, x_time_taken, x_description)
|
29
|
+
|
30
|
+
patient.to_s.must_equal "#{format('%0.2f', (10/60.0))} hours of #{x_subject}: #{x_description}"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
describe 'to_hours' do
|
34
|
+
it 'works' do
|
35
|
+
x_subject = 'subject'
|
36
|
+
x_time_taken = '10 min'
|
37
|
+
x_description = 'interesting description'
|
38
|
+
|
39
|
+
patient = Task.new(x_subject, x_time_taken, x_description)
|
40
|
+
|
41
|
+
patient.to_hours.must_equal (10/60.0)
|
42
|
+
end
|
43
|
+
end
|
22
44
|
end
|
@@ -0,0 +1,239 @@
|
|
1
|
+
require_relative 'support/spec_helper'
|
2
|
+
|
3
|
+
require 'time_distribution/work_day_collection'
|
4
|
+
|
5
|
+
include TimeDistribution
|
6
|
+
describe WorkDayCollection do
|
7
|
+
describe '#new' do
|
8
|
+
it 'with days only' do
|
9
|
+
patient = WorkDayCollection.new('d1', 'd2')
|
10
|
+
patient.to_a.must_equal ['d1', 'd2']
|
11
|
+
patient.official_work_days.must_equal ({
|
12
|
+
january: 0,
|
13
|
+
february: 0,
|
14
|
+
march: 0,
|
15
|
+
april: 0,
|
16
|
+
may: 0,
|
17
|
+
june: 0,
|
18
|
+
july: 0,
|
19
|
+
august: 0,
|
20
|
+
september: 0,
|
21
|
+
october: 0,
|
22
|
+
november: 0,
|
23
|
+
december: 0
|
24
|
+
})
|
25
|
+
patient.respond_to?(:set_official_work_days_in_january).must_equal true
|
26
|
+
patient.respond_to?(:set_official_work_days_in_february).must_equal true
|
27
|
+
patient.respond_to?(:set_official_work_days_in_march).must_equal true
|
28
|
+
patient.respond_to?(:set_official_work_days_in_april).must_equal true
|
29
|
+
patient.respond_to?(:set_official_work_days_in_may).must_equal true
|
30
|
+
patient.respond_to?(:set_official_work_days_in_june).must_equal true
|
31
|
+
patient.respond_to?(:set_official_work_days_in_july).must_equal true
|
32
|
+
patient.respond_to?(:set_official_work_days_in_august).must_equal true
|
33
|
+
patient.respond_to?(:set_official_work_days_in_september).must_equal true
|
34
|
+
patient.respond_to?(:set_official_work_days_in_october).must_equal true
|
35
|
+
patient.respond_to?(:set_official_work_days_in_november).must_equal true
|
36
|
+
patient.respond_to?(:set_official_work_days_in_december).must_equal true
|
37
|
+
end
|
38
|
+
it 'with days and official work schedule' do
|
39
|
+
x_official_work_days = {
|
40
|
+
january: 0,
|
41
|
+
february: 20,
|
42
|
+
march: 0,
|
43
|
+
april: 30,
|
44
|
+
may: 14,
|
45
|
+
june: 0,
|
46
|
+
july: 0,
|
47
|
+
august: 16,
|
48
|
+
september: 0,
|
49
|
+
october: 0,
|
50
|
+
november: 0,
|
51
|
+
december: 12
|
52
|
+
}
|
53
|
+
patient = WorkDayCollection.new('d1', 'd2', official_work_days: x_official_work_days.dup)
|
54
|
+
patient.to_a.must_equal ['d1', 'd2']
|
55
|
+
patient.official_work_days.must_equal x_official_work_days
|
56
|
+
patient.respond_to?(:set_official_work_days_in_january).must_equal true
|
57
|
+
patient.respond_to?(:set_official_work_days_in_february).must_equal true
|
58
|
+
patient.respond_to?(:set_official_work_days_in_march).must_equal true
|
59
|
+
patient.respond_to?(:set_official_work_days_in_april).must_equal true
|
60
|
+
patient.respond_to?(:set_official_work_days_in_may).must_equal true
|
61
|
+
patient.respond_to?(:set_official_work_days_in_june).must_equal true
|
62
|
+
patient.respond_to?(:set_official_work_days_in_july).must_equal true
|
63
|
+
patient.respond_to?(:set_official_work_days_in_august).must_equal true
|
64
|
+
patient.respond_to?(:set_official_work_days_in_september).must_equal true
|
65
|
+
patient.respond_to?(:set_official_work_days_in_october).must_equal true
|
66
|
+
patient.respond_to?(:set_official_work_days_in_november).must_equal true
|
67
|
+
patient.respond_to?(:set_official_work_days_in_december).must_equal true
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe '#time_worked' do
|
72
|
+
it 'works' do
|
73
|
+
patient = new_full_patient
|
74
|
+
patient.time_worked.must_equal ({
|
75
|
+
:taxes => Duration.new(14760),
|
76
|
+
:cmput659 => Duration.new(31920),
|
77
|
+
:cprg => Duration.new(3600),
|
78
|
+
:masters_research => Duration.new(3600)
|
79
|
+
})
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe '#avg_hours_per_official_work_day' do
|
84
|
+
it 'works without argument' do
|
85
|
+
patient = new_full_patient
|
86
|
+
patient.avg_hours_per_official_work_day.must_equal (
|
87
|
+
14.9666666666666667 / (1 + 20 + 10 + 30 + 14 + 0 + 0 + 16 + 0 + 0 + 0 + 12)
|
88
|
+
)
|
89
|
+
end
|
90
|
+
it 'works with arguments' do
|
91
|
+
patient = new_full_patient
|
92
|
+
patient.avg_hours_per_official_work_day(:cprg, :taxes).must_equal (
|
93
|
+
5.1 / (1 + 20 + 10 + 30 + 14 + 0 + 0 + 16 + 0 + 0 + 0 + 12)
|
94
|
+
)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
describe '#hours' do
|
99
|
+
it 'works without argument' do
|
100
|
+
patient = new_full_patient
|
101
|
+
patient.hours.must_equal 14.9666666666666667
|
102
|
+
end
|
103
|
+
it 'works with argument' do
|
104
|
+
patient = new_full_patient
|
105
|
+
patient.hours(:cprg, :taxes).must_equal 5.1
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
describe '#avg_hours_per_day_worked' do
|
110
|
+
it 'works without argument' do
|
111
|
+
patient = new_full_patient
|
112
|
+
patient.avg_hours_per_day_worked.must_equal 14.9666666666666667 / 2.0
|
113
|
+
end
|
114
|
+
it 'works without argument' do
|
115
|
+
patient = new_full_patient
|
116
|
+
patient.avg_hours_per_day_worked(:cprg, :taxes).must_equal 5.1 / 2.0
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
describe '#to_md' do
|
121
|
+
it 'works' do
|
122
|
+
patient = new_full_patient
|
123
|
+
patient.to_md.must_equal (
|
124
|
+
<<-END
|
125
|
+
Mar 14, 2015
|
126
|
+
============================
|
127
|
+
- 2.60 hours of taxes: Worked on taxes some more
|
128
|
+
- 1.50 hours of taxes: Worked on taxes
|
129
|
+
|
130
|
+
Mar 13, 2015
|
131
|
+
============================
|
132
|
+
- 6.92 hours of cmput659: Finished A7. Used my fourth late day, so I have one left for two assignments
|
133
|
+
- 1.00 hours of cprg: Fixed a bug in no-limit interface
|
134
|
+
- 1.00 hours of masters_research: Attended AI lecture by Gabor on theory related to convex regression
|
135
|
+
- 0.25 hours of cmput659: Listened to a Koller lecture
|
136
|
+
- 1.70 hours of cmput659: Worked on A7
|
137
|
+
|
138
|
+
END
|
139
|
+
)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
describe '#to_ssv' do
|
144
|
+
it 'works' do
|
145
|
+
patient = new_full_patient
|
146
|
+
patient.to_ssv.must_equal (
|
147
|
+
<<-END
|
148
|
+
# Mar 14, 2015
|
149
|
+
taxes 2.60
|
150
|
+
taxes 1.50
|
151
|
+
# Mar 13, 2015
|
152
|
+
cmput659 6.92
|
153
|
+
cprg 1.00
|
154
|
+
masters_research 1.00
|
155
|
+
cmput659 0.25
|
156
|
+
cmput659 1.70
|
157
|
+
END
|
158
|
+
)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
def new_full_patient
|
163
|
+
WorkDayCollection.new(
|
164
|
+
WorkDay.new(
|
165
|
+
'March 14, 2015',
|
166
|
+
[
|
167
|
+
Task.new(
|
168
|
+
:taxes,
|
169
|
+
'12:54pm to 3:30pm',
|
170
|
+
"
|
171
|
+
Worked on taxes some more
|
172
|
+
"
|
173
|
+
),
|
174
|
+
Task.new(
|
175
|
+
:taxes,
|
176
|
+
'11am to 12:30pm',
|
177
|
+
"
|
178
|
+
Worked on taxes
|
179
|
+
"
|
180
|
+
)
|
181
|
+
]
|
182
|
+
),
|
183
|
+
WorkDay.new(
|
184
|
+
'March 13, 2015',
|
185
|
+
[
|
186
|
+
Task.new(
|
187
|
+
:cmput659,
|
188
|
+
'5:30pm to 12:25am',
|
189
|
+
"
|
190
|
+
Finished A7. Used my fourth late day, so I have one left for two assignments
|
191
|
+
"
|
192
|
+
),
|
193
|
+
Task.new(
|
194
|
+
:cprg,
|
195
|
+
'1 hour',
|
196
|
+
"
|
197
|
+
Fixed a bug in no-limit interface
|
198
|
+
"
|
199
|
+
),
|
200
|
+
Task.new(
|
201
|
+
:masters_research,
|
202
|
+
'12pm to 1pm',
|
203
|
+
"
|
204
|
+
Attended AI lecture by Gabor on theory related to convex regression
|
205
|
+
"
|
206
|
+
),
|
207
|
+
Task.new(
|
208
|
+
:cmput659,
|
209
|
+
'11:35am to 11:50am',
|
210
|
+
"
|
211
|
+
Listened to a Koller lecture
|
212
|
+
"
|
213
|
+
),
|
214
|
+
Task.new(
|
215
|
+
:cmput659,
|
216
|
+
'9:53am to 11:35am',
|
217
|
+
"
|
218
|
+
Worked on A7
|
219
|
+
"
|
220
|
+
)
|
221
|
+
]
|
222
|
+
),
|
223
|
+
official_work_days: {
|
224
|
+
january: 1,
|
225
|
+
february: 20,
|
226
|
+
march: 10,
|
227
|
+
april: 30,
|
228
|
+
may: 14,
|
229
|
+
june: 0,
|
230
|
+
july: 0,
|
231
|
+
august: 16,
|
232
|
+
september: 0,
|
233
|
+
october: 0,
|
234
|
+
november: 0,
|
235
|
+
december: 12
|
236
|
+
}
|
237
|
+
)
|
238
|
+
end
|
239
|
+
end
|
data/spec/work_day_spec.rb
CHANGED
@@ -14,6 +14,46 @@ describe WorkDay do
|
|
14
14
|
@patient.date.must_equal Chronic.parse(@x_date)
|
15
15
|
@patient.tasks.must_equal @x_tasks
|
16
16
|
end
|
17
|
+
describe 'to_hours' do
|
18
|
+
it 'works without argument' do
|
19
|
+
@x_tasks[0].expect(:to_hours, 1.1)
|
20
|
+
@x_tasks[1].expect(:to_hours, 2.6)
|
21
|
+
@patient.to_hours.must_equal 1.1 + 2.6
|
22
|
+
end
|
23
|
+
it 'works with arguments' do
|
24
|
+
@x_tasks[0].expect(:to_hours, 1.1)
|
25
|
+
@x_tasks[1].expect(:to_hours, 2.6)
|
26
|
+
@x_tasks[0].expect(:subject, :relevant_task)
|
27
|
+
@x_tasks[1].expect(:subject, :irrelevant_task)
|
28
|
+
@patient.to_hours(:relevant_task).must_equal 1.1
|
29
|
+
|
30
|
+
@x_tasks[0].expect(:to_hours, 1.1)
|
31
|
+
@x_tasks[1].expect(:to_hours, 2.6)
|
32
|
+
@x_tasks[0].expect(:subject, :relevant_task)
|
33
|
+
@x_tasks[1].expect(:subject, :irrelevant_task)
|
34
|
+
@patient.to_hours(:irrelevant_task).must_equal 2.6
|
35
|
+
|
36
|
+
@x_tasks[0].expect(:to_hours, 1.1)
|
37
|
+
@x_tasks[1].expect(:to_hours, 2.6)
|
38
|
+
@x_tasks[0].expect(:subject, :relevant_task)
|
39
|
+
@x_tasks[1].expect(:subject, :irrelevant_task)
|
40
|
+
@patient.to_hours(:relevant_task, :irrelevant_task).must_equal 1.1 + 2.6
|
41
|
+
end
|
42
|
+
end
|
43
|
+
describe 'to_md' do
|
44
|
+
it 'works' do
|
45
|
+
@x_tasks[0].expect(:to_s, 'Task 1')
|
46
|
+
@x_tasks[1].expect(:to_s, 'Task 2')
|
47
|
+
@patient.to_md.must_equal (
|
48
|
+
<<-END
|
49
|
+
#{@x_date}
|
50
|
+
============================
|
51
|
+
- Task 1
|
52
|
+
- Task 2
|
53
|
+
END
|
54
|
+
)
|
55
|
+
end
|
56
|
+
end
|
17
57
|
describe '#add_task!' do
|
18
58
|
it 'works' do
|
19
59
|
t3 = MiniTest::Mock.new
|
@@ -30,7 +70,7 @@ describe WorkDay do
|
|
30
70
|
mock_task.expect(:subject, x_subject)
|
31
71
|
mock_task.expect(:time_taken, time_taken_for_each_task)
|
32
72
|
end
|
33
|
-
@patient.time_worked.must_equal (Duration.new(@x_tasks.length * time_taken_for_each_task))
|
73
|
+
@patient.time_worked.must_equal ({x_subject => (Duration.new(@x_tasks.length * time_taken_for_each_task)) })
|
34
74
|
end
|
35
75
|
it 'when more than one subject is present' do
|
36
76
|
time_taken_for_each_task = 23
|
@@ -51,6 +91,8 @@ describe WorkDay do
|
|
51
91
|
t4.expect(:time_taken, time_taken_for_each_task)
|
52
92
|
@x_tasks << t4
|
53
93
|
|
94
|
+
@patient = WorkDay.new @x_date, @x_tasks
|
95
|
+
|
54
96
|
@patient.time_worked.must_equal (
|
55
97
|
{
|
56
98
|
subject_1 => Duration.new(num_subject_1_tasks * time_taken_for_each_task),
|
@@ -78,7 +120,9 @@ describe WorkDay do
|
|
78
120
|
t4.expect(:subject, subject_3)
|
79
121
|
@x_tasks << t4
|
80
122
|
|
81
|
-
@patient.
|
123
|
+
@patient = WorkDay.new @x_date, @x_tasks
|
124
|
+
|
125
|
+
@patient.time_worked(subject_1, subject_2).must_equal (
|
82
126
|
{
|
83
127
|
subject_1 => Duration.new(num_subject_1_tasks * time_taken_for_each_task),
|
84
128
|
subject_2 => Duration.new(time_taken_for_each_task)
|
@@ -104,12 +148,12 @@ describe WorkDay do
|
|
104
148
|
t4.expect(:subject, subject_3)
|
105
149
|
@x_tasks << t4
|
106
150
|
|
151
|
+
@patient = WorkDay.new @x_date, @x_tasks
|
152
|
+
|
107
153
|
@patient.time_worked(subject_1).must_equal (
|
108
|
-
Duration.new(num_subject_1_tasks * time_taken_for_each_task)
|
154
|
+
{subject_1 => Duration.new(num_subject_1_tasks * time_taken_for_each_task)}
|
109
155
|
)
|
110
156
|
end
|
111
|
-
it 'as a single element list' do
|
112
|
-
end
|
113
157
|
end
|
114
158
|
end
|
115
159
|
end
|
data/time_distribution.gemspec
CHANGED
@@ -18,14 +18,13 @@ Gem::Specification.new do |gem|
|
|
18
18
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
19
|
gem.require_paths = ["lib"]
|
20
20
|
|
21
|
-
gem.add_dependency "chronic", '~> 0.
|
21
|
+
gem.add_dependency "chronic", '~> 0.10'
|
22
22
|
gem.add_dependency "chronic_duration", '~> 0.10'
|
23
|
-
gem.add_dependency "ruby-duration", '~> 3.
|
23
|
+
gem.add_dependency "ruby-duration", '~> 3.2'
|
24
24
|
|
25
25
|
gem.add_development_dependency "rake", '~> 10.0'
|
26
|
-
gem.add_development_dependency "
|
27
|
-
gem.add_development_dependency "
|
28
|
-
gem.add_development_dependency "
|
29
|
-
gem.add_development_dependency "
|
30
|
-
gem.add_development_dependency "simplecov", '~> 0.7'
|
26
|
+
gem.add_development_dependency "awesome_print", '~> 1.6'
|
27
|
+
gem.add_development_dependency "minitest", '~> 5.5'
|
28
|
+
gem.add_development_dependency "pry-rescue", '~> 1.4'
|
29
|
+
gem.add_development_dependency "simplecov", '~> 0.9'
|
31
30
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: time_distribution
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dustin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chronic
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
19
|
+
version: '0.10'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0.
|
26
|
+
version: '0.10'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: chronic_duration
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '3.
|
47
|
+
version: '3.2'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '3.
|
54
|
+
version: '3.2'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,76 +66,62 @@ dependencies:
|
|
66
66
|
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '10.0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: turn
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ~>
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0.9'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ~>
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0.9'
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
70
|
name: awesome_print
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
86
72
|
requirements:
|
87
73
|
- - ~>
|
88
74
|
- !ruby/object:Gem::Version
|
89
|
-
version: '1.
|
75
|
+
version: '1.6'
|
90
76
|
type: :development
|
91
77
|
prerelease: false
|
92
78
|
version_requirements: !ruby/object:Gem::Requirement
|
93
79
|
requirements:
|
94
80
|
- - ~>
|
95
81
|
- !ruby/object:Gem::Version
|
96
|
-
version: '1.
|
82
|
+
version: '1.6'
|
97
83
|
- !ruby/object:Gem::Dependency
|
98
84
|
name: minitest
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
100
86
|
requirements:
|
101
87
|
- - ~>
|
102
88
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
89
|
+
version: '5.5'
|
104
90
|
type: :development
|
105
91
|
prerelease: false
|
106
92
|
version_requirements: !ruby/object:Gem::Requirement
|
107
93
|
requirements:
|
108
94
|
- - ~>
|
109
95
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
96
|
+
version: '5.5'
|
111
97
|
- !ruby/object:Gem::Dependency
|
112
98
|
name: pry-rescue
|
113
99
|
requirement: !ruby/object:Gem::Requirement
|
114
100
|
requirements:
|
115
101
|
- - ~>
|
116
102
|
- !ruby/object:Gem::Version
|
117
|
-
version: '1.
|
103
|
+
version: '1.4'
|
118
104
|
type: :development
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
107
|
requirements:
|
122
108
|
- - ~>
|
123
109
|
- !ruby/object:Gem::Version
|
124
|
-
version: '1.
|
110
|
+
version: '1.4'
|
125
111
|
- !ruby/object:Gem::Dependency
|
126
112
|
name: simplecov
|
127
113
|
requirement: !ruby/object:Gem::Requirement
|
128
114
|
requirements:
|
129
115
|
- - ~>
|
130
116
|
- !ruby/object:Gem::Version
|
131
|
-
version: '0.
|
117
|
+
version: '0.9'
|
132
118
|
type: :development
|
133
119
|
prerelease: false
|
134
120
|
version_requirements: !ruby/object:Gem::Requirement
|
135
121
|
requirements:
|
136
122
|
- - ~>
|
137
123
|
- !ruby/object:Gem::Version
|
138
|
-
version: '0.
|
124
|
+
version: '0.9'
|
139
125
|
description: Gem for creating time distribution management systems
|
140
126
|
email:
|
141
127
|
- morrill@ualberta.ca
|
@@ -151,13 +137,16 @@ files:
|
|
151
137
|
- lib/time_distribution.rb
|
152
138
|
- lib/time_distribution/smart_duration.rb
|
153
139
|
- lib/time_distribution/task.rb
|
140
|
+
- lib/time_distribution/task_list.rb
|
154
141
|
- lib/time_distribution/time.rb
|
155
142
|
- lib/time_distribution/version.rb
|
156
143
|
- lib/time_distribution/work_day.rb
|
144
|
+
- lib/time_distribution/work_day_collection.rb
|
157
145
|
- spec/smart_duration_spec.rb
|
158
146
|
- spec/support/spec_helper.rb
|
159
147
|
- spec/task_spec.rb
|
160
148
|
- spec/time_spec.rb
|
149
|
+
- spec/work_day_collection_spec.rb
|
161
150
|
- spec/work_day_spec.rb
|
162
151
|
- time_distribution.gemspec
|
163
152
|
homepage: ''
|
@@ -180,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
180
169
|
version: '0'
|
181
170
|
requirements: []
|
182
171
|
rubyforge_project:
|
183
|
-
rubygems_version: 2.0.
|
172
|
+
rubygems_version: 2.0.3
|
184
173
|
signing_key:
|
185
174
|
specification_version: 4
|
186
175
|
summary: Gem for creating time distribution management systems
|
@@ -189,4 +178,6 @@ test_files:
|
|
189
178
|
- spec/support/spec_helper.rb
|
190
179
|
- spec/task_spec.rb
|
191
180
|
- spec/time_spec.rb
|
181
|
+
- spec/work_day_collection_spec.rb
|
192
182
|
- spec/work_day_spec.rb
|
183
|
+
has_rdoc:
|