gitget 0.1.1 → 0.2
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 +4 -4
- data/.gitignore +1 -0
- data/Rakefile +5 -5
- data/bin/gitget +2 -2
- data/lib/gitget/github_api.rb +5 -0
- data/lib/gitget/github_developer.rb +20 -11
- data/lib/gitget/github_repository.rb +7 -0
- data/lib/gitget/version.rb +1 -1
- data/spec/{github_spec.rb → developer_spec.rb} +2 -8
- data/spec/repository_spec.rb +32 -0
- data/spec/spec_helper.rb +15 -1
- metadata +7 -6
- data/Gemfile.lock +0 -89
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b1d41249e213ab65365f67b9a7f6764873119e3
|
4
|
+
data.tar.gz: 67a5033f962e6e3f62f063d81356318c0165ab0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2bedfa2d9cd29a6f764aab5bb9da2d7dc98aba5a9f1ddcdae786759a9c2f2032ebae1529c6d793137d59110568ba8ec1bcc87d003accddb169547da2e7ca69f
|
7
|
+
data.tar.gz: 7f5e92affa05444f7eb55ef3c4062d22c5f1de60157d21fc4eab279c6ac8d469911b7a47fdc154a759d6d44a708f29565048703082f2fc56bb642f946dba2258
|
data/.gitignore
CHANGED
data/Rakefile
CHANGED
@@ -3,6 +3,11 @@ require 'rake/testtask'
|
|
3
3
|
|
4
4
|
task default: :spec
|
5
5
|
|
6
|
+
Rake::TestTask.new(:spec) do |t|
|
7
|
+
t.pattern = 'spec/*_spec.rb'
|
8
|
+
t.warning = false
|
9
|
+
end
|
10
|
+
|
6
11
|
namespace :credentials do
|
7
12
|
require 'yaml'
|
8
13
|
|
@@ -15,11 +20,6 @@ namespace :credentials do
|
|
15
20
|
end
|
16
21
|
end
|
17
22
|
|
18
|
-
desc 'run tests'
|
19
|
-
task :spec do
|
20
|
-
sh 'ruby spec/github_spec.rb'
|
21
|
-
end
|
22
|
-
|
23
23
|
desc 'delete cassette fixtures'
|
24
24
|
task :wipe do
|
25
25
|
sh 'rm spec/fixtures/cassettes/*.yml' do |ok, _|
|
data/bin/gitget
CHANGED
@@ -12,10 +12,10 @@ end
|
|
12
12
|
|
13
13
|
developer = Github::Developer.find(username: developer_name)
|
14
14
|
|
15
|
-
puts developer.
|
15
|
+
puts developer.username
|
16
16
|
developer.repos.first(3).each.with_index do |repo, index|
|
17
17
|
print "#{index + 1}: "
|
18
|
-
puts 'Repo name: ' + repo.
|
18
|
+
puts 'Repo name: ' + repo.full.to_s
|
19
19
|
puts 'Repo ID: ' + repo.id.to_s
|
20
20
|
puts 'Number of watchers: ' + repo.watchers_count.to_s
|
21
21
|
puts 'Number of Issues: ' + repo.open_issues_count.to_s
|
data/lib/gitget/github_api.rb
CHANGED
@@ -25,6 +25,11 @@ module Github
|
|
25
25
|
github_api_get(route)
|
26
26
|
end
|
27
27
|
|
28
|
+
def self.repo_info(owner, repo)
|
29
|
+
route = '/repos/' + owner + '/' + repo
|
30
|
+
github_api_get(route)
|
31
|
+
end
|
32
|
+
|
28
33
|
def self.user_followers(username)
|
29
34
|
route = '/users/' + username + '/followers'
|
30
35
|
github_api_get(route)
|
@@ -3,18 +3,17 @@
|
|
3
3
|
module Github
|
4
4
|
# Main class to set up a Github User
|
5
5
|
class Developer
|
6
|
-
attr_reader :
|
6
|
+
attr_reader :username, :id, :public_repos, :avatar_url, :name, :company,
|
7
|
+
:blog, :location, :email, :bio, :followers, :following
|
7
8
|
|
8
|
-
def initialize(data:)
|
9
|
-
|
10
|
-
@id = data['id']
|
11
|
-
@public_repos = data['public_repos']
|
9
|
+
def initialize(data: nil)
|
10
|
+
load_data(data)
|
12
11
|
end
|
13
12
|
|
14
13
|
def repos
|
15
14
|
return @repos if @repos
|
16
15
|
|
17
|
-
@repos = Github::API.user_repos(@
|
16
|
+
@repos = Github::API.user_repos(@username).map do |repo_data|
|
18
17
|
Github::Repository.new(data: repo_data)
|
19
18
|
end
|
20
19
|
end
|
@@ -31,13 +30,23 @@ module Github
|
|
31
30
|
@following = Github::API.user_following @name
|
32
31
|
end
|
33
32
|
|
33
|
+
def load_data(repo_data)
|
34
|
+
@username = repo_data['login']
|
35
|
+
@id = repo_data['id']
|
36
|
+
@public_repos = repo_data['public_repos']
|
37
|
+
@avatar_url = repo_data['avatar_url']
|
38
|
+
@name = repo_data['name']
|
39
|
+
@company = repo_data['company']
|
40
|
+
@blog = repo_data['blog']
|
41
|
+
@location = repo_data['location']
|
42
|
+
@email = repo_data['email']
|
43
|
+
@bio = repo_data['bio']
|
44
|
+
end
|
45
|
+
|
34
46
|
def self.find(username:)
|
35
47
|
user_data = Github::API.user_info(username)
|
36
|
-
if user_data[
|
37
|
-
|
38
|
-
else
|
39
|
-
new(data: user_data)
|
40
|
-
end
|
48
|
+
return nil if user_data['message'] == 'Not Found'
|
49
|
+
new(data: user_data)
|
41
50
|
end
|
42
51
|
end
|
43
52
|
end
|
@@ -24,6 +24,7 @@ module Github
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def load_data(repo_data)
|
27
|
+
@id = repo_data['id']
|
27
28
|
@full_name = repo_data['full_name']
|
28
29
|
@is_private = repo_data['is_private']
|
29
30
|
@is_fork = repo_data['is_fork']
|
@@ -35,5 +36,11 @@ module Github
|
|
35
36
|
@forks_count = repo_data['forks_count']
|
36
37
|
@open_issues_count = repo_data['open_issues_count']
|
37
38
|
end
|
39
|
+
|
40
|
+
def self.find(owner:, repo:)
|
41
|
+
repo_data = Github::API.repo_info(owner, repo)
|
42
|
+
return nil if repo_data['message'] == 'Not Found'
|
43
|
+
new(data: repo_data)\
|
44
|
+
end
|
38
45
|
end
|
39
46
|
end
|
data/lib/gitget/version.rb
CHANGED
@@ -3,15 +3,9 @@
|
|
3
3
|
require_relative 'spec_helper'
|
4
4
|
|
5
5
|
describe 'Github specifications' do
|
6
|
-
VCR.configure do |c|
|
7
|
-
c.cassette_library_dir = CASSETTES_FOLDER
|
8
|
-
c.hook_into :webmock
|
9
|
-
|
10
|
-
c.filter_sensitive_data('<AUTH>') { ENV['GH_AUTH'] }
|
11
|
-
end
|
12
6
|
|
13
7
|
before do
|
14
|
-
VCR.insert_cassette
|
8
|
+
VCR.insert_cassette DEVELOPER, record: :new_episodes
|
15
9
|
@developer = Github::Developer.find(username: USERNAME)
|
16
10
|
@sad_developer = Github::Developer.find(username: SAD_USERNAME)
|
17
11
|
end
|
@@ -25,7 +19,7 @@ describe 'Github specifications' do
|
|
25
19
|
end
|
26
20
|
|
27
21
|
it 'should be able to open a new Github Developer' do
|
28
|
-
@developer.
|
22
|
+
@developer.username.length.must_be :>, 0
|
29
23
|
end
|
30
24
|
|
31
25
|
it 'should get the user id' do
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'spec_helper'
|
4
|
+
|
5
|
+
describe 'Github specifications' do
|
6
|
+
|
7
|
+
before do
|
8
|
+
VCR.insert_cassette REPOSITORY, record: :new_episodes
|
9
|
+
@repository = Github::Repository.find(owner: HAPPY_OWNER, repo: HAPPY_REPO)
|
10
|
+
@sad_repository = Github::Repository.find(owner: SAD_USERNAME, repo: SAD_REPO)
|
11
|
+
end
|
12
|
+
|
13
|
+
after do
|
14
|
+
VCR.eject_cassette
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should return nil for no repository found' do
|
18
|
+
@sad_repository.must_be_nil
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should be able to open a new Github Repository' do
|
22
|
+
@repository.full_name.must_be_instance_of String
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should get the repository id' do
|
26
|
+
@repository.id.must_be :>, 0
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should get the repo should have stats' do
|
30
|
+
@repository.stats.wont_be_nil
|
31
|
+
end
|
32
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -13,14 +13,28 @@ require_relative '../lib/gitget'
|
|
13
13
|
|
14
14
|
FIXTURES_FOLDER = 'spec/fixtures'
|
15
15
|
CASSETTES_FOLDER = "#{FIXTURES_FOLDER}/cassettes"
|
16
|
-
|
16
|
+
DEVELOPER = 'developer'
|
17
|
+
REPOSITORY = 'repository'
|
17
18
|
|
18
19
|
USERNAME = 'rjollet'
|
19
20
|
SAD_USERNAME = '12547'
|
20
21
|
|
22
|
+
HAPPY_OWNER = 'rjollet'
|
23
|
+
HAPPY_REPO = 'DeepViz'
|
24
|
+
|
25
|
+
SAD_OWNER = '12547'
|
26
|
+
SAD_REPO = '12547'
|
27
|
+
|
21
28
|
if File.file?('config/github_credential.yml')
|
22
29
|
credentials = YAML.load(File.read('config/github_credential.yml'))
|
23
30
|
ENV['GH_USERNAME'] = credentials[:username]
|
24
31
|
ENV['GH_TOKEN'] = credentials[:token]
|
25
32
|
ENV['GH_AUTH'] = credentials[:auth]
|
26
33
|
end
|
34
|
+
|
35
|
+
VCR.configure do |c|
|
36
|
+
c.cassette_library_dir = CASSETTES_FOLDER
|
37
|
+
c.hook_into :webmock
|
38
|
+
|
39
|
+
c.filter_sensitive_data('<AUTH>') { ENV['GH_AUTH'] }
|
40
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitget
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Renaud Jollet
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-11-
|
13
|
+
date: 2016-11-21 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: http
|
@@ -166,7 +166,6 @@ files:
|
|
166
166
|
- ".rubocop.yml"
|
167
167
|
- ".travis.yml"
|
168
168
|
- Gemfile
|
169
|
-
- Gemfile.lock
|
170
169
|
- LICENSE
|
171
170
|
- README.md
|
172
171
|
- Rakefile
|
@@ -178,8 +177,9 @@ files:
|
|
178
177
|
- lib/gitget/github_developer.rb
|
179
178
|
- lib/gitget/github_repository.rb
|
180
179
|
- lib/gitget/version.rb
|
180
|
+
- spec/developer_spec.rb
|
181
181
|
- spec/fixtures/README.md
|
182
|
-
- spec/
|
182
|
+
- spec/repository_spec.rb
|
183
183
|
- spec/spec_helper.rb
|
184
184
|
homepage: https://github.com/Rubeasts/gitget
|
185
185
|
licenses:
|
@@ -201,11 +201,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
201
201
|
version: '0'
|
202
202
|
requirements: []
|
203
203
|
rubyforge_project:
|
204
|
-
rubygems_version: 2.
|
204
|
+
rubygems_version: 2.5.1
|
205
205
|
signing_key:
|
206
206
|
specification_version: 4
|
207
207
|
summary: Gets public information about Github developers
|
208
208
|
test_files:
|
209
|
+
- spec/developer_spec.rb
|
209
210
|
- spec/fixtures/README.md
|
210
|
-
- spec/
|
211
|
+
- spec/repository_spec.rb
|
211
212
|
- spec/spec_helper.rb
|
data/Gemfile.lock
DELETED
@@ -1,89 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
gitget (0.1.0)
|
5
|
-
http (~> 2.0)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
addressable (2.4.0)
|
11
|
-
ast (2.3.0)
|
12
|
-
crack (0.4.3)
|
13
|
-
safe_yaml (~> 1.0.0)
|
14
|
-
docile (1.1.5)
|
15
|
-
domain_name (0.5.20161021)
|
16
|
-
unf (>= 0.0.5, < 1.0.0)
|
17
|
-
erubis (2.7.0)
|
18
|
-
flay (2.8.1)
|
19
|
-
erubis (~> 2.7.0)
|
20
|
-
path_expander (~> 1.0)
|
21
|
-
ruby_parser (~> 3.0)
|
22
|
-
sexp_processor (~> 4.0)
|
23
|
-
flog (4.4.0)
|
24
|
-
path_expander (~> 1.0)
|
25
|
-
ruby_parser (~> 3.1, > 3.1.0)
|
26
|
-
sexp_processor (~> 4.4)
|
27
|
-
hashdiff (0.3.0)
|
28
|
-
http (2.0.3)
|
29
|
-
addressable (~> 2.3)
|
30
|
-
http-cookie (~> 1.0)
|
31
|
-
http-form_data (~> 1.0.1)
|
32
|
-
http_parser.rb (~> 0.6.0)
|
33
|
-
http-cookie (1.0.3)
|
34
|
-
domain_name (~> 0.5)
|
35
|
-
http-form_data (1.0.1)
|
36
|
-
http_parser.rb (0.6.0)
|
37
|
-
json (2.0.2)
|
38
|
-
minitest (5.9.1)
|
39
|
-
minitest-rg (5.2.0)
|
40
|
-
minitest (~> 5.0)
|
41
|
-
parser (2.3.1.4)
|
42
|
-
ast (~> 2.2)
|
43
|
-
path_expander (1.0.0)
|
44
|
-
powerpack (0.1.1)
|
45
|
-
rainbow (2.1.0)
|
46
|
-
rake (11.3.0)
|
47
|
-
rubocop (0.43.0)
|
48
|
-
parser (>= 2.3.1.1, < 3.0)
|
49
|
-
powerpack (~> 0.1)
|
50
|
-
rainbow (>= 1.99.1, < 3.0)
|
51
|
-
ruby-progressbar (~> 1.7)
|
52
|
-
unicode-display_width (~> 1.0, >= 1.0.1)
|
53
|
-
ruby-progressbar (1.8.1)
|
54
|
-
ruby_parser (3.8.3)
|
55
|
-
sexp_processor (~> 4.1)
|
56
|
-
safe_yaml (1.0.4)
|
57
|
-
sexp_processor (4.7.0)
|
58
|
-
simplecov (0.12.0)
|
59
|
-
docile (~> 1.1.0)
|
60
|
-
json (>= 1.8, < 3)
|
61
|
-
simplecov-html (~> 0.10.0)
|
62
|
-
simplecov-html (0.10.0)
|
63
|
-
unf (0.1.4)
|
64
|
-
unf_ext
|
65
|
-
unf_ext (0.0.7.2)
|
66
|
-
unicode-display_width (1.1.1)
|
67
|
-
vcr (3.0.3)
|
68
|
-
webmock (2.1.0)
|
69
|
-
addressable (>= 2.3.6)
|
70
|
-
crack (>= 0.3.2)
|
71
|
-
hashdiff
|
72
|
-
|
73
|
-
PLATFORMS
|
74
|
-
ruby
|
75
|
-
|
76
|
-
DEPENDENCIES
|
77
|
-
flay (~> 2.8)
|
78
|
-
flog (~> 4.4)
|
79
|
-
gitget!
|
80
|
-
minitest (~> 5.9)
|
81
|
-
minitest-rg (~> 5.2)
|
82
|
-
rake (~> 11.3)
|
83
|
-
rubocop (~> 0.42)
|
84
|
-
simplecov (~> 0.12)
|
85
|
-
vcr (~> 3.0)
|
86
|
-
webmock (~> 2.1)
|
87
|
-
|
88
|
-
BUNDLED WITH
|
89
|
-
1.13.1
|