gitout 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 55d53c152b410ec5f478771b1348e0d011134c24
4
+ data.tar.gz: b28fb5b0c75ca20a354496ed78cb810e94cc26b7
5
+ SHA512:
6
+ metadata.gz: 8ead119b8fc9b7fd6851d1484e6e4d5296ba51248e6670d5577695c0db6549a5e5e3fbe44c376728b9159ed3a4ea823820e2823317169a23f93ad326a31aa815
7
+ data.tar.gz: 64be11eebc59facd358ec67195b1d3db925772344b4614ab0195d1c8593174873174584b45fa894f97d4b00219141cc27a9f021fa8cdfa610df6b4ad9e97c854
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Jonathan Torres
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,2 @@
1
+ # Gitout
2
+ Measure github productivity by day. Check how much code you push to GitHub on a single day (Work in progress)
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'octokit'
4
+ require 'gitout'
5
+ require 'gitout/github'
6
+ require 'gitout/credentials'
7
+
8
+ username = ARGV[0]
9
+
10
+ if username.nil?
11
+ puts "Username is required!"
12
+ abort
13
+ end
14
+
15
+ puts "Fetching data for #{username}..."
16
+
17
+ client = Octokit::Client.new({
18
+ client_id: Credentials::CLIENT_ID,
19
+ client_secret: Credentials::CLIENT_SECRET
20
+ })
21
+
22
+ github = GitHub.new(client)
23
+ gitout = Gitout.new(github, username)
24
+ data = gitout.github
25
+
26
+ puts "GitHub data for '#{ARGV[0]}'"
27
+ puts "Commits: #{data[:commits]}"
28
+ puts "Lines of code added: #{data[:additions]}"
29
+ puts "Lines of code deleted: #{data[:deletions]}"
@@ -0,0 +1,20 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
4
+ require 'gitout/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'gitout'
8
+ spec.version = Gitout::VERSION
9
+ spec.summary = 'Find out much code you pushed to GitHub on a single day.'
10
+ spec.description = 'Check how much code you pushed to GitHub on a single day.'
11
+ spec.authors = ['Jonathan Torres']
12
+ spec.email = 'jonathantorres41@gmail.com'
13
+ spec.files = %w(LICENSE.md README.md gitout.gemspec)
14
+ spec.files += Dir['lib/**/*.rb'] + Dir['bin/*']
15
+ spec.executables << 'gitout'
16
+ spec.homepage = 'https://github.com/jonathantorres/gitout'
17
+ spec.license = 'MIT'
18
+ spec.required_ruby_version = '>= 1.9.2'
19
+ spec.required_rubygems_version = '>= 1.3.5'
20
+ end
@@ -0,0 +1,40 @@
1
+ require 'gitout/github'
2
+
3
+ class Gitout
4
+
5
+ def initialize(github, username)
6
+ @github = github
7
+ @username = username
8
+ @repositories = []
9
+ @total_commits = 0
10
+ @total_additions = 0
11
+ @total_deletions = 0
12
+ end
13
+
14
+ def github()
15
+ fetch_commits
16
+
17
+ data = {
18
+ commits: @total_commits,
19
+ additions: @total_additions,
20
+ deletions: @total_deletions,
21
+ }
22
+
23
+ data
24
+ end
25
+
26
+ private
27
+ def fetch_commits
28
+ @repositories = @github.repositories(@username)
29
+ @repositories.each do |repository|
30
+ puts "Reading commits on #{repository.name}..."
31
+ commits = @github.commits(@username, repository.name, Time.now.strftime("%Y-%m-%d"))
32
+ commits.each do |commit|
33
+ @total_commits += 1
34
+ commit_data = @github.commit(@username, repository.name, commit.sha)
35
+ @total_additions += commit_data.stats[:additions]
36
+ @total_deletions += commit_data.stats[:deletions]
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,4 @@
1
+ module Credentials
2
+ CLIENT_ID = '5bcb888ab4553ea8856e'
3
+ CLIENT_SECRET = '5aac4f5cd50059a878d27e796282d80b4f7edced'
4
+ end
@@ -0,0 +1,25 @@
1
+ require 'octokit'
2
+ require 'gitout/credentials'
3
+
4
+ class GitHub
5
+
6
+ def initialize(client)
7
+ @client = client
8
+ end
9
+
10
+ # get user repositories
11
+ def repositories(user)
12
+ @client.repositories(user)
13
+ end
14
+
15
+ # Get user commits on a repository on a specific date
16
+ # date format: 'Y-M-D'
17
+ def commits(user, repository, date)
18
+ @client.commits_on("#{user}/#{repository}", date, 'master')
19
+ end
20
+
21
+ # Get single commit data
22
+ def commit(user, repository, sha)
23
+ @client.commit("#{user}/#{repository}", sha)
24
+ end
25
+ end
@@ -0,0 +1,3 @@
1
+ module Gitout
2
+ VERSION = '1.0.0'
3
+ end
metadata ADDED
@@ -0,0 +1,52 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gitout
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Jonathan Torres
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-06-25 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Check how much code you pushed to GitHub on a single day.
14
+ email: jonathantorres41@gmail.com
15
+ executables:
16
+ - gitout
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - LICENSE.md
21
+ - README.md
22
+ - bin/gitout
23
+ - gitout.gemspec
24
+ - lib/gitout.rb
25
+ - lib/gitout/credentials.rb
26
+ - lib/gitout/github.rb
27
+ - lib/gitout/version.rb
28
+ homepage: https://github.com/jonathantorres/gitout
29
+ licenses:
30
+ - MIT
31
+ metadata: {}
32
+ post_install_message:
33
+ rdoc_options: []
34
+ require_paths:
35
+ - lib
36
+ required_ruby_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 1.9.2
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: 1.3.5
46
+ requirements: []
47
+ rubyforge_project:
48
+ rubygems_version: 2.4.6
49
+ signing_key:
50
+ specification_version: 4
51
+ summary: Find out much code you pushed to GitHub on a single day.
52
+ test_files: []