maremma 2.3.1 → 2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZjQ3OGFkNDYzZDQ2NGE1NzFiOWY0NWViZDYxNzRkMjViYTMxYTFlNA==
5
- data.tar.gz: !binary |-
6
- YTAyZGI5NzNhMWJjYmU0YTA3ZGMzYzQyZGEwYzFlMzkxZGY2MWY2OA==
2
+ SHA1:
3
+ metadata.gz: 861a9dc4a8cc68ef10480b07b8b07cf5d08850c5
4
+ data.tar.gz: 6fd6ea07604967c5ea0c5fc83e8aac1c16e6aa55
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- NWZiY2Y0NGQzNTViY2JkMDE1N2I1MjA2NjVlOTg1NDI4MTZhN2YwODE0ZWNh
10
- ODUxZDg5NDY2OWNlYjAxOTI3ZWU4MTBkNDUyYTEyMjg3NDFiN2MwM2NlOThm
11
- ZjcyZjc0NzA2MTU0NmZmYjc2YjE2MGRmMDU1M2YxMjJmYzlmMDQ=
12
- data.tar.gz: !binary |-
13
- ZDRiM2E0M2ZjYjBmZTNlYjljODMzNDlkYjZmMjE1NzY1ZDkyMzFjYjhkODYx
14
- ZDY0NjViNTE4NmQzNTE0NDI3ZGU5MDkzNzA5ZGM5ZDQ3YjhmMzJlZGQ1NzZh
15
- ZWIwZmQxMGQ3NjRlMzJkMDJhYzY5NjE2Y2QxOGZmMWUxYjliMzA=
6
+ metadata.gz: c053633946f44f2cf70fefad942cc34615699bea11e0571099a830fba81eafbca455a1ee48e1fb89dfd335e655a62951d9f99135ecda8034a53c559ba8a9cac5
7
+ data.tar.gz: 6a2dbd38d6d2af002ceeb10b4430c980a15dc8520c666891e60a2ade88d960ede994457c0a337fe0245c5f95ded4b0e3be0d81caed0629de34a694ff48f891fa
data/.travis.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.4
3
+ - 2.3.1
4
4
  install:
5
5
  - travis_retry bundle install
