toggl-worktime 0.1.5 → 0.1.6

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: a3805cf1ac06cf2cb710f00977b7694da03d1a28
4
- data.tar.gz: 5b64340cff02c9ed302abacc1b4d8f1975d89be2
3
+ metadata.gz: 145ec982c592fc482e71954ae7868b0d223e0d63
4
+ data.tar.gz: c820648ad85b0ac6ee3ea967c02b746a17a0a6ad
5
5
  SHA512:
6
- metadata.gz: 63a468bdb8414e0ca3a68300f953b73f68c8b5e6ec98e3d22a660a2ec31c99104192ad6d97f56e8d47c14dfc11e79a490b206a0d938b6e1da2c109d896f8e0f4
7
- data.tar.gz: e2918d856818d65b2cbc15684e87a8ee0a27160aa634e4ff2afecb584a0a416af2d2aee8d64816c76333eb7c6d6b61f89216d1cc5effcef3f0c342438d8ce885
6
+ metadata.gz: 066c63d7e8a0f5a0f382d515e9a8b8b673ed322fb9448c726ca0dcba0cbe0c74765c78fcd46199281fd604f18f9f08d41a66cc961dbc51b47bc7806c18b69f1d
7
+ data.tar.gz: 07023fa7dfd214bc3f7405751e85a4c979424f106391e6015ca9b43631a391651634a45a0ea86007b7b148802a7893076b57e861afb92dfbd7ac24fa5b325722
data/exe/toggl-worktime CHANGED
@@ -26,3 +26,5 @@ puts user['fullname']
26
26
  puts 'worktime'
27
27
 
28
28
  driver.write
29
+
30
+ puts "Total worktime: #{driver.total_time}"
@@ -41,6 +41,15 @@ module Toggl
41
41
  def time_expr(t)
42
42
  t ? t.strftime('%F %T') : 'nil'
43
43
  end
44
+
45
+ def total_time
46
+ time = @merger.total_time
47
+ total_seconds = time.numerator
48
+ hours = total_seconds / (60 * 60)
49
+ minutes = (total_seconds - (hours * 60 * 60)) / 60
50
+ seconds = total_seconds % 60
51
+ format("%02d:%02d:%02d", hours, minutes, seconds)
52
+ end
44
53
  end
45
54
  end
46
55
  end
@@ -4,12 +4,15 @@ module Toggl
4
4
  module Worktime
5
5
  # Time-entries merger
6
6
  class Merger
7
+ attr_reader :total_time
8
+
7
9
  def initialize(time_entries)
8
10
  @time_entries = time_entries
9
11
  @current_start = nil
10
12
  @current_stop = nil
11
13
  @continuing = true
12
14
  @last_stop = nil
15
+ @total_time = 0
13
16
  end
14
17
 
15
18
  def merge
@@ -35,6 +38,7 @@ module Toggl
35
38
  @last_stop = stop
36
39
  @current_start = start if @current_start.nil?
37
40
  @current_stop = stop if @current_stop.nil?
41
+ @total_time += stop - start
38
42
  yield [start, stop]
39
43
  end
40
44
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Toggl
4
4
  module Worktime
5
- VERSION = '0.1.5'
5
+ VERSION = '0.1.6'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: toggl-worktime
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomoya KABE
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-08-15 00:00:00.000000000 Z
11
+ date: 2017-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: togglv8