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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c80b17529159ac4b3866452626e67c50999a0cab
4
- data.tar.gz: e377fb2b2c500b9677d183afd79af4413694321d
3
+ metadata.gz: deb56d11bcf9214b2e18f055a58b23deb57ca41f
4
+ data.tar.gz: 1e3adc7ed1ecfb3f3015bf5a6cdcf4b3f8d02d03
5
5
  SHA512:
6
- metadata.gz: 565b98f0d4af096091da776348bdab88049df184c94d2ebc2c0772c8961af9ccd4cbc7002a1073d5f908e5ce981c37f62e466431e7a098fa4a9db6d2be71af05
7
- data.tar.gz: 5ee6b72f9492a8762c5d68bfba7b11bd4d87e48c502484ca56c4274b844569ffde6afbd9808c08d73d47b76451a720948fc0b5fb14736ffb49f81f22a0332320
6
+ metadata.gz: afb4c9c380642578b199f7048a82d01bd8c132ece441e1db7a12bea957e97ac0a444b2d89e82d7ff089da0940505bafd941158c7e1fa696a48c2f8d9b1ceb398
7
+ data.tar.gz: 58e118bdfc6df2dd19ecfebcf0b55565c965f0d0889bff7b02b9aadbc7d0f82f33469cac7a842a2c5f846b01ad0d499ad7af780eea858804d81fff374a8159c8
data/.travis.yml CHANGED
@@ -1,7 +1,11 @@
1
1
  language: ruby
2
2
  rvm:
3
+ - 1.9.3
3
4
  - 2.0.0
4
5
  - 2.1.0
5
6
  branches:
6
7
  only:
7
8
  - master
9
+ notifications:
10
+ email:
11
+ - ogataken@gmail.com
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
- - Adujst empty url (#1, @sanemat)
14
+ - Adjust empty url (#1, @sanemat)
10
15
 
11
16
  ## 0.0.1 (2014-02-23)
12
17
  Features:
data/Gemfile CHANGED
@@ -7,5 +7,5 @@ gem 'oj'
7
7
 
8
8
  group :development, :test do
9
9
  gem 'coveralls', require: false
10
- gem 'byebug'
10
+ gem 'byebug' if RUBY_VERSION >= '2'
11
11
  end
@@ -1,5 +1,5 @@
1
1
  module Rubygems
2
2
  module CodeFinder
3
- VERSION = '0.0.3'
3
+ VERSION = '0.0.4'
4
4
  end
5
5
  end
@@ -10,19 +10,27 @@ module Rubygems
10
10
  class RubygemsNotFound < StandardError; end
11
11
  class RepositoryNotFound < StandardError; end
12
12
 
13
- def url(name, github_strict: true)
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
- parse_response_body(response.body)
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
- res = Octokit.search_repositories data['name']
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.3
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-22 00:00:00.000000000 Z
11
+ date: 2014-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday