nestful 1.1.2 → 1.1.3

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: ed5261af3eae8645b3f911b9bd25e4609d775ae2
4
- data.tar.gz: 9e720f009d510b03cb894fd7bd5e40c066b5e733
3
+ metadata.gz: eb9257a0d53809d47c726404fe0727c055358ecc
4
+ data.tar.gz: a247a02e2d1ee21992a5da0940f6d46d140ebaa5
5
5
  SHA512:
6
- metadata.gz: afdbc5f917195797ef29fd577611563cfe83a497de1b60ba2567d8e823811c34e1c5e2bd24b797f048095c0cdbdc44814091ff3807718a0e9f3a5367cac0d0eb
7
- data.tar.gz: 8f16da8c697b2180ac672aa52b10638ec441b61cef501c296fc582c0a53734c30279f27e01a4fc570db4c757392760909739e0136c61ff840603086805c17fec
6
+ metadata.gz: a816e887e670eecea85e9b5fca9200d6bd52f11a7a3cdc42377b3446201d2de83770853fee0593a182a608ff1581e18813069150ced8d680f692649c6800792a
7
+ data.tar.gz: bc85420dd3fcccc1492ba8e86093b87736925ef72685fb7dea96487aac3fc314ea59c9ee2a95746c1321010b3821dfdec3f35dae5de4d83adb33489aebbbbc02
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.8
4
+ - 2.3.5
5
+ - 2.4.2
data/Gemfile CHANGED
@@ -7,4 +7,5 @@ group :test do
7
7
  gem 'webmock'
8
8
  gem 'rake'
9
9
  gem 'net-http-spy'
10
- end
10
+ gem 'minitest'
11
+ end
data/Rakefile CHANGED
@@ -5,4 +5,6 @@ Rake::TestTask.new do |t|
5
5
  t.libs << 'test'
6
6
  t.test_files = FileList['test/**/test*.rb']
7
7
  t.verbose = true
8
- end
8
+ end
9
+
10
+ task default: :test
@@ -6,7 +6,7 @@ module Nestful
6
6
  UriParser = URI.const_defined?(:Parser) ? URI::Parser.new : URI
7
7
 
8
8
  attr_accessor :timeout, :ssl_options
9
- attr_reader :endpoint, :timeout, :proxy, :ssl_options
9
+ attr_reader :endpoint, :proxy
10
10
 
11
11
  # The +endpoint+ parameter is required and will set the +endpoint+
12
12
  # attribute to the URI for the remote resource service.
@@ -1,6 +1,6 @@
1
1
  begin
2
2
  require 'json'
3
- rescue LoadError => e
3
+ rescue LoadError
4
4
  require 'json/pure'
5
5
  end
6
6
 
@@ -22,4 +22,4 @@ module Nestful
22
22
 
23
23
  JsonFormat = JSONFormat
24
24
  end
25
- end
25
+ end
@@ -54,14 +54,6 @@ module Nestful
54
54
  end
55
55
  end
56
56
 
57
- def from_param(param)
58
- Rack::Utils.parse_nested_query(param)
59
- (value || '').split('&').each do |res|
60
- key, value = res.split('=')
61
- @params[key] = value
62
- end
63
- end
64
-
65
57
  def from_param(qs, d = nil)
66
58
  params = {}
67
59
 
@@ -1,5 +1,7 @@
1
1
  module Nestful
2
2
  class Request
3
+ UriParser = URI.const_defined?(:Parser) ? URI::Parser.new : URI
4
+
3
5
  attr_reader :options, :format, :url
4
6
 
5
7
  attr_accessor :params, :body, :method, :headers,
@@ -37,11 +39,11 @@ module Nestful
37
39
  end
38
40
 
39
41
  def uri
40
- return @uri if @uri
42
+ return @uri if defined?(@uri) && @uri
41
43
 
