time_distribution 2.0.2 → 2.1.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a71a5c2af5b49832a2045860f26499d7f4dffe7
|
4
|
+
data.tar.gz: 000bb37d8f5d219162d92e79b3ca7a7b708166ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1bffa9227b70531563e5a90a34a1c7b39f445061a379d252e4ef5975d42f31e4ae504dd6b925a31a0842d0a6c87b8eee3d98c8729192982a8bbb835971659ff3
|
7
|
+
data.tar.gz: 3833eeb5d729993caef2518de9785b04a1e47b43e0c67af8aae9933c4447e6a6a5cd2a73ff40a14ffc4e46f28924d771f7cbf07a703e654f16c84db696ce11ce
|
@@ -34,8 +34,13 @@ module TimeDistribution
|
|
34
34
|
|
35
35
|
def to_ssv
|
36
36
|
(
|
37
|
-
"# #{@date.strftime('%b %-d, %Y')}\n" +
|
38
|
-
|
37
|
+
"# #{@date.strftime('%b %-d, %Y')}\n" + (
|
38
|
+
if block_given?
|
39
|
+
@tasks.to_ssv { |key| yield(key) }
|
40
|
+
else
|
41
|
+
@tasks.to_ssv
|
42
|
+
end
|
43
|
+
)
|
39
44
|
)
|
40
45
|
end
|
41
46
|
end
|
@@ -66,7 +66,91 @@ module TimeDistribution
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def to_ssv
|
69
|
-
inject('')
|
69
|
+
inject('') do |s, d|
|
70
|
+
s += if block_given?
|
71
|
+
"#{d.to_ssv { |key| yield(key) }}"
|
72
|
+
else
|
73
|
+
"#{d.to_ssv}"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def time_worked_to_ssv
|
79
|
+
string = ''
|
80
|
+
time_worked.each do |k,j|
|
81
|
+
string += format(
|
82
|
+
"%-30s%10s\n",
|
83
|
+
(
|
84
|
+
if block_given?
|
85
|
+
yield(k)
|
86
|
+
else
|
87
|
+
k
|
88
|
+
end
|
89
|
+
),
|
90
|
+
format("%0.2f", j.total / 3600.0)
|
91
|
+
)
|
92
|
+
end
|
93
|
+
string
|
94
|
+
end
|
95
|
+
|
96
|
+
def work_days_by_weeks
|
97
|
+
(0..length / 7).inject([]) do |array, week|
|
98
|
+
week_start = 7*week
|
99
|
+
week_end = week_start+6
|
100
|
+
days = self[week_start..week_end]
|
101
|
+
next array if days.empty?
|
102
|
+
|
103
|
+
array << WorkDayCollection.new(*days)
|
104
|
+
yield array.last if block_given?
|
105
|
+
array
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def hours_per_day_by_weeks(*task_types)
|
110
|
+
array = []
|
111
|
+
work_days_by_weeks do |week|
|
112
|
+
array << (
|
113
|
+
week.map do |day|
|
114
|
+
day.to_hours(*task_types)
|
115
|
+
end
|
116
|
+
)
|
117
|
+
yield array.last if block_given?
|
118
|
+
end
|
119
|
+
array
|
120
|
+
end
|
121
|
+
|
122
|
+
def hours_per_week(*task_types)
|
123
|
+
hours = []
|
124
|
+
hours_per_day_by_weeks(*task_types) do |week|
|
125
|
+
hours << week.inject(:+)
|
126
|
+
end
|
127
|
+
hours
|
128
|
+
end
|
129
|
+
|
130
|
+
def subjects
|
131
|
+
map { |day| day.tasks.map { |task| task.subject } }.flatten.sort.uniq
|
132
|
+
end
|
133
|
+
|
134
|
+
def hours_per_week_ssv(*task_types)
|
135
|
+
string = ''
|
136
|
+
hours = []
|
137
|
+
week = 1
|
138
|
+
work_days_by_weeks do |week_collection|
|
139
|
+
string += (
|
140
|
+
"# #{week_collection.first.date.strftime('%b %-d, %Y')}\n" +
|
141
|
+
"# #{week_collection.subjects.join(', ')}\n"
|
142
|
+
)
|
143
|
+
week_hours = week_collection.map do |day|
|
144
|
+
day.to_hours(*task_types)
|
145
|
+
end
|
146
|
+
hours << week_hours.inject(:+)
|
147
|
+
string += (
|
148
|
+
"# " + week_hours.join(', ') + "\n" +
|
149
|
+
format("%-10d%0.2f\n", week + 1, hours.last)
|
150
|
+
)
|
151
|
+
week += 1
|
152
|
+
end
|
153
|
+
string += format("%-10s%0.2f\n", 'Avg', hours.inject(:+) / hours.length)
|
70
154
|
end
|
71
155
|
end
|
72
156
|
end
|
@@ -146,19 +146,78 @@ END
|
|
146
146
|
patient.to_ssv.must_equal (
|
147
147
|
<<-END
|
148
148
|
# Mar 14, 2015
|
149
|
-
taxes
|
150
|
-
taxes
|
149
|
+
taxes 2.60
|
150
|
+
taxes 1.50
|
151
151
|
# Mar 13, 2015
|
152
|
-
cmput659
|
153
|
-
cprg
|
154
|
-
masters_research
|
155
|
-
cmput659
|
156
|
-
cmput659
|
152
|
+
cmput659 6.92
|
153
|
+
cprg 1.00
|
154
|
+
masters_research 1.00
|
155
|
+
cmput659 0.25
|
156
|
+
cmput659 1.70
|
157
157
|
END
|
158
158
|
)
|
159
159
|
end
|
160
160
|
end
|
161
161
|
|
162
|
+
describe '#time_worked_to_ssv' do
|
163
|
+
it 'works' do
|
164
|
+
patient = new_full_patient
|
165
|
+
patient.time_worked_to_ssv do |subject|
|
166
|
+
subject.to_s.split('_').collect(&:capitalize).join
|
167
|
+
end.must_equal (
|
168
|
+
<<-END
|
169
|
+
Taxes 4.10
|
170
|
+
Cmput659 8.87
|
171
|
+
Cprg 1.00
|
172
|
+
MastersResearch 1.00
|
173
|
+
END
|
174
|
+
)
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
describe '#work_days_by_weeks' do
|
179
|
+
it 'works' do
|
180
|
+
patient = new_full_patient
|
181
|
+
patient.work_days_by_weeks.flatten.must_equal patient
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
describe '#hours_per_day_by_weeks' do
|
186
|
+
it 'works' do
|
187
|
+
patient = new_full_patient
|
188
|
+
patient.hours_per_day_by_weeks.must_equal [[4.1, 10.866666666666667]]
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
describe '#hours_per_week' do
|
193
|
+
it 'works' do
|
194
|
+
patient = new_full_patient
|
195
|
+
patient.hours_per_week.must_equal [4.1 + 10.866666666666667]
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
describe '#subjects' do
|
200
|
+
it 'works' do
|
201
|
+
patient = new_full_patient
|
202
|
+
patient.subjects.must_equal [:taxes, :cmput659, :cprg, :masters_research].sort
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
describe '#hours_per_week_ssv' do
|
207
|
+
it 'works' do
|
208
|
+
patient = new_full_patient
|
209
|
+
patient.hours_per_week_ssv.must_equal (
|
210
|
+
<<-END
|
211
|
+
# Mar 14, 2015
|
212
|
+
# cmput659, cprg, masters_research, taxes
|
213
|
+
# 4.1, 10.866666666666667
|
214
|
+
2 14.97
|
215
|
+
Avg 14.97
|
216
|
+
END
|
217
|
+
)
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
162
221
|
def new_full_patient
|
163
222
|
WorkDayCollection.new(
|
164
223
|
WorkDay.new(
|
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: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dustin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chronic
|