tetra 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,11 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tetra (1.0.0)
4
+ tetra (1.1.0)
5
5
  clamp
6
6
  json_pure
7
7
  open4
8
- rest-client
9
8
  rubyzip (>= 1.0)
10
9
  text
11
10
 
@@ -14,19 +13,9 @@ GEM
14
13
  specs:
15
14
  clamp (0.6.5)
16
15
  diff-lcs (1.2.5)
17
- domain_name (0.5.24)
18
- unf (>= 0.0.5, < 1.0.0)
19
- http-cookie (1.0.2)
20
- domain_name (~> 0.5)
21
16
  json_pure (1.8.2)
22
- mime-types (2.6.1)
23
- netrc (0.10.3)
24
17
  open4 (1.3.4)
25
18
  rake (10.4.2)
26
- rest-client (1.8.0)
27
- http-cookie (>= 1.0.2, < 2.0)
28
- mime-types (>= 1.16, < 3.0)
29
- netrc (~> 0.7)
30
19
  rspec (3.2.0)
31
20
  rspec-core (~> 3.2.0)
32
21
  rspec-expectations (~> 3.2.0)
@@ -42,9 +31,6 @@ GEM
42
31
  rspec-support (3.2.2)
43
32
  rubyzip (1.1.7)
44
33
  text (1.3.1)
45
- unf (0.1.4)
46
- unf_ext
47
- unf_ext (0.0.7.1)
48
34
 
49
35
  PLATFORMS
50
36
  ruby
data/README.md CHANGED
@@ -10,7 +10,7 @@ See [MOTIVATION.md](MOTIVATION.md) for further information.
10
10
 
11
11
  You need:
12
12
 
