toggl_cli 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/toggl_cli +5 -1
  3. data/lib/toggl_cli.rb +14 -0
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a21f3e14f042c55beb949dad6b704e2aee38e718cd858b146f9363d927666623
4
- data.tar.gz: 81494fab140902260a3adede85fe6b03fbe13e65529f6d9058ac52577cac6890
3
+ metadata.gz: f921feb5c6cf10b6b9e5916f9fec61a94c1ee2dd3126872e8fb8fbb4e8591566
4
+ data.tar.gz: 9a0361b9820ea32fd3db5d25f4a175f0ee71cf3ee1927a57b9eeaad18449ca78
5
5
  SHA512:
6
- metadata.gz: 8dcc9a1fa959370385439b404858f71d6e8283b6c236aeafc4ecd233ad839ce6cd93fa234a7305980f562f9d27d3ff7c737c7ea66c6d893e67e4f6008225d05b
7
- data.tar.gz: 7b899a8e178ca3cc7aaca9557a264e39a76bcf7e9424f5565c4ab21a8e91af511e3870da87e400bf6b24b24bec6fa2cfa2355ef6a7d4a975486e9969e2dd506a
6
+ metadata.gz: 654c6d0f915f714224df133fd12ab07f745d2f3e7acf9b50d94909dcd916b87064725ddb4e1cacfa6daf4cbc83a39055a1030c1fcabab3cd40af9cc88866ce10
7
+ data.tar.gz: 4e103afcfc01b80d75931ab4e5defc2620e037b0bc092536374c4efe7f04d7fe5fd07c1255f70a53cd0ea2ab76c801c126a1b81053c8ac455d7a26d332ed9b57
@@ -18,7 +18,11 @@ when 'start'
18
18
  puts "Timer Started"
19
19
  when 'stop'
20
20
  result = @toggl_cli.stop
21
- puts "Timer Stopped. Duration: #{result['duration']}."
21
+ duration = (result['duration'].to_i / 60.0).round(2)
22
+ puts "Timer Stopped. Duration: #{duration} minutes."
23
+ when 'today'
24
+ result = @toggl_cli.today
25
+ puts "You have logged #{result} minutes or #{(result/60.0).round(2)} hours today"
22
26
  else
23
27
  puts "Uh-oh! I haven't learned that command yet"
24
28
  end
@@ -1,6 +1,7 @@
1
1
  require 'togglv8'
2
2
  require 'json'
3
3
  require 'yaml'
4
+ require 'date'
4
5
 
5
6
  class TogglCLI
6
7
  def initialize
@@ -31,4 +32,17 @@ class TogglCLI
31
32
  result = @toggl_api.stop_time_entry(current['id'])
32
33
  end
33
34
  end
35
+
36
+ def today
37
+ dates = {
38
+ start_date: Time.parse(Date.today.to_s).to_s,
39
+ end_date: Time.now.to_s
40
+ }
41
+ total = 0
42
+ result = @toggl_api.get_time_entries(dates)
43
+ result.each do |r|
44
+ total = total + r['duration']
45
+ end
46
+ (total / 60.0).round(2)
47
+ end
34
48
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: toggl_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Blake Erickson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-22 00:00:00.000000000 Z
11
+ date: 2019-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: togglv8