what_have_i_done 0.0.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8cef645c976df3cce73b279605de6dd19c36cb13
4
+ data.tar.gz: 6ef570c5af4ac44e0628377f4d82019ffd927f05
5
+ SHA512:
6
+ metadata.gz: 1fbb51ab708ad25c3145430a0b8b502aeb400d0e1b64ce4a8c5d16c26869b175692ee28a85f0f35fbb2ee37ed715d917e5a235b1608795ebafd38490503d2e48
7
+ data.tar.gz: f8b7c4b435982c06ae55e9f1df0184ec3e0b9bf6c063d48d388dd279ff7be5b3baea76789b00f0b284175e0d94c6ac0a5451ef63be9a528a06239ed8287d1b9c
@@ -0,0 +1,2 @@
1
+ metric_fu
2
+ *.gem
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'pry'
@@ -0,0 +1,39 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ what_have_i_don (0.0.1)
5
+ i18n
6
+ rainbow
7
+ togglv8
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ coderay (1.1.0)
13
+ faraday (0.9.2)
14
+ multipart-post (>= 1.2, < 3)
15
+ i18n (0.7.0)
16
+ logger (1.2.8)
17
+ method_source (0.8.2)
18
+ multipart-post (2.0.0)
19
+ oj (2.14.3)
20
+ pry (0.10.3)
21
+ coderay (~> 1.1.0)
22
+ method_source (~> 0.8.1)
23
+ slop (~> 3.4)
24
+ rainbow (2.0.0)
25
+ slop (3.6.0)
26
+ togglv8 (1.0.4)
27
+ faraday
28
+ logger
29
+ oj
30
+
31
+ PLATFORMS
32
+ ruby
33
+
34
+ DEPENDENCIES
35
+ pry
36
+ what_have_i_don!
37
+
38
+ BUNDLED WITH
39
+ 1.10.6
@@ -0,0 +1,26 @@
1
+ # What have I done?
2
+
3
+ Give me a readable recap of everything I logged into Toggl today.
4
+ This should save me about 20 seconds every day. After a year, that'll sum up to more than an hour, so yeah...
5
+
6
+ # What does this do exactly?
7
+
8
+ Glad you asked. Let me show you:
9
+
10
+ ![terminal screenshot](screenshot.png)
11
+
12
+ # I want this
13
+
14
+ 1. Install: `gem install what_have_i_done`
15
+ 2. Get your Toggl API Key from [your profile page](https://www.toggl.com/app/profile) and store it in `~/.toggl`
16
+ 3. Use at will: `what_have_i_done`
17
+
18
+ Pro tip: `alias what="what_have_i_done"`
19
+
20
+ # Why the f***?
21
+
22
+ Because I'm currently doing this manually every day to fill in our company's daily report (for time tracking, billing, and blah blah <corporate giberish> blah productivity blah)
23
+
24
+ # Roadmap
25
+
26
+ The next step would be to have this automatically submit the report in some way.
@@ -0,0 +1,6 @@
1
+ task :console do
2
+ require 'pry'
3
+ require_relative './lib/what_have_i_done'
4
+ ARGV.clear
5
+ Pry.start
6
+ end
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
3
+
4
+ require 'rubygems'
5
+ require 'what_have_i_done'
6
+
7
+ WhatHaveIDone::Runner.new.run
@@ -0,0 +1,3 @@
1
+ require 'togglv8'
2
+
3
+ require 'what_have_i_done/runner'
@@ -0,0 +1,60 @@
1
+ require 'rainbow'
2
+
3
+ module WhatHaveIDone
4
+ class Runner
5
+ def initialize()
6
+ @client = TogglV8::API.new
7
+ end
8
+
9
+ def run
10
+ entries = client.get_time_entries(start_date: Date.today.to_datetime)
11
+ entries_by_project = entries.group_by { |entry| entry["pid"] }
12
+ projects = entries_by_project.keys.map { |pid| client.get_project(pid) }
13
+
14
+ projects.each do |project|
15
+ project_entries = entries_by_project[project["id"]]
16
+ time_spent = duration_for_entries(project_entries)
17
+ entries_str = project_entries.map do |entry|
18
+ entry["description"]
19
+ end.uniq.join('; ')
20
+
21
+ subtitle project['name']
22
+ subtitle "#{seconds_as_time(time_spent)} (#{seconds_as_hours(time_spent)})"
23
+ text "#{entries_str}\n\n"
24
+ end
25
+
26
+ total_time = duration_for_entries(entries)
27
+
28
+ title "Total time today:"
29
+ title "#{seconds_as_time(total_time)} (#{seconds_as_hours(total_time)})"
30
+ end
31
+
32
+ private
33
+
34
+ attr_reader :client
35
+
36
+ def duration_for_entries(entries)
37
+ entries.map { |entry| entry["duration"] }.inject(0, &:+)
38
+ end
39
+
40
+ def seconds_as_time(seconds)
41
+ Time.at(seconds).utc.strftime("%H:%M:%S")
42
+ end
43
+
44
+ def seconds_as_hours(seconds)
45
+ (seconds / (60.0 * 60.0)).round(2).to_s + "h"
46
+ end
47
+
48
+ def subtitle(txt)
49
+ puts Rainbow("# #{txt}").blue
50
+ end
51
+
52
+ def title(txt)
53
+ puts Rainbow("# #{txt}").green
54
+ end
55
+
56
+ def text(txt)
57
+ puts txt
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,3 @@
1
+ module WhatHaveIDone
2
+ VERSION = '0.0.1'
3
+ end
Binary file
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'what_have_i_done/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "what_have_i_done"
8
+ gem.version = WhatHaveIDone::VERSION
9
+ gem.authors = ["Miguel Palhas"]
10
+ gem.email = ["miguel@subvisual.co"]
11
+ gem.summary = %q{Provide me a summary of my toggl work day}
12
+ gem.homepage = "https://github.com/naps62/what_have_i_done"
13
+
14
+ gem.files = `git ls-files`.split($/)
15
+ gem.executables = ['what_have_i_done']
16
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
17
+ gem.require_paths = ["lib"]
18
+
19
+ gem.licenses = ['MIT']
20
+
21
+ gem.required_ruby_version = '>= 1.9.3'
22
+ gem.add_dependency 'togglv8', '~> 1.0.0'
23
+ gem.add_dependency 'rainbow', '~> 2.0.0'
24
+ end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: what_have_i_done
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Miguel Palhas
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-01-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: togglv8
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rainbow
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 2.0.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 2.0.0
41
+ description:
42
+ email:
43
+ - miguel@subvisual.co
44
+ executables:
45
+ - what_have_i_done
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - Gemfile
51
+ - Gemfile.lock
52
+ - README.md
53
+ - Rakefile
54
+ - bin/what_have_i_done
55
+ - lib/what_have_i_done.rb
56
+ - lib/what_have_i_done/runner.rb
57
+ - lib/what_have_i_done/version.rb
58
+ - screenshot.png
59
+ - what_have_i_done.gemspec
60
+ homepage: https://github.com/naps62/what_have_i_done
61
+ licenses:
62
+ - MIT
63
+ metadata: {}
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: 1.9.3
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubyforge_project:
80
+ rubygems_version: 2.4.8
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: Provide me a summary of my toggl work day
84
+ test_files: []