compare_linker 1.1.4 → 1.1.5

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: 47654b7ad39f88145694628f36f54bf1a0063a5d
4
- data.tar.gz: cff0a2c629e0a4050d83a30e74f58c4738ed357b
3
+ metadata.gz: c0ff36e8002d51aa16c9c31b9d187f564eac1d53
4
+ data.tar.gz: 8adab281e5f6a8fcb53c41041a566b45a98235e7
5
5
  SHA512:
6
- metadata.gz: aa2743c90967af73d6ac6fb7506871d35dd908e80e23703dc5d9c765d0ba7d85f584e54d93858f69e6538bc4bdbde3d49c8ab5f6fa10b61fd28f74e52017f2a3
7
- data.tar.gz: 821f8334ea9caffe17e689fa7c66a3eab847471557b231440cfed1b5aa82b0e47f399273bbb3f6816c759fdcbca672ff162d4c0c5ea7a82ab074711cc190fae6
6
+ metadata.gz: bb90094ecc911eecad452ed5967cd700fd9c1646da356ba2d36d1dbb5832a55196e7af9e4935772ec0dcc98e763c919321b19f815b7606253937ebfaf26d339a
7
+ data.tar.gz: 75da3f152b86ce87b961df282d882c84c26c2c5da57f28c194cddd325025b79977c936c7283dfad148aea476adebd0a7869c84b5dbd8ff570f9acd9ffacb0cd6
data/Gemfile.lock CHANGED
@@ -1,14 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- compare_linker (1.1.4)
4
+ compare_linker (1.1.5)
5
5
  httpclient
6
6
  octokit
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- addressable (2.3.7)
11
+ addressable (2.3.8)
12
12
  diff-lcs (1.2.5)
13
13
  faraday (0.9.1)
14
14
  multipart-post (>= 1.2, < 3)
@@ -1,6 +1,5 @@
1
1
  require "json"
2
2
  require "httpclient"
3
- require "net/http"
4
3
 
5
4
  class CompareLinker
6
5
  class GithubLinkFinder
@@ -12,7 +11,7 @@ class CompareLinker
12
11
 
13
12
  def find(gem_name)
14
13
  gem_info = JSON.parse(
15
- HTTPClient.get("https://rubygems.org/api/v1/gems/#{gem_name}.json").body
14
+ HTTPClient.get_content("https://rubygems.org/api/v1/gems/#{gem_name}.json")
16
15
  )
17
16
 
18
17
  github_url = [
@@ -23,7 +22,6 @@ class CompareLinker
23
22
  if github_url.nil?
24
23
  @homepage_uri = gem_info["homepage_uri"]
25
24
  else
26
- github_url = redirect_url(github_url)
27
25
  _, @repo_owner, @repo_name = github_url.match(%r!github\.com/([^/]+)/([^/]+)!).to_a
28
26
  end
29
27
 
@@ -34,20 +32,5 @@ class CompareLinker
34
32
  def repo_full_name
35
33
  "#{@repo_owner}/#{repo_name}"
36
34
  end
37
-
38
- private
39
-
40
- def redirect_url(url, limit = 5)
41
- raise ArgumentError, 'HTTP redirect too deep' if limit <= 0
42
- response = Net::HTTP.get_response(URI.parse(url))
43
- case response
44
- when Net::HTTPSuccess
45
- url
46
- when Net::HTTPRedirection
47
- redirect_url(response['location'], limit - 1)
48
- else
49
- raise ItemNotFound
50
- end
51
- end
52
35
  end
53
36
  end
@@ -1,3 +1,3 @@
1
1
  class CompareLinker
2
- VERSION = "1.1.4"
2
+ VERSION = "1.1.5"
3
3
  end
@@ -8,7 +8,7 @@ describe CompareLinker::GithubLinkFinder do
8
8
 
9
9
  describe "#find" do
10
10
  before do
11
- allow(HTTPClient).to receive_message_chain(:get, :body).and_return load_fixture("rails.json")
11
+ allow(HTTPClient).to receive(:get_content).and_return load_fixture("rails.json")
12
12
  end
13
13
 
14
14
  it "extracts repo_owner and repo_name" do
@@ -19,7 +19,7 @@ describe CompareLinker::GithubLinkFinder do
19
19
 
20
20
  context "if github url includes trailing slash" do
21
21
  before do
22
- allow(HTTPClient).to receive_message_chain(:get, :body).and_return load_fixture("web_translate_it.json")
22
+ allow(HTTPClient).to receive(:get_content).and_return load_fixture("web_translate_it.json")
23
23
  end
24
24
 
25
25
  it "extracts repo_owner and repo_name without trailing slash" do
@@ -31,7 +31,7 @@ describe CompareLinker::GithubLinkFinder do
31
31
 
32
32
  context "if gem not found on rubygems.org" do
33
33
  before do
34
- allow(HTTPClient).to receive_message_chain(:get, :body).and_return load_fixture("not_found.json")
34
+ allow(HTTPClient).to receive(:get_content).and_return load_fixture("not_found.json")
35
35
  end
36
36
 
37
37
  it "extracts homepage_uri" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: compare_linker
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kensuke Nagae
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-24 00:00:00.000000000 Z
11
+ date: 2015-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit