haora 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8b50be4b063db3e1bdda7a9319f174e9d65c049e
4
- data.tar.gz: 38b6246c198ac1cb532ceb0b13ea1bd93eac779a
3
+ metadata.gz: 85ba46e866948e438e101cb4b2b89d9d3a68d732
4
+ data.tar.gz: f40ca3f38debc0fe0e4a8fd5abb431def1d7cb5d
5
5
  SHA512:
6
- metadata.gz: 14d5b903d8cf19545c965b89bf0c55912f20db05a4d8434f7566469279c826c48b3a7815c3a2dc9eba0c130149b2537041c3cd57e30f316d443c5bdb57adc543
7
- data.tar.gz: 9e17772fea15a6b217ccaebb29853229ee5850d4f2c09712115c2e2b6d8487688f7df18496bea8583cad8e0d90b21836faf540131dd4a4b9039e719a3d095f3b
6
+ metadata.gz: d31a00d0f96b49b5794881362773a2580c05200b40918aa4ce8be63d613522f1d6155f721a3860b0fc7b92717d0defd7e6a9c1dae661e3e8d380f435cb60d986
7
+ data.tar.gz: e0f9bedcd560443a86ef65ea9dfbc9a1bf8ee20544e55a3b716e9847f41011882256b1e73af2008ef8fafdd971cb5486016f5f286b74f012c12d45ef07684096
data/lib/haora/io.rb CHANGED
@@ -19,13 +19,9 @@ module Haora
19
19
 
20
20
  module TextIOImporter
21
21
 
22
- private
23
-
24
22
  DAY_RE = /DAY (\d\d\d\d-\d\d-\d\d)/
25
- TASK_RE = /(\d?\d:\d\d)-(\d\d:\d\d)?\|(.*)\|(.*)?/
26
-
27
- public
28
-
23
+ TASK_RE = /(\d?\d:\d\d)-(\d?\d:\d\d)?\|(.*)\|(.*)?/
24
+
29
25
  def import(io)
30
26
  @workbook = Workbook.new
31
27
  io.each_line { |line|
data/lib/haora/project.rb CHANGED
@@ -36,4 +36,4 @@ module Haora
36
36
 
37
37
  end
38
38
 
39
- end
39
+ end
@@ -1,26 +1,25 @@
1
1
  module Haora
2
-
3
2
  class Renderer
4
-
5
3
  private
6
4
 
7
5
  def rendered_timespan(start, stop)
8
- timespan = '%s - %s' % [start.to_s, stop.nil? ? ' now ' : stop.to_s]
9
- timespan.prepend(' ') if timespan.length < 13
10
- timespan
6
+ start = start.to_s
7
+ start.prepend(' ') if start.length < 5
8
+ stop = stop.nil? ? ' now ' : stop.to_s
9
+ stop.prepend(' ') if stop.length < 5
10
+ format('%s - %s', start, stop)
11
11
  end
12
12
 
13
13
  def rendered_duration(hours)
14
- '%5.2f' % hours
14
+ format('%5.2f', hours)
15
15
  end
16
-
17
16
  end
18
17
 
19
18
  class DayRenderer < Renderer
20
-
21
19
  def render(day)
22
20
  raise 'none' if day.tasks.empty?
23
- %W(#{rendered_date_of(day)} #{rendered(day.tasks)} #{rendered_total(day)}).join($/)
21
+ %W(#{rendered_date_of(day)} #{rendered(day.tasks)} #{rendered_total(day)})
22
+ .join("\n")
24
23
  end
25
24
 
26
25
  private
@@ -32,40 +31,48 @@ module Haora
32
31
  end
33
32
 
34
33
  def rendered(tasks)
35
- tasks.map { |task| rendered_task(task, tasks[tasks.index(task) + 1]) }.join($/)
34
+ tasks
35
+ .map { |task| rendered_task(task, tasks[tasks.index(task) + 1]) }
36
+ .join("\n")
36
37
  end
37
38
 
38
39
  def rendered_total(day)
39
- day.project_names
40
- .collect { |name| rendered_project_total(name, day.duration(of_project: name)) }
41
- .push(' Total = %5.2f' % day.hours)
42
- .join($/)
40
+ day
41
+ .project_names
42
+ .collect { |name| rendered_project_total(name, day.duration(of_project: name)) }
43
+ .push(' Total = %5.2f' % day.hours)
44
+ .join("\n")
43
45
  end
44
46
 
45
47
  def rendered_project_total(name, duration)
46
- total = '%s =' % name[0..12]
47
- '%s %5.2f' % [total.rjust(15), duration.hours]
48
+ total = format('%s =', name[0..12])
49
+ format('%s %5.2f', total.rjust(15), duration.hours)
48
50
  end
49
51
 
50
52
  def rendered_task(task, next_task)
51
53
  timespan = rendered_timespan(task.start, task.stop)
52
54
  duration = rendered_duration(task.duration.hours)
55
+ output = rendered_task_info(task, timespan, duration)
56
+ with_rendered_gap(task, next_task, output)
57
+ end
58
+
59
+ def rendered_task_info(task, timespan, duration)
53
60
  if task.project.noname?
54
- output = '%s = %s %s' % [timespan, duration, task.text]
61
+ output = format('%s = %s %s',
62
+ timespan, duration, task.text)
55
63
  else
56
- output = '%s = %s %s: %s' % [timespan, duration, task.project.name, task.text]
64
+ output = format('%s = %s %s: %s',
65
+ timespan, duration, task.project.name, task.text)
57
66
  end
58
- include_rendered_gap(task, next_task, output)
67
+ output
59
68
  end
60
69
 
61
- def include_rendered_gap(task, next_task, output)
70
+ def with_rendered_gap(task, next_task, output)
62
71
  unless next_task.nil?
63
72
  gap = task.gap(to_next: next_task)
64
- output << "\n %dm" % gap.minutes unless gap.minutes == 0
73
+ output << format("\n %dm", gap.minutes) unless gap.minutes.zero?
65
74
  end
66
75
  output
67
76
  end
68
-
69
77
  end
70
-
71
78
  end
@@ -54,8 +54,8 @@ module Haora
54
54
  end
55
55
 
56
56
  def parts
57
- {:hours => @minutes / 60,
58
- :minutes => @minutes % 60}
57
+ { hours: @minutes / 60,
58
+ minutes: @minutes % 60 }
59
59
  end
60
60
 
61
61
  def hours
@@ -71,7 +71,7 @@ module Haora
71
71
  end
72
72
 
73
73
  def to_s
74
- '%d h %d m' % [parts[:hours], parts[:minutes]]
74
+ format('%d h %d m', parts[:hours], parts[:minutes])
75
75
  end
76
76
 
77
77
  private
data/lib/haora/version.rb CHANGED
@@ -1,5 +1,3 @@
1
1
  module Haora
2
-
3
- VERSION = '0.1.0'
4
-
2
+ VERSION = '0.1.1'.freeze
5
3
  end
data/lib/haora.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'English'
2
+
1
3
  require 'haora/version'
2
4
  require 'haora/timestamp'
3
5
  require 'haora/task'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: haora
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dirk Rademann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-19 00:00:00.000000000 Z
11
+ date: 2017-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gli
@@ -116,7 +116,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
116
116
  requirements:
117
117
  - - ">="
118
118
  - !ruby/object:Gem::Version
119
- version: '0'
119
+ version: 2.3.3
120
120
  required_rubygems_version: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - ">="