42
44
  url = @url.match(/\Ahttps?:\/\//) ? @url : "http://#{@url}"
43
45
 
44
- @uri = URI.parse(url)
46
+ @uri = UriParser.parse(url)
45
47
  @uri.path = '/' if @uri.path.empty?
46
48
 
47
49
  @uri
@@ -103,13 +105,15 @@ module Nestful
103
105
  raise RedirectionLoop.new(self, error.response) if attempts > max_attempts
104
106
 
105
107
  location = error.response['Location'].scrub
106
- location = URI.parse(location)
108
+ location = UriParser.parse(location)
107
109
 
108
110
  # Path is relative
109
111
  unless location.host
110
112
  location = URI.join(uri, location)
111
113
  end
112
114
 
115
+ location.scheme = uri.scheme unless location.scheme
116
+
113
117
  self.url = location.to_s
114
118
  retry
115
119
  end
@@ -16,7 +16,7 @@ module Nestful
16
16
 
17
17
  def self.defaults(value = nil)
18
18
  @defaults = value if value
19
- return @defaults if @defaults
19
+ return @defaults if defined?(@defaults) && @defaults
20
20
  superclass.respond_to?(:defaults) ? superclass.defaults : {}
21
21
  end
22
22
 
@@ -183,4 +183,4 @@ module Nestful
183
183
  end
184
184
  end
185
185
  end
186
- end
186
+ end
@@ -1,3 +1,3 @@
1
1
  module Nestful
2
- VERSION = '1.1.2'
2
+ VERSION = '1.1.3'.freeze
3
3
  end
@@ -1,10 +1,6 @@
1
- require 'minitest/autorun'
2
- require 'webmock/minitest'
3
- require 'nestful'
1
+ require 'test_helper'
4
2
 
5
- WebMock.disable_net_connect!
6
-
7
- class TestEndpoint < MiniTest::Unit::TestCase
3
+ class TestEndpoint < Minitest::Test
8
4
  def test_join
9
5
  endpoint = Nestful::Endpoint['http://example.com']['charges'][1]
10
6
  assert_equal 'http://example.com/charges/1', endpoint.url
@@ -12,13 +8,13 @@ class TestEndpoint < MiniTest::Unit::TestCase
12
8
 
13
9
  def test_get
14
10
  stub_request(:any, 'http://example.com/charges?limit=10')
15
- endpoint = Nestful::Endpoint['http://example.com']['charges'].get(:limit => 10)
11
+ Nestful::Endpoint['http://example.com']['charges'].get(:limit => 10)
16
12
  assert_requested(:get, 'http://example.com/charges?limit=10')
17
13
  end
18
14
 
19
15
  def test_post
20
16
  stub_request(:any, 'http://example.com/charges')
21
- endpoint = Nestful::Endpoint['http://example.com']['charges'].post
17
+ Nestful::Endpoint['http://example.com']['charges'].post
22
18
  assert_requested(:post, 'http://example.com/charges')
23
19
  end
24
- end
20
+ end
@@ -1,10 +1,6 @@
1
- require 'minitest/autorun'
2
- require 'webmock/minitest'
3
- require 'nestful'
1
+ require 'test_helper'
4
2
 
5
- WebMock.disable_net_connect!
6
-
7
- class TestRequest < MiniTest::Unit::TestCase
3
+ class TestRequest < Minitest::Test
8
4
  def test_get
9
5
  stub_request(:any, 'http://example.com/v1/tokens')
10
6
  Nestful::Request.new('http://example.com/v1/tokens', :method => :get).execute
@@ -80,4 +76,4 @@ class TestRequest < MiniTest::Unit::TestCase
80
76
  Nestful::Request.new('http://example.com/v1/tokens', :auth_type => :bearer, :password => 'password1').execute
81
77
  assert_requested(:get, 'http://example.com/v1/tokens', :headers => {'Authorization' => 'Bearer password1'})
82
78
  end
83
- end
79
+ end
@@ -1,10 +1,6 @@
1
- require 'minitest/autorun'
2
- require 'webmock/minitest'
3
- require 'nestful'
1
+ require 'test_helper'
4
2
 
5
- WebMock.disable_net_connect!
6
-
7
- class TestResource < MiniTest::Unit::TestCase
3
+ class TestResource < Minitest::Test
8
4
  class Charge < Nestful::Resource
9
5
  endpoint 'http://example.com'
10
6
  path '/v1/charges'
@@ -65,4 +61,4 @@ class TestResource < MiniTest::Unit::TestCase
65
61
  charge = Charge.new(:amount => 1)
66
62
  assert_equal charge.to_json, '{"amount":1}'
67
63
  end
68
- end
64
+ end
@@ -1,10 +1,6 @@
1
- require 'minitest/autorun'
2
- require 'webmock/minitest'
3
- require 'nestful'
1
+ require 'test_helper'
4
2
 
5
- WebMock.disable_net_connect!
6
-
7
- class TestResponse < MiniTest::Unit::TestCase
3
+ class TestResponse < Minitest::Test
8
4
  def test_headers
9
5
  stub_request(:any, 'http://example.com/v1/charges').to_return(:headers => {'X-TEST' => 'BAR'})
10
6
  response = Nestful.get('http://example.com/v1/charges')
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+
4
+ require 'minitest/autorun'
5
+ require 'minitest/unit'
6
+ require 'webmock/minitest'
7
+
8
+ require 'nestful'
9
+
10
+ WebMock.disable_net_connect!
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nestful
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex MacCaw
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-27 00:00:00.000000000 Z
11
+ date: 2017-11-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -18,6 +18,7 @@ extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
20
  - ".gitignore"
21
+ - ".travis.yml"
21
22
  - Gemfile
22
23
  - MIT-LICENSE
23
24
  - README.markdown
@@ -44,6 +45,7 @@ files:
44
45
  - test/nestful/test_request.rb
45
46
  - test/nestful/test_resource.rb
46
47
  - test/nestful/test_response.rb
48
+ - test/test_helper.rb
47
49
  homepage: https://github.com/maccman/nestful
48
50
  licenses: []
49
51
  metadata: {}
@@ -72,3 +74,4 @@ test_files:
72
74
  - test/nestful/test_request.rb
73
75
  - test/nestful/test_resource.rb
74
76
  - test/nestful/test_response.rb
77
+ - test/test_helper.rb