restify 0.2.0.1.b45 → 0.2.0.1.b46

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OGM1ZDA3ZmY3YWZjYjE0Nzc5MmE5ZTVjYjNmOTFlZjMwNjJmYjIwZQ==
4
+ OGEzZDFhZWNhYTZmNDliM2M2OTljZmU3MmU2YWQ3ZGE1ZDlkOTY3OA==
5
5
  data.tar.gz: !binary |-
6
- N2ExZTBlZDY4NTc5YWQwZjY5ZGU3NzRhZTY4ZDFmODA5Njg5ZjY0Mw==
6
+ YjllMTgwNWU3YTU0ZjViYTliNGIxMmUzMjQ5MDg3NTJhODk0MWRhYg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZGYxNjM4NDM2YzFiYTdkNGMwY2E2NzZiNWNmYjczZDdlMmYzNzVkM2M3YjEw
10
- MzFkZGU3ZGNjNDE0ZjJiMmYyMzA2OTEwODcyNGU1YzFhOWM0YzNjMWM0MGY1
11
- YTJjYTc0MDM2YTgyNzMyYjAwOTU3NzljMjZkMTg1MWNjNzg4MjI=
9
+ M2RjYzMzZTlkMmYxMTEwMDRkNzk0ZDdjODBjNzk3NjRmMmRhODdlZWM3MGU1
10
+ ODliYTYyNjg2OTQ4YjlhZDc3MDVhNzZhMzk3NWUxZmEzNDg2NTI0NzExZGJh
11
+ NDM1NThjMzEyMmYwMDFmYzM4ZmM4ZTM0YTg2ODg0ZjliZDVkZDc=
12
12
  data.tar.gz: !binary |-
13
- YmQ4YmYxODc4NTNiYWRlMGQ4MTM1NTEzM2U4NmU0ZWVkOTEyM2M5ODNmZmIy
14
- MmQ3MjliZTE3NmU4ODg1Y2M4ZWVmZDQ2ZmFkZTYwNWUxZWNjZGE4ZGNhZDQw
15
- YjNjN2MzYmYwZWQ0MDIxOThmYzY2MWI3MjYxYWE3NDdjYzI1YTg=
13
+ NWEzMzY3ZTMyZDBmNTYzYjk4N2IzZTYzZDU5YTVkMWI1YWUyNGY1ZmUxZjc2
14
+ ZTljNTQzNWM0NjRmMjczZjQwMGNiMjU5MTQyOGY0YzZiZWE5ZDZjMGZlMWY1
15
+ MDNjMjhiNmI3MDkzNjI1YWFlOGQwZGFlNzYxNzE5YzliOWNiZmE=
@@ -51,12 +51,12 @@ module Restify
51
51
  request, writer, retried = pipeline? ? requests.shift : requests.first
52
52
  begin
53
53
  req = connection.send request.method.downcase,
54
- keepalive: true,
55
- redirects: 3,
56
- path: request.uri.normalized_path,
57
- query: request.uri.normalized_query,
58
- body: request.body,
59
- head: request.headers
54
+ keepalive: true,
55
+ redirects: 3,
56
+ path: request.uri.normalized_path,
57
+ query: request.uri.normalized_query,
58
+ body: request.body,
59
+ head: request.headers
60
60
  rescue Exception => err
61
61
  writer.reject err
62
62
  requests.shift unless pipeline?
@@ -21,7 +21,7 @@ module Restify
21
21
  #
22
22
  attr_reader :uri
23
23
 
24
- def initialize(uri, http, response = nil, opts = {})
24
+ def initialize(uri, http, response = nil, _opts = {})
25
25
  @uri = uri.is_a?(URI) ? uri : URI.parse(uri.to_s)
26
26
  @http = http
27
27
  @response = response
@@ -93,9 +93,9 @@ module Restify
93
93
  private
94
94
 
95
95
  def follow_location
96
- if @response
97
- @response.headers['LOCATION'] || @response.headers['CONTENT-LOCATION']
98
- end
96
+ return unless @response
97
+
98
+ @response.headers['LOCATION'] || @response.headers['CONTENT-LOCATION']
99
99
  end
100
100
 
101
101
  def load_relations
@@ -9,7 +9,7 @@ module Restify
9
9
  # @return [Hashie::Mash] Relations.
10
10
  # @see Context#relations
11
11
  #
12
- delegate :relations => :@context
12
+ delegate relations: :@context
13
13
 
14
14
  # @!method response
15
15
  #
@@ -18,7 +18,7 @@ module Restify
18
18
  # @return [Response] Response object.
19
19
  # @see Context#response
20
20
  #
21
- delegate :response => :@context
21
+ delegate response: :@context
22
22
 
23
23
  # @!method follow
24
24
  #
@@ -27,6 +27,6 @@ module Restify
27
27
  # @return [Relation] Relation to follow resource.
28
28
  # @see Context#follow
29
29
  #
30
- delegate :follow => :@context
30
+ delegate follow: :@context
31
31
  end
32
32
  end
data/lib/restify/http.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  require 'restify/adapter'
2
2
 
3
3
  module Restify
4
-
5
4
  # @api private
6
5
  #
7
6
  class HTTP
@@ -19,7 +18,7 @@ module Restify
19
18
  # resource or fail with a response error depending on
20
19
  # response from server.
21
20
  #
22
- def request(method, uri, data = nil, opts = {})
21
+ def request(method, uri, data = nil, _opts = {})
23
22
  request = Request.new method: method, uri: uri, data: data
24
23
 
25
24
  @adapter.call(request)
data/lib/restify/link.rb CHANGED
@@ -35,8 +35,8 @@ module Restify
35
35
  return parse_links(scanner)
36
36
  end
37
37
 
38
- fail ArgumentError,
39
- "Invalid token at #{scanner.pos}: '#{scanner.rest}'"
38
+ raise ArgumentError.new \
39
+ "Invalid token at #{scanner.pos}: '#{scanner.rest}'"
40
40
  end
41
41
 
42
42
  private
@@ -45,7 +45,7 @@ module Restify
45
45
 
46
46
  def extracted(params)
47
47
  @template.variables.each_with_object({}) do |var, hash|
48
- if (value = params.delete(var) { params.delete(var.to_sym) { nil }})
48
+ if (value = params.delete(var) { params.delete(var.to_sym) { nil } })
49
49
  value = value.to_param if value.respond_to?(:to_param)
50
50
  hash[var] = value
51
51
  end
@@ -20,7 +20,7 @@ module Restify
20
20
 
21
21
  def initialize(opts = {})
22
22
  @method = opts.fetch(:method, :get)
23
- @uri = opts.fetch(:uri) { fail ArgumentError, ':uri required.' }
23
+ @uri = opts.fetch(:uri) { raise ArgumentError.new ':uri required.' }
24
24
  @data = opts.fetch(:data, nil)
25
25
  end
26
26
 
@@ -15,7 +15,7 @@ module Restify
15
15
 
16
16
  name = case key.to_s.downcase
17
17
  when /\A(\w+)_url\z/
18
- $1
18
+ Regexp.last_match[1]
19
19
  when 'url'
20
20
  'self'
21
21
  else
@@ -35,7 +35,7 @@ module Restify
35
35
  when Resource
36
36
  super && relations == other.relations
37
37
  when Hash
38
- super Hash[other.map{|k,v| [convert_key(k), v] }]
38
+ super Hash[other.map {|k, v| [convert_key(k), v] }]
39
39
  else
40
40
  super
41
41
  end
@@ -109,10 +109,8 @@ module Restify
109
109
  def decoded_body
110
110
  @decoded_body ||= begin
111
111
  case headers['Content-Type']
112
- when /\Aapplication\/json($|;)/
113
- MultiJson.load body
114
- else
115
- nil
112
+ when /\Aapplication\/json($|;)/
113
+ MultiJson.load body
116
114
  end
117
115
  end
118
116
  end
@@ -123,7 +121,7 @@ module Restify
123
121
  # @return [Boolean] True if status code is 2XX otherwise false.
124
122
  #
125
123
  def success?
126
- (200...300) === code
124
+ (200...300).include? code
127
125
  end
128
126
  end
129
127
  end
data/restify.gemspec CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
14
14
  spec.license = 'LGPLv3'
15
15
 
16
16
  spec.files = Dir['**/*'].grep(%r{^((bin|lib|test|spec|features)/|.*\.gemspec|.*LICENSE.*|.*README.*|.*CHANGELOG.*)})
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.executables = spec.files.grep(%r{^bin/}) {|f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ['lib']
20
20
 
@@ -1,5 +1,4 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Restify::Collection do
4
-
5
4
  end
@@ -5,7 +5,7 @@ describe Restify::Link do
5
5
  describe '#parse' do
6
6
  it 'should parse link with quotes' do
7
7
  links = described_class
8
- .parse('<http://example.org/search{?query}>; rel="search"')
8
+ .parse('<http://example.org/search{?query}>; rel="search"')
9
9
 
10
10
  expect(links).to have(1).item
11
11
  expect(links[0].uri).to eq 'http://example.org/search{?query}'
@@ -14,7 +14,7 @@ describe Restify::Link do
14
14
 
15
15
  it 'should parse link without quotes' do
16
16
  links = described_class
17
- .parse('<http://example.org/search{?query}>; rel=search')
17
+ .parse('<http://example.org/search{?query}>; rel=search')
18
18
 
19
19
  expect(links).to have(1).item
20
20
  expect(links[0].uri).to eq 'http://example.org/search{?query}'
@@ -23,7 +23,7 @@ describe Restify::Link do
23
23
 
24
24
  it 'should parse multiple links' do
25
25
  links = described_class
26
- .parse('<p://h.tld/p>; rel=abc, <p://h.tld/b>; a=b; c="d"')
26
+ .parse('<p://h.tld/p>; rel=abc, <p://h.tld/b>; a=b; c="d"')
27
27
 
28
28
  expect(links).to have(2).item
29
29
  expect(links[0].uri).to eq 'p://h.tld/p'
@@ -10,7 +10,7 @@ describe Restify::Resource do
10
10
  let(:data) do
11
11
  {
12
12
  'users_url' => 'http://example.org/users',
13
- 'projects_url' => 'http://example.org/projects',
13
+ 'projects_url' => 'http://example.org/projects'
14
14
  }
15
15
  end
16
16
 
@@ -39,7 +39,7 @@ describe Restify::Resource do
39
39
  let(:data) do
40
40
  {
41
41
  'users_url' => 'http://example.org/users',
42
- 'projects_url' => 'http://example.org/projects',
42
+ 'projects_url' => 'http://example.org/projects'
43
43
  }
44
44
  end
45
45
 
@@ -86,8 +86,8 @@ describe Restify::Resource do
86
86
  let(:data) { {a: 0, b: 1} }
87
87
 
88
88
  it 'should yield' do
89
- expect{|cb| res.each(&cb) }.to yield_control.twice
90
- expect{|cb| res.each(&cb) }.to yield_successive_args ['a', 0], ['b', 1]
89
+ expect {|cb| res.each(&cb) }.to yield_control.twice
90
+ expect {|cb| res.each(&cb) }.to yield_successive_args ['a', 0], ['b', 1]
91
91
  end
92
92
 
93
93
  it 'should return enumerator' do
data/spec/restify_spec.rb CHANGED
@@ -41,7 +41,7 @@ describe Restify do
41
41
  stub_request(:post, 'http://localhost/base/users')
42
42
  .with(body: {})
43
43
  .to_return do
44
- <<-EOF.gsub(/^ {12}/, '')
44
+ <<-EOF.gsub(/^ {12}/, '')
45
45
  HTTP/1.1 422 Unprocessable Entity
46
46
  Content-Type: application/json
47
47
  Transfer-Encoding: chunked
@@ -53,7 +53,7 @@ describe Restify do
53
53
  stub_request(:post, 'http://localhost/base/users')
54
54
  .with(body: {name: 'John Smith'})
55
55
  .to_return do
56
- <<-EOF.gsub(/^ {12}/, '')
56
+ <<-EOF.gsub(/^ {12}/, '')
57
57
  HTTP/1.1 201 Created
58
58
  Content-Type: application/json
59
59
  Location: http://localhost/base/users/john.smith
@@ -69,7 +69,8 @@ describe Restify do
69
69
  end
70
70
 
71
71
  stub_request(:get, 'http://localhost/base/users/john.smith')
72
- .to_return do <<-EOF.gsub(/^ {10}/, '')
72
+ .to_return do
73
+ <<-EOF.gsub(/^ {10}/, '')
73
74
  HTTP/1.1 200 OK
74
75
  Content-Type: application/json
75
76
  Link: <http://localhost/base/users/john.smith>; rel="self"
@@ -83,7 +84,8 @@ describe Restify do
83
84
  end
84
85
 
85
86
  stub_request(:get, 'http://localhost/base/users/john.smith/blurb')
86
- .to_return do <<-EOF.gsub(/^ {10}/, '')
87
+ .to_return do
88
+ <<-EOF.gsub(/^ {10}/, '')
87
89
  HTTP/1.1 200 OK
88
90
  Content-Type: application/json
89
91
  Link: <http://localhost/base/users/john.smith>; rel="user"
data/spec/spec_helper.rb CHANGED
@@ -12,7 +12,7 @@ require 'restify'
12
12
 
13
13
  require 'rspec/collection_matchers'
14
14
 
15
- Dir[File.expand_path('spec/support/**/*.rb')].each { |f| require f }
15
+ Dir[File.expand_path('spec/support/**/*.rb')].each {|f| require f }
16
16
 
17
17
  RSpec.configure do |config|
18
18
  config.order = 'random'
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
16
16
  s.licenses = ["MIT"]
17
17
  s.rubygems_version = "2.4.5"
18
18
  s.summary = "Your friendly neighborhood hash library."
19
- s.test_files = ["spec/hashie/clash_spec.rb", "spec/hashie/dash_spec.rb", "spec/hashie/extensions/autoload_spec.rb", "spec/hashie/extensions/coercion_spec.rb", "spec/hashie/extensions/dash/indifferent_access_spec.rb", "spec/hashie/extensions/deep_fetch_spec.rb", "spec/hashie/extensions/deep_find_spec.rb", "spec/hashie/extensions/deep_merge_spec.rb", "spec/hashie/extensions/ignore_undeclared_spec.rb", "spec/hashie/extensions/indifferent_access_spec.rb", "spec/hashie/extensions/indifferent_access_with_rails_hwia_spec.rb", "spec/hashie/extensions/key_conversion_spec.rb", "spec/hashie/extensions/mash/safe_assignment_spec.rb", "spec/hashie/extensions/merge_initializer_spec.rb", "spec/hashie/extensions/method_access_spec.rb", "spec/hashie/extensions/stringify_keys_spec.rb", "spec/hashie/extensions/symbolize_keys_spec.rb", "spec/hashie/hash_spec.rb", "spec/hashie/mash_spec.rb", "spec/hashie/parsers/yaml_erb_parser_spec.rb", "spec/hashie/rash_spec.rb", "spec/hashie/trash_spec.rb", "spec/hashie/version_spec.rb", "spec/spec_helper.rb", "spec/support/module_context.rb"]
19
+ s.test_files = ["spec/hashie/extensions/dash/indifferent_access_spec.rb", "spec/hashie/extensions/mash/safe_assignment_spec.rb", "spec/hashie/extensions/autoload_spec.rb", "spec/hashie/extensions/coercion_spec.rb", "spec/hashie/extensions/deep_fetch_spec.rb", "spec/hashie/extensions/deep_find_spec.rb", "spec/hashie/extensions/deep_merge_spec.rb", "spec/hashie/extensions/ignore_undeclared_spec.rb", "spec/hashie/extensions/indifferent_access_spec.rb", "spec/hashie/extensions/indifferent_access_with_rails_hwia_spec.rb", "spec/hashie/extensions/key_conversion_spec.rb", "spec/hashie/extensions/merge_initializer_spec.rb", "spec/hashie/extensions/method_access_spec.rb", "spec/hashie/extensions/stringify_keys_spec.rb", "spec/hashie/extensions/symbolize_keys_spec.rb", "spec/hashie/parsers/yaml_erb_parser_spec.rb", "spec/hashie/clash_spec.rb", "spec/hashie/dash_spec.rb", "spec/hashie/hash_spec.rb", "spec/hashie/mash_spec.rb", "spec/hashie/rash_spec.rb", "spec/hashie/trash_spec.rb", "spec/hashie/version_spec.rb", "spec/support/module_context.rb", "spec/spec_helper.rb"]
20
20
 
21
21
  if s.respond_to? :specification_version then
22
22
  s.specification_version = 4
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0.1.b45
4
+ version: 0.2.0.1.b46
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Graichen