6
6
  script: bundle exec rspec
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## v.2.4 (November 6, 2016)
2
+
3
+ [maremma 2.4](https://github.com/datacite/maremma/releases/tag/v.2.4) was released on November, 2016:
4
+
5
+ * set `Content-type` and `Accept` headers separately. This is a breaking change
6
+ * upgrade `codeclimate-test-reporter` gem
7
+
1
8
  ## v.2.3.1 (September 2, 2016)
2
9
 
3
10
  [maremma 2.3.1](https://github.com/datacite/maremma/releases/tag/v.2.3.1) was released on September 2, 2016:
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- maremma (2.3.1)
4
+ maremma (2.4)
5
5
  activesupport (~> 4.2, >= 4.2.5)
6
6
  builder (~> 3.2, >= 3.2.2)
7
7
  excon (~> 0.45.0)
@@ -21,15 +21,18 @@ GEM
21
21
  minitest (~> 5.1)
22
22
  thread_safe (~> 0.3, >= 0.3.4)
23
23
  tzinfo (~> 1.1)
24
- addressable (2.4.0)
24
+ addressable (2.5.0)
25
+ public_suffix (~> 2.0, >= 2.0.2)
25
26
  builder (3.2.2)
27
+ codeclimate-test-reporter (1.0.0)
26
28
  crack (0.4.3)
27
29
  safe_yaml (~> 1.0.0)
28
30
  diff-lcs (1.2.5)
31
+ docile (1.1.5)
29
32
  excon (0.45.4)
30
33
  faraday (0.9.2)
31
34
  multipart-post (>= 1.2, < 3)
32
- faraday-encoding (0.0.3)
35
+ faraday-encoding (0.0.4)
33
36
  faraday
34
37
  faraday_middleware (0.10.0)
35
38
  faraday (>= 0.7.4, < 0.10)
@@ -37,32 +40,36 @@ GEM
37
40
  i18n (0.7.0)
38
41
  json (1.8.3)
39
42
  mini_portile2 (2.1.0)
40
- minitest (5.9.0)
43
+ minitest (5.9.1)
41
44
  multi_json (1.11.3)
42
45
  multipart-post (2.0.0)
43
- nokogiri (1.6.8)
46
+ nokogiri (1.6.8.1)
44
47
  mini_portile2 (~> 2.1.0)
45
- pkg-config (~> 1.1.7)
46
48
  oj (2.13.1)
47
- pkg-config (1.1.7)
49
+ public_suffix (2.0.3)
48
50
  rack (2.0.1)
49
51
  rack-test (0.6.3)
50
52
  rack (>= 1.0)
51
- rake (11.2.2)
52
- rspec (3.4.0)
53
- rspec-core (~> 3.4.0)
54
- rspec-expectations (~> 3.4.0)
55
- rspec-mocks (~> 3.4.0)
56
- rspec-core (3.4.4)
57
- rspec-support (~> 3.4.0)
58
- rspec-expectations (3.4.0)
53
+ rake (11.3.0)
54
+ rspec (3.5.0)
55
+ rspec-core (~> 3.5.0)
56
+ rspec-expectations (~> 3.5.0)
57
+ rspec-mocks (~> 3.5.0)
58
+ rspec-core (3.5.4)
59
+ rspec-support (~> 3.5.0)
60
+ rspec-expectations (3.5.0)
59
61
  diff-lcs (>= 1.2.0, < 2.0)
60
- rspec-support (~> 3.4.0)
61
- rspec-mocks (3.4.1)
62
+ rspec-support (~> 3.5.0)
63
+ rspec-mocks (3.5.0)
62
64
  diff-lcs (>= 1.2.0, < 2.0)
63
- rspec-support (~> 3.4.0)
64
- rspec-support (3.4.1)
65
+ rspec-support (~> 3.5.0)
66
+ rspec-support (3.5.0)
65
67
  safe_yaml (1.0.4)
68
+ simplecov (0.12.0)
69
+ docile (~> 1.1.0)
70
+ json (>= 1.8, < 3)
71
+ simplecov-html (~> 0.10.0)
72
+ simplecov-html (0.10.0)
66
73
  thread_safe (0.3.5)
67
74
  tzinfo (1.2.2)
68
75
  thread_safe (~> 0.1)
@@ -77,10 +84,12 @@ PLATFORMS
77
84
 
78
85
  DEPENDENCIES
79
86
  bundler (~> 1.0)
87
+ codeclimate-test-reporter (~> 1.0.0)
80
88
  maremma!
81
89
  rack-test (~> 0)
82
90
  rake
83
91
  rspec (~> 3.4)
92
+ simplecov
84
93
  vcr
85
94
  webmock (~> 1.22, >= 1.22.3)
86
95
 
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Maremma
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/maremma.svg)](https://badge.fury.io/rb/maremma)
3
4
  [![Build Status](https://travis-ci.org/datacite/maremma.svg?branch=master)](https://travis-ci.org/datacite/maremma)
5
+ [![Test Coverage](https://codeclimate.com/github/datacite/maremma/badges/coverage.svg)](https://codeclimate.com/github/datacite/maremma/coverage)
4
6
  [![Code Climate](https://codeclimate.com/github/datacite/maremma/badges/gpa.svg)](https://codeclimate.com/github/datacite/maremma)
5
7
 
6
8
  Utility library for network calls. Based on [Faraday](https://github.com/lostisland/faraday) and [Excon](https://github.com/excon/excon), provides a wrapper for XML/JSON parsing and error handling. All successful responses are returned as hash with key `data`, all errors in a JSONAPI-friendly hash with key `errors`.
@@ -23,7 +25,13 @@ gem install maremma
23
25
 
24
26
  ## Usage
25
27
  ```ruby
26
- Maremma.get 'http://dlm.datacite.org/heartbeat' => {"services"=>{"mysql"=>"OK", "memcached"=>"OK", "redis"=>"OK", "sidekiq"=>"OK", "postfix"=>"failed"}, "version"=>"4.3", "status"=>"failed"}
28
+ Maremma.get 'http://dlm.datacite.org/heartbeat' => { "data" => { "services"=>{ "mysql"=>"OK",
29
+ "memcached"=>"OK",
30
+ "redis"=>"OK",
31
+ "sidekiq"=>"OK",
32
+ "postfix"=>"failed" },
33
+ "version"=>"4.3",
34
+ "status"=>"failed" }}
27
35
  Maremma.post 'http://example.com', data: { 'foo' => 'baz' }
28
36
  ```
29
37
 
data/lib/maremma.rb CHANGED
@@ -63,6 +63,7 @@ module Maremma
63
63
 
64
64
  Faraday.new do |c|
65
65
  c.options.params_encoder = Faraday::FlatParamsEncoder
66
+ c.headers['Content-type'] = options[:headers]['Content-type']
66
67
  c.headers['Accept'] = options[:headers]['Accept']
67
68
  c.headers['User-Agent'] = options[:headers]['User-Agent']
68
69
  c.use FaradayMiddleware::FollowRedirects, limit: limit, cookie: :all
@@ -80,15 +81,23 @@ module Maremma
80
81
  # set useragent
81
82
  options[:headers]['User-Agent'] = ENV['HOSTNAME'].present? ? "Maremma - http://#{ENV['HOSTNAME']}" : "Maremma - https://github.com/datacite/maremma"
82
83
 
84
+ # set host, needed for some services behind proxy
83
85
  if options[:host]
84
86
  options[:headers]['Host'] = URI.parse(url).host
85
87
  end
86
88
 
87
89
  if options[:content_type].present?
90
+ content_type_headers = { "html" => 'text/html; charset=UTF-8',
91
+ "xml" => 'application/xml',
92
+ "json" => 'application/json' }
93
+ options[:headers]['Content-type'] = content_type_headers.fetch(options[:content_type], options[:content_type])
94
+ end
95
+
96
+ if options[:accept].present?
88
97
  accept_headers = { "html" => 'text/html; charset=UTF-8',
89
98
  "xml" => 'application/xml',
90
99
  "json" => 'application/json' }
91
- options[:headers]['Accept'] = accept_headers.fetch(options[:content_type], options[:content_type])
100
+ options[:headers]['Accept'] = accept_headers.fetch(options[:accept], options[:accept])
92
101
  else
93
102
  # accept all content
94
103
  options[:headers]['Accept'] ||= "text/html,application/json,application/xml;q=0.9, text/plain;q=0.8,image/png,*/*;q=0.5"
@@ -142,8 +151,6 @@ module Maremma
142
151
  end
143
152
  end
144
153
 
145
- protected
146
-
147
154
  def self.parse_response(string)
148
155
  from_json(string) || from_xml(string) || from_string(string)
149
156
  end
@@ -1,3 +1,3 @@
1
1
  module Maremma
2
- VERSION = "2.3.1"
2
+ VERSION = "2.4"
3
3
  end
data/maremma.gemspec CHANGED
@@ -34,4 +34,6 @@ Gem::Specification.new do |s|
34
34
  s.add_development_dependency 'rack-test', '~> 0'
35
35
  s.add_development_dependency 'vcr'
36
36
  s.add_development_dependency 'webmock', '~> 1.22', '>= 1.22.3'
37
+ s.add_development_dependency 'codeclimate-test-reporter', "~> 1.0.0"
38
+ s.add_development_dependency 'simplecov'
37
39
  end
data/spec/maremma_spec.rb CHANGED
@@ -17,21 +17,21 @@ describe Maremma do
17
17
 
18
18
  it "get xml" do
19
19
  stub = stub_request(:get, url).to_return(:body => data.to_xml, :status => 200, :headers => { "Content-Type" => "application/xml" })
20
- response = subject.get(url, content_type: 'xml')
20
+ response = subject.get(url, accept: 'xml')
21
21
  expect(response).to eq("data" => data)
22
22
  expect(stub).to have_been_requested
23
23
  end
24
24
 
25
25
  it "get html" do
26
26
  stub = stub_request(:get, url).to_return(:body => data.to_s, :status => 200, :headers => { "Content-Type" => "text/html" })
27
- response = subject.get(url, content_type: 'html')
27
+ response = subject.get(url, accept: 'html')
28
28
  expect(response).to eq("data" => data.to_s)
29
29
  expect(stub).to have_been_requested
30
30
  end
31
31
 
32
32
  it "post xml" do
33
33
  stub = stub_request(:post, url).with(:body => post_data.to_xml).to_return(:body => data.to_xml, :status => 200, :headers => { "Content-Type" => "text/html" })
34
- subject.post(url, content_type: 'xml', data: post_data.to_xml) { |response| expect(Hash.from_xml(response.to_s)["hash"]).to eq(data) }
34
+ subject.post(url, accept: 'xml', data: post_data.to_xml) { |response| expect(Hash.from_xml(response.to_s)["hash"]).to eq(data) }
35
35
  expect(stub).to have_been_requested
36
36
  end
37
37
 
@@ -64,21 +64,21 @@ describe Maremma do
64
64
 
65
65
  it "get xml" do
66
66
  stub = stub_request(:get, url).to_return(:body => nil, :status => 200, :headers => { "Content-Type" => "application/xml" })
67
- response = subject.get(url, content_type: 'xml')
67
+ response = subject.get(url, accept: 'xml')
68
68
  expect(response).to eq("data" => nil)
69
69
  expect(stub).to have_been_requested
70
70
  end
71
71
 
72
72
  it "get html" do
73
73
  stub = stub_request(:get, url).to_return(:body => nil, :status => 200, :headers => { "Content-Type" => "text/html" })
74
- response = subject.get(url, content_type: 'html')
74
+ response = subject.get(url, accept: 'html')
75
75
  expect(response).to eq("data" => nil)
76
76
  expect(stub).to have_been_requested
77
77
  end
78
78
 
79
79
  it "post xml" do
80
80
  stub = stub_request(:post, url).with(:body => post_data.to_xml).to_return(:body => nil, :status => 200, :headers => { "Content-Type" => "application/xml" })
81
- subject.post(url, content_type: 'xml', data: post_data.to_xml) { |response| expect(response).to eq("data" => nil) }
81
+ subject.post(url, accept: 'xml', data: post_data.to_xml) { |response| expect(response).to eq("data" => nil) }
82
82
  expect(stub).to have_been_requested
83
83
  end
84
84
  end
@@ -94,19 +94,19 @@ describe Maremma do
94
94
 
95
95
  it "get xml" do
96
96
  stub = stub_request(:get, url).to_return(:body => error.to_xml, :status => [404], :headers => { "Content-Type" => "application/xml" })
97
- expect(subject.get(url, content_type: 'xml')).to eq(error)
97
+ expect(subject.get(url, accept: 'xml')).to eq(error)
98
98
  expect(stub).to have_been_requested
99
99
  end
100
100
 
101
101
  it "get html" do
102
102
  stub = stub_request(:get, url).to_return(:body => error.to_s, :status => [404], :headers => { "Content-Type" => "text/html" })
103
- expect(subject.get(url, content_type: 'html')).to eq(error)
103
+ expect(subject.get(url, accept: 'html')).to eq(error)
104
104
  expect(stub).to have_been_requested
105
105
  end
106
106
 
107
107
  it "post xml" do
108
108
  stub = stub_request(:post, url).with(:body => post_data.to_xml).to_return(:body => error.to_xml, :status => [404], :headers => { "Content-Type" => "application/xml" })
109
- subject.post(url, content_type: 'xml', data: post_data.to_xml) { |response| expect(Hash.from_xml(response.to_s)["hash"]).to eq(error) }
109
+ subject.post(url, accept: 'xml', data: post_data.to_xml) { |response| expect(Hash.from_xml(response.to_s)["hash"]).to eq(error) }
110
110
  expect(stub).to have_been_requested
111
111
  end
112
112
  end
@@ -121,21 +121,21 @@ describe Maremma do
121
121
 
122
122
  it "get xml" do
123
123
  stub = stub_request(:get, url).to_return(:status => [408])
124
- response = subject.get(url, content_type: 'xml')
124
+ response = subject.get(url, accept: 'xml')
125
125
  expect(response).to eq("errors"=>[{"status"=>408, "title"=>"Request timeout"}])
126
126
  expect(stub).to have_been_requested
127
127
  end
128
128
 
129
129
  it "get html" do
130
130
  stub = stub_request(:get, url).to_return(:status => [408])
131
- response = subject.get(url, content_type: 'html')
131
+ response = subject.get(url, accept: 'html')
132
132
  expect(response).to eq("errors"=>[{"status"=>408, "title"=>"Request timeout"}])
133
133
  expect(stub).to have_been_requested
134
134
  end
135
135
 
136
136
  it "post xml" do
137
137
  stub = stub_request(:post, url).with(:body => post_data.to_xml).to_return(:status => [408])
138
- subject.post(url, content_type: 'xml', data: post_data.to_xml) { |response| expect(response).to be_nil }
138
+ subject.post(url, accept: 'xml', data: post_data.to_xml) { |response| expect(response).to be_nil }
139
139
  expect(stub).to have_been_requested
140
140
  end
141
141
  end
@@ -150,21 +150,21 @@ describe Maremma do
150
150
 
151
151
  it "get xml" do
152
152
  stub = stub_request(:get, url).to_raise(Faraday::ConnectionFailed.new("Connection refused - connect(2)"))
153
- response = subject.get(url, content_type: 'xml')
153
+ response = subject.get(url, accept: 'xml')
154
154
  expect(response).to eq("errors"=>[{"status"=>"403", "title"=>"Connection refused - connect(2)"}])
155
155
  expect(stub).to have_been_requested
156
156
  end
157
157
 
158
158
  it "get html" do
159
159
  stub = stub_request(:get, url).to_raise(Faraday::ConnectionFailed.new("Connection refused - connect(2)"))
160
- response = subject.get(url, content_type: 'html')
160
+ response = subject.get(url, accept: 'html')
161
161
  expect(response).to eq("errors"=>[{"status"=>"403", "title"=>"Connection refused - connect(2)"}])
162
162
  expect(stub).to have_been_requested
163
163
  end
164
164
 
165
165
  it "post xml" do
166
166
  stub = stub_request(:post, url).with(:body => post_data.to_xml).to_raise(Faraday::ConnectionFailed.new("Connection refused - connect(2)"))
167
- subject.post(url, content_type: 'xml', data: post_data.to_xml) { |response| expect(response).to be_nil }
167
+ subject.post(url, accept: 'xml', data: post_data.to_xml) { |response| expect(response).to be_nil }
168
168
  expect(stub).to have_been_requested
169
169
  end
170
170
  end
@@ -179,21 +179,21 @@ describe Maremma do
179
179
 
180
180
  it "get xml" do
181
181
  stub = stub_request(:get, url).to_timeout
182
- response = subject.get(url, content_type: 'xml')
182
+ response = subject.get(url, accept: 'xml')
183
183
  expect(response).to eq("errors"=>[{"status"=>408, "title"=>"Request timeout"}])
184
184
  expect(stub).to have_been_requested
185
185
  end
186
186
 
187
187
  it "get html" do
188
188
  stub = stub_request(:get, url).to_timeout
189
- response = subject.get(url, content_type: 'html')
189
+ response = subject.get(url, accept: 'html')
190
190
  expect(response).to eq("errors"=>[{"status"=>408, "title"=>"Request timeout"}])
191
191
  expect(stub).to have_been_requested
192
192
  end
193
193
 
194
194
  it "post xml" do
195
195
  stub = stub_request(:post, url).with(:body => post_data.to_xml).to_timeout
196
- subject.post(url, content_type: 'xml', data: post_data.to_xml) { |response| expect(response).to be_nil }
196
+ subject.post(url, accept: 'xml', data: post_data.to_xml) { |response| expect(response).to be_nil }
197
197
  expect(stub).to have_been_requested
198
198
  end
199
199
  end
@@ -208,14 +208,14 @@ describe Maremma do
208
208
 
209
209
  it "get xml" do
210
210
  stub = stub_request(:get, url).to_return(status: 200, headers: { 'X-Rate-Limit-Remaining' => 3 })
211
- response = subject.get(url, content_type: 'xml')
211
+ response = subject.get(url, accept: 'xml')
212
212
  expect(response).to eq("errors"=>[{"status"=>429, "title"=>"Too many requests"}])
213
213
  expect(stub).to have_been_requested
214
214
  end
215
215
 
216
216
  it "get html" do
217
217
  stub = stub_request(:get, url).to_return(status: 200, headers: { 'X-Rate-Limit-Remaining' => 3 })
218
- response = subject.get(url, content_type: 'html')
218
+ response = subject.get(url, accept: 'html')
219
219
  expect(response).to eq("errors"=>[{"status"=>429, "title"=>"Too many requests"}])
220
220
  expect(stub).to have_been_requested
221
221
  end
@@ -223,7 +223,7 @@ describe Maremma do
223
223
  it "post xml" do
224
224
  stub = stub_request(:post, url).with(:body => post_data.to_xml)
225
225
  .to_return(status: 200, headers: { 'X-Rate-Limit-Remaining' => 3 })
226
- subject.post(url, content_type: 'xml', data: post_data.to_xml) { |response| expect(response).to be_nil }
226
+ subject.post(url, accept: 'xml', data: post_data.to_xml) { |response| expect(response).to be_nil }
227
227
  expect(stub).to have_been_requested
228
228
  end
229
229
  end
@@ -268,7 +268,7 @@ describe Maremma do
268
268
 
269
269
  it "returns content as bibtex", vcr: true do
270
270
  url = "https://doi.org/10.5281/ZENODO.21430"
271
- response = subject.get(url, content_type: "application/x-bibtex")
271
+ response = subject.get(url, accept: "application/x-bibtex")
272
272
  expect(response.fetch("data", nil)).to eq("@data{198243d2-ed8a-4126-867e-5fff1e80dcfc,\n doi = {10.5281/ZENODO.21430},\n url = {http://dx.doi.org/10.5281/ZENODO.21430},\n author = {Martin Fenner; Karl Jonathan Ward; Gudmundur A. Thorisson; Robert Peters; },\n publisher = {Zenodo},\n title = {DataCite-ORCID: 1.0},\n year = {2015}\n}")
273
273
  end
274
274
  end
@@ -296,6 +296,11 @@ describe Maremma do
296
296
  expect(subject.parse_success_response(string)).to eq("data"=>{"word"=>"abc"})
297
297
  end
298
298
 
299
+ it 'from_json with data' do
300
+ string = '{ "data": { "word": "abc" }}'
301
+ expect(subject.parse_success_response(string)).to eq("data"=>{"word"=>"abc"})
302
+ end
303
+
299
304
  it 'from_xml' do
300
305
  string = "<word>abc</word>"
301
306
  expect(subject.parse_success_response(string)).to eq("data"=>{"word"=>"abc"})
@@ -320,25 +325,25 @@ describe Maremma do
320
325
  end
321
326
 
322
327
  it 'json' do
323
- headers = subject.set_request_headers(url, content_type: 'json')
328
+ headers = subject.set_request_headers(url, accept: 'json')
324
329
  expect(headers).to eq("Accept"=>"application/json",
325
330
  "User-Agent"=>"Maremma - https://github.com/datacite/maremma")
326
331
  end
327
332
 
328
333
  it 'xml' do
329
- headers = subject.set_request_headers(url, content_type: 'xml')
334
+ headers = subject.set_request_headers(url, accept: 'xml')
330
335
  expect(headers).to eq("Accept"=>"application/xml",
331
336
  "User-Agent"=>"Maremma - https://github.com/datacite/maremma")
332
337
  end
333
338
 
334
339
  it 'html' do
335
- headers = subject.set_request_headers(url, content_type: 'html')
340
+ headers = subject.set_request_headers(url, accept: 'html')
336
341
  expect(headers).to eq("Accept" => "text/html; charset=UTF-8",
337
342
  "User-Agent" => "Maremma - https://github.com/datacite/maremma")
338
343
  end
339
344
 
340
345
  it 'other' do
341
- headers = subject.set_request_headers(url, content_type: 'application/x-bibtex')
346
+ headers = subject.set_request_headers(url, accept: 'application/x-bibtex')
342
347
  expect(headers).to eq("Accept" => "application/x-bibtex",
343
348
  "User-Agent" => "Maremma - https://github.com/datacite/maremma")
344
349
  end
@@ -366,4 +371,16 @@ describe Maremma do
366
371
  expect(subject.set_request_headers(url, options)).to eq("User-Agent"=>"Maremma - https://github.com/datacite/maremma", "Accept"=>accept_header, "Authorization"=>"Basic #{basic}")
367
372
  end
368
373
  end
374
+
375
+ context 'host' do
376
+ it 'empty' do
377
+ options = {}
378
+ expect(subject.set_request_headers(url, options)).to eq("User-Agent"=>"Maremma - https://github.com/datacite/maremma", "Accept"=>accept_header)
379
+ end
380
+
381
+ it 'true' do
382
+ options = { host: true}
383
+ expect(subject.set_request_headers(url, options)).to eq("User-Agent"=>"Maremma - https://github.com/datacite/maremma", "Host"=>"example.org", "Accept"=>accept_header)
384
+ end
385
+ end
369
386
  end
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,9 @@
1
1
  require 'bundler/setup'
2
2
  Bundler.setup
3
3
 
4
+ require 'simplecov'
5
+ SimpleCov.start
6
+
4
7
  require 'maremma'
5
8
  require 'rspec'
6
9
  require 'rack/test'
@@ -19,5 +22,6 @@ VCR.configure do |c|
19
22
  c.cassette_library_dir = "spec/fixtures/vcr_cassettes"
20
23
  c.hook_into :webmock
21
24
  c.ignore_localhost = true
25
+ c.ignore_hosts 'codeclimate.com'
22
26
  c.configure_rspec_metadata!
23
27
  end
metadata CHANGED
@@ -1,243 +1,271 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maremma
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.1
4
+ version: '2.4'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Fenner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-02 00:00:00.000000000 Z
11
+ date: 2016-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: 0.9.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.9.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: faraday_middleware
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: 0.10.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.10.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: faraday-encoding
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: 0.0.1
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.0.1
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: excon
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: 0.45.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 0.45.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: nokogiri
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: 1.6.7
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: 1.6.7
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: builder
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ~>
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
89
  version: '3.2'
90
- - - ! '>='
90
+ - - ">="
91
91
  - !ruby/object:Gem::Version
92
92
  version: 3.2.2
93
93
  type: :runtime
94
94
  prerelease: false
95
95
  version_requirements: !ruby/object:Gem::Requirement
96
96
  requirements:
97
- - - ~>
97
+ - - "~>"
98
98
  - !ruby/object:Gem::Version
99
99
  version: '3.2'
100
- - - ! '>='
100
+ - - ">="
101
101
  - !ruby/object:Gem::Version
102
102
  version: 3.2.2
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: multi_json
105
105
  requirement: !ruby/object:Gem::Requirement
106
106
  requirements:
107
- - - ~>
107
+ - - "~>"
108
108
  - !ruby/object:Gem::Version
109
109
  version: 1.11.2
110
110
  type: :runtime
111
111
  prerelease: false
112
112
  version_requirements: !ruby/object:Gem::Requirement
113
113
  requirements:
114
- - - ~>
114
+ - - "~>"
115
115
  - !ruby/object:Gem::Version
116
116
  version: 1.11.2
117
117
  - !ruby/object:Gem::Dependency
118
118
  name: oj
119
119
  requirement: !ruby/object:Gem::Requirement
120
120
  requirements:
121
- - - ~>
121
+ - - "~>"
122
122
  - !ruby/object:Gem::Version
123
123
  version: 2.13.1
124
124
  type: :runtime
125
125
  prerelease: false
126
126
  version_requirements: !ruby/object:Gem::Requirement
127
127
  requirements:
128
- - - ~>
128
+ - - "~>"
129
129
  - !ruby/object:Gem::Version
130
130
  version: 2.13.1
131
131
  - !ruby/object:Gem::Dependency
132
132
  name: activesupport
133
133
  requirement: !ruby/object:Gem::Requirement
134
134
  requirements:
135
- - - ~>
135
+ - - "~>"
136
136
  - !ruby/object:Gem::Version
137
137
  version: '4.2'
138
- - - ! '>='
138
+ - - ">="
139
139
  - !ruby/object:Gem::Version
140
140
  version: 4.2.5
141
141
  type: :runtime
142
142
  prerelease: false
143
143
  version_requirements: !ruby/object:Gem::Requirement
144
144
  requirements:
145
- - - ~>
145
+ - - "~>"
146
146
  - !ruby/object:Gem::Version
147
147
  version: '4.2'
148
- - - ! '>='
148
+ - - ">="
149
149
  - !ruby/object:Gem::Version
150
150
  version: 4.2.5
151
151
  - !ruby/object:Gem::Dependency
152
152
  name: bundler
153
153
  requirement: !ruby/object:Gem::Requirement
154
154
  requirements:
155
- - - ~>
155
+ - - "~>"
156
156
  - !ruby/object:Gem::Version
157
157
  version: '1.0'
158
158
  type: :development
159
159
  prerelease: false
160
160
  version_requirements: !ruby/object:Gem::Requirement
161
161
  requirements:
162
- - - ~>
162
+ - - "~>"
163
163
  - !ruby/object:Gem::Version
164
164
  version: '1.0'
165
165
  - !ruby/object:Gem::Dependency
166
166
  name: rspec
167
167
  requirement: !ruby/object:Gem::Requirement
168
168
  requirements:
169
- - - ~>
169
+ - - "~>"
170
170
  - !ruby/object:Gem::Version
171
171
  version: '3.4'
172
172
  type: :development
173
173
  prerelease: false
174
174
  version_requirements: !ruby/object:Gem::Requirement
175
175
  requirements:
176
- - - ~>
176
+ - - "~>"
177
177
  - !ruby/object:Gem::Version
178
178
  version: '3.4'
179
179
  - !ruby/object:Gem::Dependency
180
180
  name: rake
181
181
  requirement: !ruby/object:Gem::Requirement
182
182
  requirements:
183
- - - ! '>='
183
+ - - ">="
184
184
  - !ruby/object:Gem::Version
185
185
  version: '0'
186
186
  type: :development
187
187
  prerelease: false
188
188
  version_requirements: !ruby/object:Gem::Requirement
189
189
  requirements:
190
- - - ! '>='
190
+ - - ">="
191
191
  - !ruby/object:Gem::Version
192
192
  version: '0'
193
193
  - !ruby/object:Gem::Dependency
194
194
  name: rack-test
195
195
  requirement: !ruby/object:Gem::Requirement
196
196
  requirements:
197
- - - ~>
197
+ - - "~>"
198
198
  - !ruby/object:Gem::Version
199
199
  version: '0'
200
200
  type: :development
201
201
  prerelease: false
202
202
  version_requirements: !ruby/object:Gem::Requirement
203
203
  requirements:
204
- - - ~>
204
+ - - "~>"
205
205
  - !ruby/object:Gem::Version
206
206
  version: '0'
207
207
  - !ruby/object:Gem::Dependency
208
208
  name: vcr
209
209
  requirement: !ruby/object:Gem::Requirement
210
210
  requirements:
211
- - - ! '>='
211
+ - - ">="
212
212
  - !ruby/object:Gem::Version
213
213
  version: '0'
214
214
  type: :development
215
215
  prerelease: false
216
216
  version_requirements: !ruby/object:Gem::Requirement
217
217
  requirements:
218
- - - ! '>='
218
+ - - ">="
219
219
  - !ruby/object:Gem::Version
220
220
  version: '0'
221
221
  - !ruby/object:Gem::Dependency
222
222
  name: webmock
223
223
  requirement: !ruby/object:Gem::Requirement
224
224
  requirements:
225
- - - ~>
225
+ - - "~>"
226
226
  - !ruby/object:Gem::Version
227
227
  version: '1.22'
228
- - - ! '>='
228
+ - - ">="
229
229
  - !ruby/object:Gem::Version
230
230
  version: 1.22.3
231
231
  type: :development
232
232
  prerelease: false
233
233
  version_requirements: !ruby/object:Gem::Requirement
234
234
  requirements:
235
- - - ~>
235
+ - - "~>"
236
236
  - !ruby/object:Gem::Version
237
237
  version: '1.22'
238
- - - ! '>='
238
+ - - ">="
239
239
  - !ruby/object:Gem::Version
240
240
  version: 1.22.3
241
+ - !ruby/object:Gem::Dependency
242
+ name: codeclimate-test-reporter
243
+ requirement: !ruby/object:Gem::Requirement
244
+ requirements:
245
+ - - "~>"
246
+ - !ruby/object:Gem::Version
247
+ version: 1.0.0
248
+ type: :development
249
+ prerelease: false
250
+ version_requirements: !ruby/object:Gem::Requirement
251
+ requirements:
252
+ - - "~>"
253
+ - !ruby/object:Gem::Version
254
+ version: 1.0.0
255
+ - !ruby/object:Gem::Dependency
256
+ name: simplecov
257
+ requirement: !ruby/object:Gem::Requirement
258
+ requirements:
259
+ - - ">="
260
+ - !ruby/object:Gem::Version
261
+ version: '0'
262
+ type: :development
263
+ prerelease: false
264
+ version_requirements: !ruby/object:Gem::Requirement
265
+ requirements:
266
+ - - ">="
267
+ - !ruby/object:Gem::Version
268
+ version: '0'
241
269
  description: Simplifies network calls, including json/xml parsing and error handling.
242
270
  Based on Faraday.
243
271
  email: mfenner@datacite.org
@@ -246,8 +274,8 @@ extensions: []
246
274
  extra_rdoc_files:
247
275
  - README.md
248
276
  files:
249
- - .gitignore
250
- - .travis.yml
277
+ - ".gitignore"
278
+ - ".travis.yml"
251
279
  - CHANGELOG.md
252
280
  - Gemfile
253
281
  - Gemfile.lock
@@ -272,12 +300,12 @@ require_paths:
272
300
  - lib
273
301
  required_ruby_version: !ruby/object:Gem::Requirement
274
302
  requirements:
275
- - - ! '>='
303
+ - - ">="
276
304
  - !ruby/object:Gem::Version
277
305
  version: '0'
278
306
  required_rubygems_version: !ruby/object:Gem::Requirement
279
307
  requirements:
280
- - - ! '>='
308
+ - - ">="
281
309
  - !ruby/object:Gem::Version
282
310
  version: '0'
283
311
  requirements: []