github_sloc 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/exe/github_sloc +70 -0
- data/lib/github_sloc/query.json +12 -0
- metadata +89 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9d34e9fe62ee1a28a7de6e0d43a108f5422c65e2
|
4
|
+
data.tar.gz: 231cc9eb0b73cba931bb51baf4fd7fa36004f440
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d5494d71c68b0ffd42df021b3f30ff668ff9183fa6f0a629b212d0ffcea1d1099753ccf64cd23b2d9c26be3f03cd429c453cbabd60c58c45b284544cc65ec091
|
7
|
+
data.tar.gz: 56c3b9e7e7e1ad4374d1c3caa19428b510799a7564a9cefd8d9b525d5eb1e97c56c35c029a4b77427d5d0f7bf5798de17a1ba31f929d064da649d3e88e46fb8a
|
data/exe/github_sloc
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "octokit"
|
4
|
+
require "net/http"
|
5
|
+
require "uri"
|
6
|
+
|
7
|
+
totala = 0
|
8
|
+
totald = 0
|
9
|
+
totalc = 0
|
10
|
+
|
11
|
+
print "Username: "
|
12
|
+
uname = gets.chomp
|
13
|
+
print "Password: "
|
14
|
+
pword = gets.chomp
|
15
|
+
|
16
|
+
octoclient = Octokit::Client.new(:login => uname, :password => pword)
|
17
|
+
|
18
|
+
auth = octoclient.create_authorization(:scopes => ["repo"], :note => "SLOC Script")
|
19
|
+
authid = auth.attrs[:id]
|
20
|
+
token = auth.attrs[:token]
|
21
|
+
|
22
|
+
query = Hash.new
|
23
|
+
path = File.expand_path('../lib/github_sloc/query.json', File.dirname(__FILE__))
|
24
|
+
puts path
|
25
|
+
query['query'] = IO.read(path)
|
26
|
+
query['variables'] = Hash.new
|
27
|
+
query['variables']['user'] = uname
|
28
|
+
query = query.to_json
|
29
|
+
|
30
|
+
uri = URI.parse("https://api.github.com/graphql")
|
31
|
+
|
32
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
33
|
+
http.use_ssl = true
|
34
|
+
|
35
|
+
request = Net::HTTP::Post.new(uri)
|
36
|
+
request['Authorization'] = "bearer #{token}"
|
37
|
+
request['Content-type'] = "application/json"
|
38
|
+
request.body = query
|
39
|
+
|
40
|
+
data = JSON.parse(http.request(request).body)
|
41
|
+
|
42
|
+
printf "----------\n%-40s %-10s %-10s %-10s\n----------\n", "Repository", "Adds", "Dels", "Commits"
|
43
|
+
|
44
|
+
data['data']['user']['contributedRepositories']['edges'].each do |edge|
|
45
|
+
repo = edge['node']['nameWithOwner']
|
46
|
+
stats = octoclient.contributors_stats(repo)
|
47
|
+
a = 0
|
48
|
+
d = 0
|
49
|
+
c = 0
|
50
|
+
if stats == nil
|
51
|
+
next
|
52
|
+
end
|
53
|
+
stats.each do |stat|
|
54
|
+
if stat[:author][:login] == uname
|
55
|
+
stat[:weeks].each do |week|
|
56
|
+
a = a + week[:a]
|
57
|
+
d = d + week[:d]
|
58
|
+
c = c + week[:c]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
printf "%-40s %-10s %-10s %-10s\n", repo, "(+#{a})", "(-#{d})", "(:#{c})"
|
63
|
+
totala = totala + a
|
64
|
+
totald = totald + d
|
65
|
+
totalc = totalc + c
|
66
|
+
end
|
67
|
+
|
68
|
+
printf "----------\n%-40s %-10s %-10s %-10s\n", "Total", "(+#{totala})", "(-#{totald})", "(:#{totalc})"
|
69
|
+
|
70
|
+
octoclient.delete_authorization(authid)
|
metadata
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: github_sloc
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Caleb Smith
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-08-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: octokit
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.7'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.15'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.15'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description: Find How Many SLOC You've Commited to Github
|
56
|
+
email:
|
57
|
+
- karagenit@outlook.com
|
58
|
+
executables:
|
59
|
+
- github_sloc
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- exe/github_sloc
|
64
|
+
- lib/github_sloc/query.json
|
65
|
+
homepage: https://github.com/karagenit/sloc
|
66
|
+
licenses:
|
67
|
+
- MIT
|
68
|
+
metadata: {}
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options: []
|
71
|
+
require_paths:
|
72
|
+
- lib
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
requirements: []
|
84
|
+
rubyforge_project:
|
85
|
+
rubygems_version: 2.4.8
|
86
|
+
signing_key:
|
87
|
+
specification_version: 4
|
88
|
+
summary: Github SLOC
|
89
|
+
test_files: []
|