time_distribution 2.2.0 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -0
- data/README.md +4 -1
- data/lib/time_distribution/task.rb +9 -0
- data/lib/time_distribution/task_list.rb +1 -1
- data/lib/time_distribution/version.rb +1 -1
- data/lib/time_distribution/work_day.rb +7 -5
- data/lib/time_distribution/work_day_collection.rb +5 -0
- data/spec/work_day_collection_spec.rb +17 -10
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b16fb3cb13125af20b1382020d1d46191cca65e
|
4
|
+
data.tar.gz: 49b34753244271ade8ca898f2e529225caab6a46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d01ea7697d035587924f1f71fdb1f9b200b22d770ea230a12a5bf543c3c4efd445832f0b33d44a8e8970b5e1aab622247337ac499e66d759649a85204cef56b
|
7
|
+
data.tar.gz: 53b9f6ceb4b18f785f37594a75853ef3b29ee80f17e0fbdbfdf2b19f221f96df0a7d33ef6602aea55462bbfe8809073449b0c0b7cb179cc1c5536a2711ae1b12
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
# TimeDistribution
|
2
2
|
|
3
|
-
|
3
|
+
[![Build Status](https://travis-ci.org/dmorrill10/time_distribution.svg?branch=master)](https://travis-ci.org/dmorrill10/time_distribution)
|
4
|
+
|
5
|
+
A small library for associating time intervals with tasks in a human friendly
|
6
|
+
way.
|
4
7
|
|
5
8
|
## Installation
|
6
9
|
|
@@ -17,6 +17,7 @@ module TimeDistribution
|
|
17
17
|
# @param [#to_s] desc The task's description.
|
18
18
|
def initialize(subject, time_taken, desc)
|
19
19
|
@subject = subject
|
20
|
+
@duration_string = time_taken
|
20
21
|
@time_taken = SmartDuration.parse(time_taken)
|
21
22
|
@desc = desc
|
22
23
|
end
|
@@ -31,6 +32,14 @@ module TimeDistribution
|
|
31
32
|
|
32
33
|
def to_s() "#{to_headline}: #{to_desc}" end
|
33
34
|
|
35
|
+
def to_h
|
36
|
+
{
|
37
|
+
'subject' => @subject.to_s,
|
38
|
+
'duration' => @duration_string,
|
39
|
+
'description' => @desc
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
34
43
|
def to_desc() @desc.strip end
|
35
44
|
|
36
45
|
def to_headline
|
@@ -26,11 +26,13 @@ module TimeDistribution
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
def ==(other)
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
29
|
+
def ==(other) (@date == other.date && @tasks == other.tasks) end
|
30
|
+
|
31
|
+
def to_h
|
32
|
+
{
|
33
|
+
'date' => @date.strftime('%B %-d, %Y'),
|
34
|
+
'tasks' => @tasks.map { |e| e.to_h }
|
35
|
+
}
|
34
36
|
end
|
35
37
|
|
36
38
|
# @param [Task] task Adds +task+ to the list of tasks completed on this work day.
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'time'
|
2
|
+
require 'yaml'
|
2
3
|
|
3
4
|
require_relative 'smart_duration'
|
4
5
|
require_relative 'task'
|
@@ -36,6 +37,10 @@ module TimeDistribution
|
|
36
37
|
end
|
37
38
|
end
|
38
39
|
|
40
|
+
def days_to_yaml(opts = {})
|
41
|
+
map { |e| e.to_h }.to_yaml opts
|
42
|
+
end
|
43
|
+
|
39
44
|
def time_worked
|
40
45
|
inject({}) do |hash, d|
|
41
46
|
t = d.time_worked
|
@@ -9,17 +9,18 @@ include TimeDistribution
|
|
9
9
|
describe WorkDayCollection do
|
10
10
|
let(:yml_string_data) do
|
11
11
|
<<-END
|
12
|
+
---
|
12
13
|
-
|
13
14
|
date: April 21, 2016
|
14
15
|
tasks:
|
15
16
|
-
|
16
|
-
subject:
|
17
|
+
subject: time_distribution
|
17
18
|
duration: 6:38pm to 7pm
|
18
19
|
description: |
|
19
20
|
- Comment 1
|
20
21
|
- Comment 2
|
21
22
|
-
|
22
|
-
subject:
|
23
|
+
subject: aaaaaa
|
23
24
|
duration: 4:38am to 6pm
|
24
25
|
description: |
|
25
26
|
- Ahdkjlan akjdlnkfn
|
@@ -27,32 +28,38 @@ describe WorkDayCollection do
|
|
27
28
|
date: April 20, 2016
|
28
29
|
tasks:
|
29
30
|
-
|
30
|
-
subject:
|
31
|
+
subject: time_distribution
|
31
32
|
duration: 6:38pm to 7pm
|
32
33
|
description: |
|
33
34
|
- Comment 3
|
34
35
|
- Comment 4
|
35
36
|
-
|
36
|
-
subject:
|
37
|
+
subject: bbbbb
|
37
38
|
duration: 4:38am to 6pm
|
38
39
|
description: |
|
39
40
|
- jkljkljlkj syowueiorue
|
40
41
|
END
|
41
42
|
end
|
42
43
|
|
44
|
+
let(:patient) do
|
45
|
+
map_data = YAML.load(yml_string_data)
|
46
|
+
_patient = WorkDayCollection.from_map map_data
|
47
|
+
_patient.must_equal map_data.map { |t| WorkDay.from_map t }
|
48
|
+
_patient
|
49
|
+
end
|
43
50
|
|
44
51
|
describe '#from_map' do
|
45
|
-
let(:patient) do
|
46
|
-
map_data = YAML.load(yml_string_data)
|
47
|
-
_patient = WorkDayCollection.from_map map_data
|
48
|
-
_patient.must_equal map_data.map { |t| WorkDay.from_map t }
|
49
|
-
_patient
|
50
|
-
end
|
51
52
|
it 'works' do
|
52
53
|
patient
|
53
54
|
end
|
54
55
|
end
|
55
56
|
|
57
|
+
describe '#days_to_yaml' do
|
58
|
+
it 'works' do
|
59
|
+
patient.must_equal WorkDayCollection.from_map YAML.load(patient.days_to_yaml)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
56
63
|
describe '#new' do
|
57
64
|
it 'with days only' do
|
58
65
|
patient = WorkDayCollection.new('d1', 'd2')
|
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.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dustin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chronic
|
@@ -130,6 +130,7 @@ extensions: []
|
|
130
130
|
extra_rdoc_files: []
|
131
131
|
files:
|
132
132
|
- ".gitignore"
|
133
|
+
- ".travis.yml"
|
133
134
|
- Gemfile
|
134
135
|
- LICENSE.md
|
135
136
|
- README.md
|
@@ -180,3 +181,4 @@ test_files:
|
|
180
181
|
- spec/time_spec.rb
|
181
182
|
- spec/work_day_collection_spec.rb
|
182
183
|
- spec/work_day_spec.rb
|
184
|
+
has_rdoc:
|