hubtime 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.
- data/.gitignore +4 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +56 -0
- data/MIT-LICENSE +20 -0
- data/README.md +109 -0
- data/bin/hubtime +199 -0
- data/hubtime.gemspec +28 -0
- data/lib/hubtime.rb +16 -0
- data/lib/hubtime/activity.rb +494 -0
- data/lib/hubtime/cacher.rb +48 -0
- data/lib/hubtime/charts/graph.erb +92 -0
- data/lib/hubtime/charts/impact.erb +90 -0
- data/lib/hubtime/charts/pie.erb +51 -0
- data/lib/hubtime/commit.rb +42 -0
- data/lib/hubtime/github.rb +67 -0
- data/lib/hubtime/hub_config.rb +122 -0
- data/lib/hubtime/repo.rb +174 -0
- data/lib/hubtime/version.rb +3 -0
- data/readme/graph.png +0 -0
- data/readme/impact.png +0 -0
- data/readme/pie.png +0 -0
- data/readme/stacked.png +0 -0
- metadata +196 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
hubtime (0.0.1)
|
5
|
+
active_support (~> 3.0)
|
6
|
+
commander (~> 4.1)
|
7
|
+
erubis (~> 2.7)
|
8
|
+
hashie (~> 1.2)
|
9
|
+
i18n (~> 0.6)
|
10
|
+
octokit (~> 1.20)
|
11
|
+
terminal-table (~> 1.4)
|
12
|
+
tzinfo (~> 0.3)
|
13
|
+
|
14
|
+
GEM
|
15
|
+
remote: http://rubygems.org/
|
16
|
+
specs:
|
17
|
+
active_support (3.0.0)
|
18
|
+
activesupport (= 3.0.0)
|
19
|
+
activesupport (3.0.0)
|
20
|
+
addressable (2.3.2)
|
21
|
+
commander (4.1.3)
|
22
|
+
highline (~> 1.6.11)
|
23
|
+
erubis (2.7.0)
|
24
|
+
faraday (0.8.4)
|
25
|
+
multipart-post (~> 1.1)
|
26
|
+
faraday_middleware (0.9.0)
|
27
|
+
faraday (>= 0.7.4, < 0.9)
|
28
|
+
hashie (1.2.0)
|
29
|
+
highline (1.6.15)
|
30
|
+
i18n (0.6.1)
|
31
|
+
multi_json (1.5.0)
|
32
|
+
multipart-post (1.1.5)
|
33
|
+
netrc (0.7.7)
|
34
|
+
octokit (1.20.0)
|
35
|
+
addressable (~> 2.2)
|
36
|
+
faraday (~> 0.8)
|
37
|
+
faraday_middleware (~> 0.9)
|
38
|
+
hashie (~> 1.2)
|
39
|
+
multi_json (~> 1.3)
|
40
|
+
netrc (~> 0.7.7)
|
41
|
+
terminal-table (1.4.5)
|
42
|
+
tzinfo (0.3.35)
|
43
|
+
|
44
|
+
PLATFORMS
|
45
|
+
ruby
|
46
|
+
|
47
|
+
DEPENDENCIES
|
48
|
+
active_support
|
49
|
+
commander
|
50
|
+
erubis
|
51
|
+
hashie
|
52
|
+
hubtime!
|
53
|
+
i18n
|
54
|
+
octokit
|
55
|
+
terminal-table
|
56
|
+
tzinfo
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2012 Brian Leonard
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
## Hubtime
|
2
|
+
|
3
|
+
I wanted to be able to see how things went this year, but Github didn't give a graph across all the repositories. I used their API to generate some graphs.
|
4
|
+
|
5
|
+
### Commands
|
6
|
+
|
7
|
+
First, you need to install the gem:
|
8
|
+
|
9
|
+
gem install hubtime
|
10
|
+
|
11
|
+
Note: `hubtime` will add the file `hubtime_config.yml` and the directory `data` on the directory you run the command.
|
12
|
+
|
13
|
+
To give auth (It will store your password encrypted on disk)
|
14
|
+
|
15
|
+
hubtime auth
|
16
|
+
|
17
|
+
To see what repositiories it will pull from
|
18
|
+
|
19
|
+
hubtime repositories
|
20
|
+
|
21
|
+
To ignore some of those
|
22
|
+
|
23
|
+
hubtime ignore bleonard/rails
|
24
|
+
|
25
|
+
Caching is heavily used to not kill Github and speed things up. Caching is done at the sha, time window per repo, and the full history levels.
|
26
|
+
Specifically, if you add another repo or something, you'll want to do this
|
27
|
+
|
28
|
+
hubtime clear activity
|
29
|
+
|
30
|
+
If things are generally messed up and you want to start again, clear it all
|
31
|
+
|
32
|
+
hubtime clear all
|
33
|
+
|
34
|
+
#### To show table of commits and such
|
35
|
+
|
36
|
+
hubtime table
|
37
|
+
hubtime table --months 3
|
38
|
+
hubtime table --unit day
|
39
|
+
hubtime table --unit day --months 1
|
40
|
+
hubtime table --unit year
|
41
|
+
|
42
|
+
hubtime table --unit month
|
43
|
+
+---------+---------+--------+-----------+-----------+
|
44
|
+
| Month | Commits | Impact | Additions | Deletions |
|
45
|
+
+---------+---------+--------+-----------+-----------+
|
46
|
+
| 2012-01 | 241 | 29581 | 15324 | 14257 |
|
47
|
+
| 2012-02 | 250 | 15518 | 7844 | 7674 |
|
48
|
+
| 2012-03 | 181 | 16647 | 12036 | 4611 |
|
49
|
+
| 2012-04 | 130 | 14755 | 12213 | 2542 |
|
50
|
+
| 2012-05 | 178 | 40102 | 22883 | 17219 |
|
51
|
+
| 2012-06 | 91 | 9870 | 7279 | 2591 |
|
52
|
+
| 2012-07 | 50 | 5017 | 4677 | 340 |
|
53
|
+
| 2012-08 | 110 | 10124 | 5214 | 4910 |
|
54
|
+
| 2012-09 | 49 | 3632 | 2535 | 1097 |
|
55
|
+
| 2012-10 | 153 | 54326 | 34419 | 19907 |
|
56
|
+
| 2012-11 | 183 | 27958 | 22602 | 5356 |
|
57
|
+
| 2012-12 | 123 | 21099 | 13897 | 7202 |
|
58
|
+
+---------+---------+--------+-----------+-----------+
|
59
|
+
|
60
|
+
#### Graph a piece of data
|
61
|
+
|
62
|
+
hubtime graph
|
63
|
+
hubtime graph impact
|
64
|
+
hubtime graph deletions
|
65
|
+
hubtime graph additions --user otherlogin
|
66
|
+
|
67
|
+
hubtime graph commits --months 3
|
68
|
+
|
69
|
+

