gigest 2.0.2 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gigest/github/github_connection.rb +9 -1
- data/lib/gigest/version.rb +1 -1
- data/spec/fixtures/account.json +7 -0
- data/spec/fixtures/vcr_cassettes/Gigest_GithubConnection/_details_for/returns_account_details.json +1 -0
- data/spec/gigest/analytics_spec.rb +3 -5
- data/spec/gigest/github/github_connection_spec.rb +16 -8
- metadata +5 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e00cf1001d5b9af1e2fe56e39d261bcc1b7117a9
|
4
|
+
data.tar.gz: 7d67bd6e64cad21c32e6214e6353123d998d6b43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64b8ef5cd243265cef0b4c00812cc3750f6e75290c52eb70f04b18e9e9e6e22f8862db396173bf4fa99c78eb8b8bdb85e5a71f47098eebf129f4e866602bf760
|
7
|
+
data.tar.gz: 690b0aa4aa6de2b6896e9615eb1f868f8d2dfa279cc33d92b316ae28051c1cd6698e3acbd7f3f9d454ec75b7b4be39f015db2482ce5697150faa4a4efee0d563
|
@@ -5,7 +5,15 @@ module Gigest
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def details_for(account=nil, type=:user)
|
8
|
-
@connection.send(account_method(type), account)
|
8
|
+
details = @connection.send(account_method(type), account)
|
9
|
+
|
10
|
+
{
|
11
|
+
name: details[:name],
|
12
|
+
avatar_url: details._rels[:avatar].href,
|
13
|
+
company: details[:company],
|
14
|
+
location: details[:location],
|
15
|
+
html_url: details._rels[:html].href
|
16
|
+
}
|
9
17
|
end
|
10
18
|
|
11
19
|
def repositories_for(account=nil, type=:user)
|
data/lib/gigest/version.rb
CHANGED
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"name": "Winston",
|
3
|
+
"avatar_url": "https://2.gravatar.com/avatar/15ad10eecd3bc28166b7e627cca2edeb?d=https%3A%2F%2Fidenticons.github.com%2Fa29d1598024f9e87beab4b98411d48ce.png",
|
4
|
+
"company": "Neo",
|
5
|
+
"location": "Singapore",
|
6
|
+
"html_url": "https://github.com/winston"
|
7
|
+
}
|
data/spec/fixtures/vcr_cassettes/Gigest_GithubConnection/_details_for/returns_account_details.json
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"http_interactions":[{"request":{"method":"get","uri":"https://api.github.com/users/winston","body":{"encoding":"US-ASCII","base64_string":""},"headers":{"Accept":["application/vnd.github.beta+json"],"User-Agent":["Octokit Ruby Gem 2.0.0"],"Accept-Encoding":["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"]}},"response":{"status":{"code":200,"message":"OK"},"headers":{"Server":["GitHub.com"],"Date":["Thu, 29 Aug 2013 08:29:02 GMT"],"Content-Type":["application/json; charset=utf-8"],"Transfer-Encoding":["chunked"],"Status":["200 OK"],"X-Ratelimit-Limit":["60"],"X-Ratelimit-Remaining":["34"],"X-Ratelimit-Reset":["1377766479"],"Cache-Control":["public, max-age=60, s-maxage=60"],"Last-Modified":["Thu, 29 Aug 2013 06:54:51 GMT"],"Etag":["\"4db51d577b726b3ba981242ef001dc55\""],"Vary":["Accept","Accept-Encoding"],"X-Github-Media-Type":["github.beta; format=json"],"X-Content-Type-Options":["nosniff"],"Access-Control-Allow-Credentials":["true"],"Access-Control-Expose-Headers":["ETag, Link, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes"],"Access-Control-Allow-Origin":["*"],"X-Github-Request-Id":["ed681e10-d8a2-47bb-9b02-c086b7b91e0e"]},"body":{"encoding":"UTF-8","base64_string":"eyJsb2dpbiI6IndpbnN0b24iLCJpZCI6MjExMiwiYXZhdGFyX3VybCI6Imh0\ndHBzOi8vMi5ncmF2YXRhci5jb20vYXZhdGFyLzE1YWQxM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5fSIsInJlY2VpdmVkX2V2ZW50c191cmwiOiJodHRwczovL2Fw\naS5naXRodWIuY29tL3VzZXJzL3dpbnN0b24vcmVjZWl2ZWRfZXZlbnRzIiwi\ndHlwZSI6IlVzZXIiLCJuYW1lIjoiV2luc3RvbiIsImNvbXBhbnkiOiJOZW8i\nLCJibG9nIjoiaHR0cDovL3d3dy53aW5zdG9ueXcuY29tIiwibG9jYXRpb24i\nOiJTaW5nYXBvcmUiLCJlbWFpbCI6IndpbnN0b24ueW9uZ3dlaUBnbWFpbC5j\nb20iLCJoaXJlYWJsZSI6ZmFsc2UsImJpbyI6bnVsbCwicHVibGljX3JlcG9z\nIjoyNSwiZm9sbG93ZXJzIjozMywiZm9sbG93aW5nIjoyMiwiY3JlYXRlZF9h\ndCI6IjIwMDgtMDMtMDRUMDc6MTQ6NDBaIiwidXBkYXRlZF9hdCI6IjIwMTMt\nMDgtMjlUMDY6NTQ6NTFaIiwicHVibGljX2dpc3RzIjo1MH0=\n"},"http_version":null},"recorded_at":"Thu, 29 Aug 2013 08:29:03 GMT"}],"recorded_with":"VCR 2.5.0"}
|
@@ -17,7 +17,6 @@ describe Gigest::Analytics do
|
|
17
17
|
let(:account_details) { {name: "naruto", company: "konoha"} }
|
18
18
|
let(:repositories) { [repo1, repo2] }
|
19
19
|
let(:repositories_with_gemfile) { [repo1] }
|
20
|
-
|
21
20
|
let(:repo1) { double(:repo1, has_gemfile?: true) }
|
22
21
|
let(:repo2) { double(:repo2, has_gemfile?: false) }
|
23
22
|
|
@@ -41,7 +40,7 @@ describe Gigest::Analytics do
|
|
41
40
|
end
|
42
41
|
|
43
42
|
describe "#summary", :vcr do
|
44
|
-
let(:expected) { JSON.parse
|
43
|
+
let(:expected) { JSON.parse(File.read(File.join(Dir.pwd, "spec", "fixtures", "summary.json"))) }
|
45
44
|
|
46
45
|
context "when repositories exist" do
|
47
46
|
before { analytics.process_for("winston") }
|
@@ -61,9 +60,8 @@ describe Gigest::Analytics do
|
|
61
60
|
describe "#statistics", :vcr do
|
62
61
|
let(:expected) do
|
63
62
|
contents = JSON.parse(File.read(File.join(Dir.pwd, "spec", "fixtures", "statistics.json")))
|
64
|
-
|
65
|
-
|
66
|
-
end
|
63
|
+
# stringify keys
|
64
|
+
contents.map { |row| row.inject({}) { |memo,(k,v)| memo[k.to_sym] = v; memo } }
|
67
65
|
end
|
68
66
|
|
69
67
|
context "when repositories exist" do
|
@@ -34,22 +34,30 @@ describe Gigest::GithubConnection do
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
describe "#details_for" do
|
38
|
-
let(:
|
37
|
+
describe "#details_for", :vcr do
|
38
|
+
let(:expected) do
|
39
|
+
contents = JSON.parse(File.read(File.join(Dir.pwd, "spec", "fixtures", "account.json")))
|
40
|
+
# stringify keys
|
41
|
+
contents.inject({}) { |memo,(k,v)| memo[k.to_sym] = v; memo }
|
42
|
+
end
|
43
|
+
|
44
|
+
it "returns account details" do
|
45
|
+
expect(connection.details_for("winston")).to eq(expected)
|
46
|
+
end
|
47
|
+
|
48
|
+
context "when account type is specified" do
|
49
|
+
let(:octokit_client) { double(:octokit_client) }
|
39
50
|
|
40
|
-
|
51
|
+
before { Octokit::Client.stub(:new) { octokit_client } }
|
41
52
|
|
42
|
-
context "when account type is user" do
|
43
53
|
it "retrieves user details" do
|
44
|
-
octokit_client.stub(:user)
|
54
|
+
octokit_client.stub(:user) { double(:account).as_null_object }
|
45
55
|
connection.details_for("winston", :user)
|
46
56
|
expect(octokit_client).to have_received(:user).with("winston")
|
47
57
|
end
|
48
|
-
end
|
49
58
|
|
50
|
-
context "when account type is org" do
|
51
59
|
it "retrieves org details" do
|
52
|
-
octokit_client.stub(:organization)
|
60
|
+
octokit_client.stub(:organization) { double(:account).as_null_object }
|
53
61
|
connection.details_for("neo" , :org)
|
54
62
|
expect(octokit_client).to have_received(:organization).with("neo")
|
55
63
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gigest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Winston Teo
|
@@ -103,10 +103,12 @@ files:
|
|
103
103
|
- lib/gigest/github/github_repo.rb
|
104
104
|
- lib/gigest/version.rb
|
105
105
|
- spec/fixtures/Gemfile
|
106
|
+
- spec/fixtures/account.json
|
106
107
|
- spec/fixtures/statistics.json
|
107
108
|
- spec/fixtures/summary.json
|
108
109
|
- spec/fixtures/vcr_cassettes/Gigest_Analytics/_statistics/when_repositories_exist/generates_a_summary_report.json
|
109
110
|
- spec/fixtures/vcr_cassettes/Gigest_Analytics/_summary/when_repositories_exist/generates_a_summary_report.json
|
111
|
+
- spec/fixtures/vcr_cassettes/Gigest_GithubConnection/_details_for/returns_account_details.json
|
110
112
|
- spec/fixtures/vcr_cassettes/Gigest_GithubConnection/_gemfile_for/when_Gemfile_does_not_exist/returns_nil.json
|
111
113
|
- spec/fixtures/vcr_cassettes/Gigest_GithubConnection/_gemfile_for/when_Gemfile_exists/returns_the_Gemfile_contents.json
|
112
114
|
- spec/fixtures/vcr_cassettes/Gigest_GithubConnection/_repositories_for/default/returns_an_array_of_Gigest_GithubRepo.json
|
@@ -140,10 +142,12 @@ specification_version: 4
|
|
140
142
|
summary: GIthubGEmSTats. Discover Gems usage for a GitHub user or org.
|
141
143
|
test_files:
|
142
144
|
- spec/fixtures/Gemfile
|
145
|
+
- spec/fixtures/account.json
|
143
146
|
- spec/fixtures/statistics.json
|
144
147
|
- spec/fixtures/summary.json
|
145
148
|
- spec/fixtures/vcr_cassettes/Gigest_Analytics/_statistics/when_repositories_exist/generates_a_summary_report.json
|
146
149
|
- spec/fixtures/vcr_cassettes/Gigest_Analytics/_summary/when_repositories_exist/generates_a_summary_report.json
|
150
|
+
- spec/fixtures/vcr_cassettes/Gigest_GithubConnection/_details_for/returns_account_details.json
|
147
151
|
- spec/fixtures/vcr_cassettes/Gigest_GithubConnection/_gemfile_for/when_Gemfile_does_not_exist/returns_nil.json
|
148
152
|
- spec/fixtures/vcr_cassettes/Gigest_GithubConnection/_gemfile_for/when_Gemfile_exists/returns_the_Gemfile_contents.json
|
149
153
|
- spec/fixtures/vcr_cassettes/Gigest_GithubConnection/_repositories_for/default/returns_an_array_of_Gigest_GithubRepo.json
|