rubygems-code_finder 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -0
- data/CHANGELOG.md +6 -1
- data/Gemfile +1 -1
- data/lib/rubygems/code_finder/version.rb +1 -1
- data/lib/rubygems-code_finder.rb +11 -3
- data/spec/rubygems/code_finder/url_spec.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: deb56d11bcf9214b2e18f055a58b23deb57ca41f
|
4
|
+
data.tar.gz: 1e3adc7ed1ecfb3f3015bf5a6cdcf4b3f8d02d03
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: afb4c9c380642578b199f7048a82d01bd8c132ece441e1db7a12bea957e97ac0a444b2d89e82d7ff089da0940505bafd941158c7e1fa696a48c2f8d9b1ceb398
|
7
|
+
data.tar.gz: 58e118bdfc6df2dd19ecfebcf0b55565c965f0d0889bff7b02b9aadbc7d0f82f33469cac7a842a2c5f846b01ad0d499ad7af780eea858804d81fff374a8159c8
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## 0.0.4(2014-02-23)
|
2
|
+
Features:
|
3
|
+
|
4
|
+
- Add ruby1.9.3 support (#5, @sanemat)
|
5
|
+
|
1
6
|
## 0.0.3 (2014-02-23)
|
2
7
|
Features:
|
3
8
|
|
@@ -6,7 +11,7 @@
|
|
6
11
|
## 0.0.2 (2014-02-23)
|
7
12
|
Fixes:
|
8
13
|
|
9
|
-
-
|
14
|
+
- Adjust empty url (#1, @sanemat)
|
10
15
|
|
11
16
|
## 0.0.1 (2014-02-23)
|
12
17
|
Features:
|
data/Gemfile
CHANGED
data/lib/rubygems-code_finder.rb
CHANGED
@@ -10,19 +10,27 @@ module Rubygems
|
|
10
10
|
class RubygemsNotFound < StandardError; end
|
11
11
|
class RepositoryNotFound < StandardError; end
|
12
12
|
|
13
|
-
def url(name,
|
13
|
+
def url(name, options = {})
|
14
|
+
github_strict = options[:github_strict] || true
|
14
15
|
conn = Faraday.new 'https://rubygems.org'
|
15
16
|
response = conn.get('/api/v1/gems/' + name + '.json')
|
16
17
|
fail RubygemsNotFound unless response.status == 200
|
17
|
-
|
18
|
+
begin
|
19
|
+
parse_response_body(response.body)
|
20
|
+
rescue RepositoryNotFound => e
|
21
|
+
search_github(name)
|
22
|
+
end
|
18
23
|
end
|
19
24
|
|
20
25
|
def parse_response_body(body)
|
21
26
|
data = MultiJson.load(body)
|
22
27
|
return data['source_code_uri'] if data['source_code_uri'] && URI.parse(data['source_code_uri']).host == 'github.com'
|
23
28
|
return data['homepage_uri'] if data['homepage_uri'] && URI.parse(data['homepage_uri']).host == 'github.com'
|
29
|
+
fail RepositoryNotFound
|
30
|
+
end
|
24
31
|
|
25
|
-
|
32
|
+
def search_github(name)
|
33
|
+
res = Octokit.search_repositories name
|
26
34
|
return 'https://github.com/' + res.items.first.full_name if res.items.count >= 1
|
27
35
|
fail RepositoryNotFound
|
28
36
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require_relative '../../spec_helper'
|
2
|
-
require 'byebug'
|
2
|
+
require 'byebug' if RUBY_VERSION >= '2'
|
3
3
|
|
4
4
|
describe Rubygems::CodeFinder do
|
5
5
|
it 'returns source_code_uri' do
|
@@ -26,7 +26,7 @@ describe Rubygems::CodeFinder do
|
|
26
26
|
stub_request(:get, 'https://rubygems.org/api/v1/gems/fluentd.json').
|
27
27
|
to_return(status: 200, body: File.new('./spec/fixtures/fluentd.json'), headers: {})
|
28
28
|
stub_request(:get, 'https://api.github.com/search/repositories?q=fluentd').
|
29
|
-
to_return(status: 200, body: File.new('./spec/fixtures/repositories?q=fluentd'), headers: { content_type: 'application/json; charset=utf-8'})
|
29
|
+
to_return(status: 200, body: File.new('./spec/fixtures/repositories?q=fluentd'), headers: { content_type: 'application/json; charset=utf-8' })
|
30
30
|
|
31
31
|
expect(Rubygems::CodeFinder.url('fluentd')).to eq 'https://github.com/fluent/fluentd'
|
32
32
|
end
|
@@ -35,7 +35,7 @@ describe Rubygems::CodeFinder do
|
|
35
35
|
stub_request(:get, 'https://rubygems.org/api/v1/gems/fluentd.json').
|
36
36
|
to_return(status: 200, body: File.new('./spec/fixtures/fluentd.json'), headers: {})
|
37
37
|
stub_request(:get, 'https://api.github.com/search/repositories?q=fluentd').
|
38
|
-
to_return(status: 200, body: File.new('./spec/fixtures/repositories?q=reposnotfound'), headers: { content_type: 'application/json; charset=utf-8'})
|
38
|
+
to_return(status: 200, body: File.new('./spec/fixtures/repositories?q=reposnotfound'), headers: { content_type: 'application/json; charset=utf-8' })
|
39
39
|
|
40
40
|
expect { Rubygems::CodeFinder.url('fluentd') }.to raise_error(Rubygems::CodeFinder::RepositoryNotFound)
|
41
41
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubygems-code_finder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sanemat
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|