|
70
|
+
|
71
|
+
#### All of those work with a stacked graph to see if broken up by repository
|
72
|
+
|
73
|
+
hubtime graph --stacked
|
74
|
+
|
75
|
+
hubtime graph impact --stacked
|
76
|
+
|
77
|
+

|
78
|
+
|
79
|
+
#### Impact Graph like on Github
|
80
|
+
|
81
|
+
hubtime impact
|
82
|
+
|
83
|
+
hubtime impact --months 12
|
84
|
+
|
85
|
+

|
86
|
+
|
87
|
+
#### Pie chart of repositories
|
88
|
+
|
89
|
+
hubtime pie
|
90
|
+
hubtime pie impact
|
91
|
+
|
92
|
+
hubtime pie --months 3
|
93
|
+
|
94
|
+

|
95
|
+
|
96
|
+
#### Sparklines in the console
|
97
|
+
|
98
|
+
hubtime spark
|
99
|
+
hubtime spark commits
|
100
|
+
|
101
|
+
hubtime spark impact
|
102
|
+
▄▂▂▂▅▁▁▁▇▇▄▃
|
103
|
+
|
104
|
+
#### Development
|
105
|
+
|
106
|
+
I use rvm and bundler. Check out this repo and `bundle install` to get started.
|
107
|
+
All of the above commands would need `bundle exec` prepended to work in development.
|
108
|
+
|
109
|
+
|
data/bin/hubtime
ADDED
@@ -0,0 +1,199 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'commander/import'
|
4
|
+
require 'hubtime'
|
5
|
+
|
6
|
+
program :name, 'hubtime'
|
7
|
+
program :version, Hubtime::VERSION
|
8
|
+
program :description, 'See activity on Github.'
|
9
|
+
|
10
|
+
command :impact do |c|
|
11
|
+
c.syntax = 'hubtime impact'
|
12
|
+
c.summary = ''
|
13
|
+
c.description = 'Graph your additions and deletions'
|
14
|
+
c.example 'description', 'command example'
|
15
|
+
c.option '--months INTEGER', 'How many months of history'
|
16
|
+
c.option '--user USERNAME', 'Which Github user'
|
17
|
+
c.action do |args, options|
|
18
|
+
options.default :months => 12
|
19
|
+
activity = Hubtime::Activity.new(self, options.user, options.months)
|
20
|
+
file = activity.impact
|
21
|
+
puts "saved: #{file}"
|
22
|
+
`open #{file}`
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
command :graph do |c|
|
27
|
+
c.syntax = 'hubtime graph [commits|impact|additions|deletions]'
|
28
|
+
c.summary = ''
|
29
|
+
c.description = 'Graph a single count'
|
30
|
+
c.example 'description', 'command example'
|
31
|
+
c.option '--months INTEGER', 'How many months of history'
|
32
|
+
c.option '--user USERNAME', 'Which Github user'
|
33
|
+
c.option '--stacked', 'To see data by repository'
|
34
|
+
c.action do |args, options|
|
35
|
+
options.default :months => 12
|
36
|
+
options.default :data => "count"
|
37
|
+
type = args.first
|
38
|
+
type ||= "commits"
|
39
|
+
type = "count" if type == "commits"
|
40
|
+
activity = Hubtime::Activity.new(self, options.user, options.months)
|
41
|
+
file = activity.graph(type, options.stacked.present?)
|
42
|
+
puts "saved: #{file}"
|
43
|
+
`open #{file}`
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
command :pie do |c|
|
48
|
+
c.syntax = 'hubtime pie [commits|impact|additions|deletions]'
|
49
|
+
c.summary = ''
|
50
|
+
c.description = 'Graph a pie chart by repository'
|
51
|
+
c.example 'description', 'command example'
|
52
|
+
c.option '--months INTEGER', 'How many months of history'
|
53
|
+
c.option '--user USERNAME', 'Which Github user'
|
54
|
+
c.action do |args, options|
|
55
|
+
options.default :months => 12
|
56
|
+
options.default :data => "count"
|
57
|
+
type = args.first
|
58
|
+
type ||= "commits"
|
59
|
+
type = "count" if type == "commits"
|
60
|
+
activity = Hubtime::Activity.new(self, options.user, options.months)
|
61
|
+
file = activity.pie(type)
|
62
|
+
puts "saved: #{file}"
|
63
|
+
`open #{file}`
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
command :table do |c|
|
68
|
+
c.syntax = 'hubtime table [options]'
|
69
|
+
c.summary = ''
|
70
|
+
c.description = 'Table your time'
|
71
|
+
c.example 'description', 'command example'
|
72
|
+
c.option '--months INTEGER', 'How many months of history'
|
73
|
+
c.option '--user USERNAME', 'How many months of history'
|
74
|
+
c.option '--unit (year|month|day)', 'Granularity of the results'
|
75
|
+
c.action do |args, options|
|
76
|
+
options.default :months => 12
|
77
|
+
options.default :unit => "month"
|
78
|
+
activity = Hubtime::Activity.new(self, options.user, options.months)
|
79
|
+
puts activity.table(options.unit)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
command :spark do |c|
|
84
|
+
c.syntax = 'hubtime spark [options]'
|
85
|
+
c.summary = ''
|
86
|
+
c.description = 'Graph your time'
|
87
|
+
c.example 'description', 'command example'
|
88
|
+
c.option '--months INTEGER', 'How many months of history'
|
89
|
+
c.option '--user USERNAME', 'How many months of history'
|
90
|
+
c.option '--unit (year|month|day)', 'Granularity of the results'
|
91
|
+
c.option '--data (count|impact|additions|deletions)', 'Type of results'
|
92
|
+
c.action do |args, options|
|
93
|
+
options.default :months => 12
|
94
|
+
options.default :unit => "month"
|
95
|
+
type = args.first
|
96
|
+
type ||= "commits"
|
97
|
+
type = "count" if type == "commits"
|
98
|
+
|
99
|
+
activity = Hubtime::Activity.new(self, options.user, options.months)
|
100
|
+
puts activity.spark(options.unit, type)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
command :config do |c|
|
105
|
+
c.syntax = 'hubtime config --user USERNAME --password PASSWORD'
|
106
|
+
c.summary = ''
|
107
|
+
c.description = 'Sets your details'
|
108
|
+
c.example 'description', 'command example'
|
109
|
+
c.option '--user USERNAME', 'Github user name'
|
110
|
+
c.option '--password PASSWORD', 'Github password'
|
111
|
+
c.action do |args, options|
|
112
|
+
if options.password || options.user
|
113
|
+
raise("Need password") unless options.password
|
114
|
+
raise("Need github user name") unless options.user
|
115
|
+
Hubtime::HubConfig.store(options.user, options.password)
|
116
|
+
puts "Set config..."
|
117
|
+
else
|
118
|
+
puts "Current config..."
|
119
|
+
end
|
120
|
+
|
121
|
+
puts " Username: #{Hubtime::HubConfig.user}"
|
122
|
+
puts " Password: #{Hubtime::HubConfig.display_password}"
|
123
|
+
|
124
|
+
unless options.password || options.user
|
125
|
+
puts "To set, use command: hubtime config --user USERNAME --password PASSWORD"
|
126
|
+
end
|
127
|
+
|
128
|
+
puts ""
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
command :auth do |c|
|
133
|
+
c.syntax = 'hubtime auth'
|
134
|
+
c.summary = ''
|
135
|
+
c.description = 'Saves credentials'
|
136
|
+
c.action do |args, options|
|
137
|
+
username = ask("Github Username: ")
|
138
|
+
password = ask("Github Password: ") { |q| q.echo = "*" }
|
139
|
+
|
140
|
+
raise "Need a username" if username.blank?
|
141
|
+
raise "Need a password" if password.blank?
|
142
|
+
|
143
|
+
Hubtime::HubConfig.auth(username, password)
|
144
|
+
|
145
|
+
puts "Current auth..."
|
146
|
+
|
147
|
+
puts " Username: #{Hubtime::HubConfig.user}"
|
148
|
+
puts " Password: #{Hubtime::HubConfig.display_password}"
|
149
|
+
|
150
|
+
unless options.password || options.user
|
151
|
+
puts "To set directly, use command: hubtime config --user USERNAME --password PASSWORD"
|
152
|
+
end
|
153
|
+
|
154
|
+
puts ""
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
command :ignore do |c|
|
159
|
+
c.syntax = 'hubtime ignore REPO_NAME'
|
160
|
+
c.summary = ''
|
161
|
+
c.description = 'Stop looking at this repo'
|
162
|
+
c.example 'description', 'hubtime ignore bleonard/rails'
|
163
|
+
c.action do |args, options|
|
164
|
+
if args.first
|
165
|
+
Hubtime::HubConfig.add_ignore(args.first)
|
166
|
+
Hubtime::Cacher.clear("activity") # different repos
|
167
|
+
Hubtime::Cacher.clear("charts")
|
168
|
+
end
|
169
|
+
|
170
|
+
puts "Current ignore list: #{Hubtime::HubConfig.ignore.join(", ")}"
|
171
|
+
puts "This list can be edited in the config.yml"
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
command :clear do |c|
|
176
|
+
c.syntax = 'hubtime clear'
|
177
|
+
c.summary = ''
|
178
|
+
c.description = 'Removes items from the cache'
|
179
|
+
c.example 'description', 'hubtime clear activity'
|
180
|
+
c.action do |args, options|
|
181
|
+
args << "activity" if args.size == 0
|
182
|
+
args.each do |item|
|
183
|
+
Hubtime::Cacher.clear(item)
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
command :repositories do |c|
|
189
|
+
c.syntax = 'hubtime repositories'
|
190
|
+
c.description = 'Lists known repositories'
|
191
|
+
c.option '--user USERNAME', 'Github user name'
|
192
|
+
c.action do |args, options|
|
193
|
+
user = options.user
|
194
|
+
user ||= Hubtime::HubConfig.user
|
195
|
+
Hubtime::GithubService.owner.repositories(user).each do |name|
|
196
|
+
puts name
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
data/hubtime.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "hubtime/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "hubtime"
|
7
|
+
s.version = Hubtime::VERSION
|
8
|
+
s.summary = "Visualization of your Github activity over the past year via Github API."
|
9
|
+
s.email = "contact@plataformatec.com.br"
|
10
|
+
s.homepage = "http://github.com/bleonard/hubtime"
|
11
|
+
s.description = "Visualization of your Github activity over the past year via Github API with visualizations like table, graph, stacked graph and pie chart."
|
12
|
+
s.authors = ['Brian Leonard']
|
13
|
+
|
14
|
+
s.rubyforge_project = "hubtime"
|
15
|
+
|
16
|
+
s.executables << "hubtime"
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
|
20
|
+
s.add_dependency("active_support", "~> 3.0")
|
21
|
+
s.add_dependency("commander", "~> 4.1")
|
22
|
+
s.add_dependency("i18n", "~> 0.6")
|
23
|
+
s.add_dependency("tzinfo", "~> 0.3")
|
24
|
+
s.add_dependency("octokit", "~> 1.20")
|
25
|
+
s.add_dependency("terminal-table", "~> 1.4")
|
26
|
+
s.add_dependency("erubis", "~> 2.7")
|
27
|
+
s.add_dependency("hashie", "~> 1.2")
|
28
|
+
end
|
data/lib/hubtime.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'active_support'
|
2
|
+
require 'active_support/all'
|
3
|
+
require 'terminal-table'
|
4
|
+
require 'fileutils'
|
5
|
+
require 'yaml'
|
6
|
+
require 'erubis'
|
7
|
+
require 'hashie'
|
8
|
+
require 'octokit'
|
9
|
+
|
10
|
+
require 'hubtime/version'
|
11
|
+
require 'hubtime/hub_config'
|
12
|
+
require 'hubtime/cacher'
|
13
|
+
require 'hubtime/commit'
|
14
|
+
require 'hubtime/github'
|
15
|
+
require 'hubtime/activity'
|
16
|
+
require 'hubtime/repo'
|