13
- * [Ruby 1.9](https://www.ruby-lang.org/en/);
13
+ * [Ruby 1.9.2](https://www.ruby-lang.org/en/) or later;
14
14
  * [git](http://git-scm.com/);
15
15
  * bash;
16
16
  * a JDK that can compile whatever software you need to package;
data/lib/tetra.rb CHANGED
@@ -11,6 +11,7 @@ require "open-uri"
11
11
  require "pathname"
12
12
  require "singleton"
13
13
  require "rexml/document"
14
+ require "net/http"
14
15
 
15
16
  # third party libraries
16
17
  require "clamp"
@@ -36,9 +36,7 @@ module Tetra
36
36
  # returns a search result object from search.maven.com
37
37
  # see input and output format at http://search.maven.org/#api
38
38
  def search(params)
39
- response = RestClient.get("http://search.maven.org/solrsearch/select",
40
- params: params.merge("rows" => "100", "wt" => "json")
41
- )
39
+ response = get("http://search.maven.org/solrsearch/select?", params.merge("rows" => "100", "wt" => "json"))
42
40
  json = JSON.parse(response.to_s)
43
41
  json["response"]["docs"]
44
42
  end
@@ -53,7 +51,17 @@ module Tetra
53
51
  def download_pom(group_id, artifact_id, version)
54
52
  path = "#{group_id.gsub('.', '/')}/#{artifact_id}/#{version}/#{artifact_id}-#{version}.pom"
55
53
  log.debug("downloading #{path}...")
56
- (RestClient.get("http://search.maven.org/remotecontent", params: { filepath: path })).to_s
54
+ get("http://repo1.maven.org/maven2/#{path}", {}).to_s
57
55
  end
56
+
57
+ def get(url, params)
58
+ response = Net::HTTP.get_response(URI.parse(url + URI.encode_www_form(params)))
59
+ fail NotFoundOnMavenWebsiteError if response.code == "404"
60
+
61
+ response.body
62
+ end
63
+ end
64
+
65
+ class NotFoundOnMavenWebsiteError < StandardError
58
66
  end
59
67
  end
@@ -51,7 +51,7 @@ module Tetra
51
51
  return site.download_pom(group_id, artifact_id, version), :found_via_sha1
52
52
  end
53
53
  end
54
- rescue RestClient::ResourceNotFound
54
+ rescue NotFoundOnMavenWebsiteError
55
55
  log.warn("Got a 404 error while looking for #{file}'s SHA1 in search.maven.org")
56
56
  end
57
57
  nil
@@ -90,7 +90,7 @@ module Tetra
90
90
 
91
91
  return site.download_pom(group_id, artifact_id, version), :found_via_heuristic
92
92
  end
93
- rescue RestClient::ResourceNotFound
93
+ rescue NotFoundOnMavenWebsiteError
94
94
  log.warn("Got a 404 error while looking for #{filename} heuristically in search.maven.org")
95
95
  end
96
96
  nil
data/lib/tetra/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  # base module for tetra
4
4
  module Tetra
5
- VERSION = "1.1.0"
5
+ VERSION = "1.2.0"
6
6
  end
@@ -52,5 +52,10 @@ describe Tetra::MavenWebsite do
52
52
  pom_path = File.join(dir_path, "pom.xml")
53
53
  expect(site.download_pom("antlr", "antlrall", "2.7.2")).to eq(File.read(pom_path))
54
54
  end
55
+ it "returns an error on file not found" do
56
+ expect do
57
+ site.download_pom("does_not_exist", "does_not_exist", "does_not_exist")
58
+ end.to raise_error(Tetra::NotFoundOnMavenWebsiteError)
59
+ end
55
60
  end
56
61
  end
data/spec/lib/pom_spec.rb CHANGED
@@ -39,6 +39,7 @@ describe Tetra::Pom do
39
39
  end
40
40
  end
41
41
 
42
+ # rubocop:disable Metrics/LineLength, Style/TrailingWhitespace
42
43
  describe "#description" do
43
44
  it "reads the description" do
44
45
  expect(commons_pom.description).to eq "Commons Logging is a thin adapter allowing configurable bridging to other,
@@ -54,6 +55,7 @@ describe Tetra::Pom do
54
55
  expect(struts_apps_pom.description).to eq ""
55
56
  end
56
57
  end
58
+ # rubocop:enable Metrics/LineLength, Style/TrailingWhitespace
57
59
 
58
60
  describe "#url" do
59
61
  it "reads the url" do
@@ -84,13 +86,15 @@ describe Tetra::Pom do
84
86
  expect(commons_pom.scm_connection).to eq "scm:svn:http://svn.apache.org/repos/asf/commons/proper/" \
85
87
  "logging/tags/commons-logging-1.1.1"
86
88
  expect(nailgun_pom.scm_connection).to eq "scm:git:git@github.com:martylamb/nailgun.git"
87
- expect(struts_apps_pom.scm_connection).to eq "scm:svn:http://svn.apache.org/repos/asf/struts/struts2/tags/STRUTS_2_3_14/apps"
89
+ expect(struts_apps_pom.scm_connection).to eq "scm:svn:http://svn.apache.org/repos/asf/struts/struts2/" \
90
+ "tags/STRUTS_2_3_14/apps"
88
91
  end
89
92
  end
90
93
 
91
94
  describe "#scm_url" do
92
95
  it "reads the SCM connection url" do
93
- expect(commons_pom.scm_url).to eq "http://svn.apache.org/repos/asf/commons/proper/logging/tags/commons-logging-1.1.1"
96
+ expect(commons_pom.scm_url).to eq "http://svn.apache.org/repos/asf/commons/proper/logging/tags/" \
97
+ "commons-logging-1.1.1"
94
98
  expect(nailgun_pom.scm_url).to eq "scm:git:git@github.com:martylamb/nailgun.git"
95
99
  expect(struts_apps_pom.scm_url).to eq "http://svn.apache.org/viewcvs.cgi/struts/struts2/tags/STRUTS_2_3_14/apps"
96
100
  end
data/tetra.gemspec CHANGED
@@ -25,7 +25,6 @@ Gem::Specification.new do |s|
25
25
  s.add_runtime_dependency "clamp"
26
26
  s.add_runtime_dependency "json_pure"
27
27
  s.add_runtime_dependency "open4"
28
- s.add_runtime_dependency "rest-client"
29
28
  s.add_runtime_dependency "rubyzip", ">= 1.0"
30
29
  s.add_runtime_dependency "text"
31
30
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tetra
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-06-05 00:00:00.000000000 Z
12
+ date: 2015-06-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -91,22 +91,6 @@ dependencies:
91
91
  - - ! '>='
92
92
  - !ruby/object:Gem::Version
93
93
  version: '0'
94
- - !ruby/object:Gem::Dependency
95
- name: rest-client
96
- requirement: !ruby/object:Gem::Requirement
97
- none: false
98
- requirements:
99
- - - ! '>='
100
- - !ruby/object:Gem::Version
101
- version: '0'
102
- type: :runtime
103
- prerelease: false
104
- version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
- requirements:
107
- - - ! '>='
108
- - !ruby/object:Gem::Version
109
- version: '0'
110
94
  - !ruby/object:Gem::Dependency
111
95
  name: rubyzip
112
96
  requirement: !ruby/object:Gem::Requirement