compare_linker 1.1.7 → 1.1.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 77a7f1b91fab3b694011b66ae937c8321a0fa287
4
- data.tar.gz: 776bfcc6f09254ead72883cb229c9c43f116f8fc
3
+ metadata.gz: 6f0e3bda9179cf4d4c524678a35ab90e6bfc4f59
4
+ data.tar.gz: 1f50cd40c055491ab0a93443bbe213cfe0483f07
5
5
  SHA512:
6
- metadata.gz: 35f9148e6da4b569bf0253eef283e93d0fb7afb726b3369c64d4974d14bac5544d81e9a39a4ddf221bf41f346b75b577f5158bd828952387c77e37a111a41a34
7
- data.tar.gz: 385ec662dc463457213b163568f6ce557a1ffbf24bef4bdb8ce07570052622e9fbbb204d3d132fa1cdc9922f3e43f3967e389e0eb94d1a38aeb370c1433a95fb
6
+ metadata.gz: 135c0afd55875f951969b2e2fe815c9d4dfc7b5ec8fbc992a90ce6fccaa8d07f06c4381c6078a1d02e2f703fb2c53611a8a6f1cd6fcf70aa2a82ea837ca42cfc
7
+ data.tar.gz: 11e4d41e901270e29d2f13673b1f1891b944ac7c75901b9bbce3bacee92fd510e7a1d0b142511a9b94686907e3503d546bc58b23db92a61fcd18541614d9d51c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- compare_linker (1.1.7)
4
+ compare_linker (1.1.8)
5
5
  httpclient
6
6
  octokit
7
7
 
@@ -20,14 +20,13 @@ class CompareLinker
20
20
  gem_info["source_code_uri"]
21
21
  ].find { |uri| uri.to_s.match(/github\.com\//) }
22
22
 
23
- if github_url.nil?
24
- @homepage_uri = gem_info["homepage_uri"]
25
- else
26
- github_url = redirect_url(github_url)
23
+ if github_url = redirect_url(github_url)
27
24
  _, @repo_owner, @repo_name = github_url.match(%r!github\.com/([^/]+)/([^/]+)!).to_a
25
+ else
26
+ @homepage_uri = gem_info["homepage_uri"]
28
27
  end
29
28
 
30
- rescue JSON::ParserError
29
+ rescue HTTPClient::BadResponseError
31
30
  @homepage_uri = "https://rubygems.org/gems/#{gem_name}"
32
31
  end
33
32
 
@@ -38,7 +37,8 @@ class CompareLinker
38
37
  private
39
38
 
40
39
  def redirect_url(url, limit = 5)
41
- raise ArgumentError, 'HTTP redirect too deep' if limit <= 0
40
+ return nil if url.nil?
41
+ return nil if limit <= 0
42
42
 
43
43
  uri = URI.parse(url)
44
44
  response = Net::HTTP.get_response(uri)
@@ -49,7 +49,7 @@ class CompareLinker
49
49
  when Net::HTTPRedirection
50
50
  redirect_url(to_absolute(response['location'], uri), limit - 1)
51
51
  else
52
- raise 'item not found'
52
+ nil
53
53
  end
54
54
  end
55
55
 
@@ -1,3 +1,3 @@
1
1
  class CompareLinker
2
- VERSION = "1.1.7"
2
+ VERSION = "1.1.8"
3
3
  end
@@ -0,0 +1 @@
1
+ {"name":"coffee-script-source","downloads":23413938,"version":"1.9.1.1","version_downloads":10964,"platform":"ruby","authors":"Jeremy Ashkenas","info":" CoffeeScript is a little language that compiles into JavaScript.\n Underneath all of those embarrassing braces and semicolons,\n JavaScript has always had a gorgeous object model at its heart.\n CoffeeScript is an attempt to expose the good parts of JavaScript\n in a simple way.\n","licenses":["MIT"],"metadata":{},"sha":"05bbce02078abdb6969abfee5b18b9b914b475895222acac3d5613fe3dcf2eab","project_uri":"http://rubygems.org/gems/coffee-script-source","gem_uri":"http://rubygems.org/gems/coffee-script-source-1.9.1.1.gem","homepage_uri":"http://jashkenas.github.com/coffee-script/","wiki_uri":null,"documentation_uri":null,"mailing_list_uri":null,"source_code_uri":null,"bug_tracker_uri":null,"dependencies":{"development":[],"runtime":[]}}
@@ -33,7 +33,8 @@ describe CompareLinker::GithubLinkFinder do
33
33
 
34
34
  context "if gem not found on rubygems.org" do
35
35
  before do
36
- allow(HTTPClient).to receive(:get_content).and_return load_fixture("not_found.json")
36
+ exception = HTTPClient::BadResponseError.new "unexpected response:..."
37
+ allow(HTTPClient).to receive(:get_content).and_raise exception
37
38
  end
38
39
 
39
40
  it "extracts homepage_uri" do
@@ -41,5 +42,17 @@ describe CompareLinker::GithubLinkFinder do
41
42
  expect(subject.homepage_uri).to eq "https://rubygems.org/gems/not_found"
42
43
  end
43
44
  end
45
+
46
+ context "if homepage_uri is '404 not found'" do
47
+ before do
48
+ allow(HTTPClient).to receive(:get_content).and_return load_fixture("coffee-script-source.json")
49
+ allow(subject).to receive(:redirect_url).and_return nil
50
+ end
51
+
52
+ it "extracts homepage_uri" do
53
+ subject.find("coffee-script-source")
54
+ expect(subject.homepage_uri).to eq "http://jashkenas.github.com/coffee-script/"
55
+ end
56
+ end
44
57
  end
45
58
  end
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.7
4
+ version: 1.1.8
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-04-11 00:00:00.000000000 Z
11
+ date: 2015-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit
@@ -110,7 +110,7 @@ files:
110
110
  - lib/compare_linker/webhook_payload.rb
111
111
  - payload.rb
112
112
  - runner.rb
113
- - spec/fixtures/not_found.json
113
+ - spec/fixtures/coffee-script-source.json
114
114
  - spec/fixtures/rails.json
115
115
  - spec/fixtures/web_translate_it.json
116
116
  - spec/lib/compare_linker/github_link_finder_spec.rb
@@ -141,7 +141,7 @@ signing_key:
141
141
  specification_version: 4
142
142
  summary: Create GitHub's compare view URLs for pull request
143
143
  test_files:
144
- - spec/fixtures/not_found.json
144
+ - spec/fixtures/coffee-script-source.json
145
145
  - spec/fixtures/rails.json
146
146
  - spec/fixtures/web_translate_it.json
147
147
  - spec/lib/compare_linker/github_link_finder_spec.rb
@@ -1 +0,0 @@
1
- This rubygem could not be found.