ptimelog 0.7.0 → 0.8.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
  SHA256:
3
- metadata.gz: f72b05fa5e616ace4ab1279b49b23bba94f5130edd06f54a1e8b21bda1a67d35
4
- data.tar.gz: 334c78339b815942e0c3155d49ee8bb601603ab682936f240370eeeabe209196
3
+ metadata.gz: 9ef3bd0d847dd1a258f83f7e1a41123352f4831270d89f550560d0ae802c3f72
4
+ data.tar.gz: 4a407b654336ca4e37272dffa964e7abeceb478ffb46d1f54926fa2fec0700a8
5
5
  SHA512:
6
- metadata.gz: 400d45182b50402b0832adb98b4c31ea84ff1c5fb9b815c43ba9d575257f9bb371d7db920270399d74f97a6f2a6bb9d7b57d1a35cff4bdf3e15d0a085a0f7295
7
- data.tar.gz: 5b8c16be0f1a3c6b3b4ae01442abaf10c381d860922cf84c58abc097ab9f1d1c82deb235e4857f58ca0b75654bc3df34b716d413a2692876e73e101e0e13f85c
6
+ metadata.gz: 4441aa2504527e658d29c83903e94a8e939f5f2bfbb529cb2f3cb4dabc57b0766ae0674784888f1696a9a85a5137285064b71edb089218d9bdf38170daf88b47
7
+ data.tar.gz: 44265b7b8be6540b726e61919f912c1cbd460636b88b3da2296dc4114f940644b72124fa89f893e67bb7823c104a5948d6227ef6f251ee4e1a1ef4179dc64bf1
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2017-2018 Matthias Viehweger
3
+ Copyright (c) 2017-2020 Matthias Viehweger
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -9,7 +9,8 @@ module Ptimelog
9
9
 
10
10
  return unless needs_entries?
11
11
 
12
- @entries = Ptimelog::Day.new(day).entries
12
+ @entries = {}
13
+ self.entries = Ptimelog::Day.new(day).entries
13
14
  end
14
15
 
15
16
  def needs_entries?
@@ -4,17 +4,27 @@ module Ptimelog
4
4
  module Command
5
5
  # show entries of one day or all of them
6
6
  class Show < Base
7
+ def initialize(*args)
8
+ @durations = Hash.new(0)
9
+
10
+ super
11
+ end
12
+
7
13
  def needs_entries?
8
14
  true
9
15
  end
10
16
 
11
17
  def run
12
18
  @entries.each do |date, list|
13
- puts date, '----------'
19
+ puts date,
20
+ '----------'
14
21
  list.each do |entry|
15
22
  puts entry
16
23
  end
17
- puts nil
24
+ puts '----------',
25
+ "Total work done: #{duration(date)} hours",
26
+ '----------------------------',
27
+ nil
18
28
  end
19
29
  end
20
30
 
@@ -23,19 +33,15 @@ module Ptimelog
23
33
  @entries[date] = []
24
34
 
25
35
  list.each do |entry|
26
- @entries[date] << [
27
- entry.start_time, '-', entry.finish_time,
28
- [
29
- entry.ticket,
30
- entry.description,
31
- entry.tags,
32
- entry.account,
33
- (entry.billable? ? '$' : nil),
34
- ].compact.join(' ∴ '),
35
- ].compact.join(' ')
36
+ @durations[date] += entry.duration
37
+ @entries[date] << entry.to_s
36
38
  end
37
39
  end
38
40
  end
41
+
42
+ def duration(date)
43
+ Time.at(@durations[date]).utc.strftime('%H:%M')
44
+ end
39
45
  end
40
46
  end
41
47
  end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'time'
4
+
3
5
  module Ptimelog
4
6
  # Dataclass to wrap an entry
5
7
  class Entry
@@ -70,15 +72,19 @@ module Ptimelog
70
72
  @account, @billable = infer_account_and_billable
71
73
  end
72
74
 
75
+ def duration
76
+ (Time.parse(@finish_time) - Time.parse(@start_time)).to_i
77
+ end
78
+
73
79
  def to_s
80
+ billable = billable? ? '$' : nil
74
81
  [
75
82
  @start_time, '-', @finish_time,
76
- [@ticket, @description, @tags, @account].compact.join(' : '),
83
+ [@ticket, @description, @tags, @account, billable].compact.join(' '),
77
84
  ].compact.join(' ')
78
85
  end
79
86
 
80
87
  # make sortable/def <=>
81
- # duration if start and finish is set
82
88
 
83
89
  private
84
90
 
@@ -16,5 +16,5 @@
16
16
  # with an improvement. Keep in mind that this is also covered by rspec so I
17
17
  # expect (pun intended) 100% test-coverage for any additional code.
18
18
  module Ptimelog
19
- VERSION = '0.7.0'
19
+ VERSION = '0.8.0'
20
20
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ptimelog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthias Viehweger
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-04-06 00:00:00.000000000 Z
11
+ date: 2020-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: naught