ghclient 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.
- checksums.yaml +7 -0
- data/bin/ghclient +9 -0
- data/lib/ghclient/api.rb +27 -0
- data/lib/ghclient/cli.rb +44 -0
- data/lib/ghclient/connection.rb +36 -0
- data/lib/ghclient/repository.rb +7 -0
- data/lib/ghclient/user.rb +11 -0
- data/lib/ghclient.rb +1 -0
- data/spec/fixtures/cli.yml +108 -0
- data/spec/fixtures/vcr_cassettes/synopsis.yml +4800 -0
- data/spec/helpers/fixtures_helper.rb +11 -0
- data/spec/spec_helper.rb +116 -0
- data/spec/unit/api_spec.rb +26 -0
- data/spec/unit/ghclient/cli_spec.rb +42 -0
- data/spec/unit/ghclient/connection_spec.rb +22 -0
- data/spec/unit/ghclient/repository_spec.rb +8 -0
- data/spec/unit/ghclient/user_spec.rb +8 -0
- data/spec/unit/user_spec.rb +5 -0
- metadata +114 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d1b76cf476655e6510246e964d3c10cec663bf57
|
4
|
+
data.tar.gz: 6bb7a129b9585ced997839594acdec00808a9eb3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1f173a938ed3b29f50c50b9a1d627ac36f0a361bbba7ba9991d5801997f9a94daec3fa1fa961909cc332d176585c927e33bc5f113ffc0d80dc368f452c8428d6
|
7
|
+
data.tar.gz: ab9fe54879f1806cb89c4d9ef8be011b4abe855083b832d0f15765976d6906e0368089643684b74c1e824ba58c905f8b7c8459aa168e252265fb63720ff75b2a
|
data/bin/ghclient
ADDED
data/lib/ghclient/api.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require_relative './connection'
|
2
|
+
require_relative './user'
|
3
|
+
require_relative './repository'
|
4
|
+
require_relative './cli'
|
5
|
+
|
6
|
+
module GHClient
|
7
|
+
class Api
|
8
|
+
|
9
|
+
attr_accessor :connection
|
10
|
+
|
11
|
+
def initialize connection = GHClient::Connection.new()
|
12
|
+
@connection = connection
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_user user_name
|
16
|
+
@connection.get GHClient::User.path(user_name)
|
17
|
+
end
|
18
|
+
|
19
|
+
def get_repositories user_name
|
20
|
+
@connection.get GHClient::User.repositories_path(user_name)
|
21
|
+
end
|
22
|
+
|
23
|
+
def get_languages_for_repository(repository)
|
24
|
+
@connection.get GHClient::Repository.languages_path(repository)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/ghclient/cli.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
module GHClient
|
2
|
+
class Cli
|
3
|
+
attr_accessor :device
|
4
|
+
|
5
|
+
def initialize api: GHClient::Api.new, device: STDOUT
|
6
|
+
@device = device
|
7
|
+
@api = api
|
8
|
+
end
|
9
|
+
|
10
|
+
def print_for_user user
|
11
|
+
acum = Hash.new { |h, k| h[k] = 0}
|
12
|
+
|
13
|
+
@api.get_repositories(user).each do |repo|
|
14
|
+
languages = @api.get_languages_for_repository(repo["full_name"])
|
15
|
+
languages.each{|l,c| acum[l] += c}
|
16
|
+
print_repo_info(repo, languages)
|
17
|
+
end
|
18
|
+
|
19
|
+
first_language = acum.to_a.sort{|x,y| y[1] <=> x[1]}[0]
|
20
|
+
puts "First language for #{user}: #{first_language[0]}"
|
21
|
+
end
|
22
|
+
|
23
|
+
def print_repo_info repo, languages
|
24
|
+
total = languages.inject(0){|acum, l| acum + l[1]}
|
25
|
+
puts "#{repo["full_name"]} - Total LOC: #{total}"
|
26
|
+
|
27
|
+
languages.each do |language, count|
|
28
|
+
print_progress(total, language, count)
|
29
|
+
end
|
30
|
+
puts ""
|
31
|
+
end
|
32
|
+
|
33
|
+
def print_progress total, text, size
|
34
|
+
proportion = (size.to_f / total.to_f).round(2)
|
35
|
+
characters = "="*(proportion * 20)
|
36
|
+
empty_characters = " "*(20 - (proportion * 20).floor)
|
37
|
+
puts "[" + characters + empty_characters + "] (#{(proportion * 100).round(2)}% / #{size} LOC) #{text}"
|
38
|
+
end
|
39
|
+
|
40
|
+
def puts message
|
41
|
+
@device.puts message
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
require 'net/https'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module GHClient
|
6
|
+
class NoAccessToken < StandardError; end
|
7
|
+
|
8
|
+
class Connection
|
9
|
+
|
10
|
+
BASE_URL = 'https://api.github.com'
|
11
|
+
ACCESS_TOKEN = '6afbf23e799a6d16d7a2cc69645307ea4a3a6c74'
|
12
|
+
|
13
|
+
attr_reader :last_response
|
14
|
+
|
15
|
+
def initialize options = {}
|
16
|
+
@options = options
|
17
|
+
options[:access_token] ||= ACCESS_TOKEN
|
18
|
+
check_options!(@options)
|
19
|
+
end
|
20
|
+
|
21
|
+
def check_options!(options)
|
22
|
+
options[:access_token] || (raise NoAccessToken)
|
23
|
+
end
|
24
|
+
|
25
|
+
def get path
|
26
|
+
uri = URI(BASE_URL + path + "?access_token=#{@options[:access_token]}")
|
27
|
+
response = Net::HTTP.get_response(uri)
|
28
|
+
check_and_parse_response!(response)
|
29
|
+
end
|
30
|
+
|
31
|
+
def check_and_parse_response!(response)
|
32
|
+
@last_response = response
|
33
|
+
JSON.parse(response.body)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/ghclient.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require './lib/ghclient/api'
|
@@ -0,0 +1,108 @@
|
|
1
|
+
repo_info: |+
|
2
|
+
my_user/my_repo - Total LOC: 698
|
3
|
+
[== ] (14.0% / 100 LOC) Java
|
4
|
+
[================= ] (86.0% / 598 LOC) Ruby
|
5
|
+
|
6
|
+
print_progress: |+
|
7
|
+
[=========== ] (55.0% / 311 LOC) Prolog
|
8
|
+
print_for_user: |+
|
9
|
+
hermesdt/AFA2 - Total LOC: 247699
|
10
|
+
[====================] (100.0% / 247699 LOC) Java
|
11
|
+
|
12
|
+
hermesdt/afa_web - Total LOC: 126728
|
13
|
+
[============= ] (68.0% / 85656 LOC) Ruby
|
14
|
+
[====== ] (32.0% / 41072 LOC) JavaScript
|
15
|
+
|
16
|
+
hermesdt/Android-DirectoryChooser - Total LOC: 41563
|
17
|
+
[=============== ] (79.0% / 32979 LOC) Java
|
18
|
+
[== ] (12.0% / 5080 LOC) Shell
|
19
|
+
[= ] (8.0% / 3504 LOC) Groovy
|
20
|
+
|
21
|
+
hermesdt/best-boxing-timer - Total LOC: 193955
|
22
|
+
[=================== ] (96.0% / 185579 LOC) Java
|
23
|
+
[ ] (4.0% / 7484 LOC) Shell
|
24
|
+
[ ] (0.0% / 892 LOC) Groovy
|
25
|
+
|
26
|
+
hermesdt/blogjs - Total LOC: 25311
|
27
|
+
[====================] (100.0% / 25201 LOC) JavaScript
|
28
|
+
[ ] (0.0% / 110 LOC) CSS
|
29
|
+
|
30
|
+
hermesdt/devise - Total LOC: 0
|
31
|
+
|
32
|
+
hermesdt/documentary - Total LOC: 7130
|
33
|
+
[====================] (100.0% / 7130 LOC) JavaScript
|
34
|
+
|
35
|
+
hermesdt/ghclient - Total LOC: 9003
|
36
|
+
[====================] (100.0% / 9003 LOC) Ruby
|
37
|
+
|
38
|
+
hermesdt/google_code_jam - Total LOC: 6222
|
39
|
+
[====================] (100.0% / 6222 LOC) Ruby
|
40
|
+
|
41
|
+
hermesdt/hangout-test - Total LOC: 0
|
42
|
+
|
43
|
+
hermesdt/hermesdt.github.io - Total LOC: 627157
|
44
|
+
[============ ] (63.0% / 397658 LOC) CSS
|
45
|
+
[======= ] (36.0% / 226757 LOC) HTML
|
46
|
+
[ ] (0.0% / 1920 LOC) Ruby
|
47
|
+
[ ] (0.0% / 822 LOC) JavaScript
|
48
|
+
|
49
|
+
hermesdt/ivoox-fetcher - Total LOC: 1897
|
50
|
+
[====================] (100.0% / 1897 LOC) Ruby
|
51
|
+
|
52
|
+
hermesdt/madridtransport - Total LOC: 6231
|
53
|
+
[============ ] (62.0% / 3849 LOC) JavaScript
|
54
|
+
[====== ] (32.0% / 1979 LOC) Ruby
|
55
|
+
[= ] (5.0% / 293 LOC) HTML
|
56
|
+
[ ] (2.0% / 110 LOC) CSS
|
57
|
+
|
58
|
+
hermesdt/omniauth-wsfed - Total LOC: 32857
|
59
|
+
[====================] (100.0% / 32857 LOC) Ruby
|
60
|
+
|
61
|
+
hermesdt/participacion - Total LOC: 578990
|
62
|
+
[=========== ] (56.0% / 321688 LOC) Ruby
|
63
|
+
[===== ] (25.0% / 145594 LOC) HTML
|
64
|
+
[=== ] (17.0% / 100382 LOC) CSS
|
65
|
+
[ ] (1.0% / 6367 LOC) JavaScript
|
66
|
+
[ ] (1.0% / 3074 LOC) CoffeeScript
|
67
|
+
[ ] (0.0% / 1885 LOC) Shell
|
68
|
+
|
69
|
+
hermesdt/pyjoke - Total LOC: 1032
|
70
|
+
[====================] (100.0% / 1032 LOC) Python
|
71
|
+
|
72
|
+
hermesdt/remotipart - Total LOC: 9848
|
73
|
+
[====================] (100.0% / 9848 LOC) Ruby
|
74
|
+
|
75
|
+
hermesdt/Ruby-Tuenti-Album-Downloader - Total LOC: 0
|
76
|
+
|
77
|
+
hermesdt/RubyFilmFinder - Total LOC: 108334
|
78
|
+
[================== ] (94.0% / 101715 LOC) JavaScript
|
79
|
+
[= ] (6.0% / 6619 LOC) Ruby
|
80
|
+
|
81
|
+
hermesdt/SafeBlock - Total LOC: 4048
|
82
|
+
[====================] (100.0% / 4048 LOC) Ruby
|
83
|
+
|
84
|
+
hermesdt/tictactoe - Total LOC: 0
|
85
|
+
|
86
|
+
hermesdt/tolk - Total LOC: 49422
|
87
|
+
[====================] (100.0% / 49190 LOC) Ruby
|
88
|
+
[ ] (0.0% / 232 LOC) JavaScript
|
89
|
+
|
90
|
+
hermesdt/TomatoEvans.github.io - Total LOC: 2381
|
91
|
+
[=========== ] (57.0% / 1357 LOC) CSS
|
92
|
+
[======== ] (43.0% / 1024 LOC) HTML
|
93
|
+
|
94
|
+
hermesdt/tresxtresIA - Total LOC: 7820
|
95
|
+
[====================] (100.0% / 7820 LOC) Ruby
|
96
|
+
|
97
|
+
hermesdt/vim_config - Total LOC: 556575
|
98
|
+
[================= ] (85.0% / 473982 LOC) VimL
|
99
|
+
[== ] (10.0% / 53218 LOC) Ruby
|
100
|
+
[ ] (4.0% / 23888 LOC) C
|
101
|
+
[ ] (1.0% / 5487 LOC) Makefile
|
102
|
+
|
103
|
+
hermesdt/webyaml - Total LOC: 20380
|
104
|
+
[=================== ] (95.0% / 19459 LOC) Ruby
|
105
|
+
[ ] (2.0% / 463 LOC) JavaScript
|
106
|
+
[ ] (2.0% / 458 LOC) CoffeeScript
|
107
|
+
|
108
|
+
First language for hermesdt: Ruby
|