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.
- checksums.yaml +4 -4
- data/bin/toggl_cli +5 -1
- data/lib/toggl_cli.rb +14 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f921feb5c6cf10b6b9e5916f9fec61a94c1ee2dd3126872e8fb8fbb4e8591566
|
4
|
+
data.tar.gz: 9a0361b9820ea32fd3db5d25f4a175f0ee71cf3ee1927a57b9eeaad18449ca78
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 654c6d0f915f714224df133fd12ab07f745d2f3e7acf9b50d94909dcd916b87064725ddb4e1cacfa6daf4cbc83a39055a1030c1fcabab3cd40af9cc88866ce10
|
7
|
+
data.tar.gz: 4e103afcfc01b80d75931ab4e5defc2620e037b0bc092536374c4efe7f04d7fe5fd07c1255f70a53cd0ea2ab76c801c126a1b81053c8ac455d7a26d332ed9b57
|
data/bin/toggl_cli
CHANGED
@@ -18,7 +18,11 @@ when 'start'
|
|
18
18
|
puts "Timer Started"
|
19
19
|
when 'stop'
|
20
20
|
result = @toggl_cli.stop
|
21
|
-
|
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
|
data/lib/toggl_cli.rb
CHANGED
@@ -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.
|
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-
|
11
|
+
date: 2019-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: togglv8
|