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 +4 -4
- data/.travis.yml +5 -0
- data/Gemfile +2 -1
- data/Rakefile +3 -1
- data/lib/nestful/connection.rb +1 -1
- data/lib/nestful/formats/json_format.rb +2 -2
- data/lib/nestful/helpers.rb +0 -8
- data/lib/nestful/request.rb +7 -3
- data/lib/nestful/resource.rb +2 -2
- data/lib/nestful/version.rb +1 -1
- data/test/nestful/test_endpoint.rb +5 -9
- data/test/nestful/test_request.rb +3 -7
- data/test/nestful/test_resource.rb +3 -7
- data/test/nestful/test_response.rb +2 -6
- data/test/test_helper.rb +10 -0
- metadata +5 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: eb9257a0d53809d47c726404fe0727c055358ecc
         | 
| 4 | 
            +
              data.tar.gz: a247a02e2d1ee21992a5da0940f6d46d140ebaa5
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: a816e887e670eecea85e9b5fca9200d6bd52f11a7a3cdc42377b3446201d2de83770853fee0593a182a608ff1581e18813069150ced8d680f692649c6800792a
         | 
| 7 | 
            +
              data.tar.gz: bc85420dd3fcccc1492ba8e86093b87736925ef72685fb7dea96487aac3fc314ea59c9ee2a95746c1321010b3821dfdec3f35dae5de4d83adb33489aebbbbc02
         | 
    
        data/.travis.yml
    ADDED
    
    
    
        data/Gemfile
    CHANGED
    
    
    
        data/Rakefile
    CHANGED
    
    
    
        data/lib/nestful/connection.rb
    CHANGED
    
    | @@ -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, : | 
| 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.
         | 
    
        data/lib/nestful/helpers.rb
    CHANGED
    
    | @@ -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 |  | 
    
        data/lib/nestful/request.rb
    CHANGED
    
    | @@ -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 =  | 
| 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 =  | 
| 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
         | 
    
        data/lib/nestful/resource.rb
    CHANGED
    
    | @@ -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
         | 
    
        data/lib/nestful/version.rb
    CHANGED
    
    
| @@ -1,10 +1,6 @@ | |
| 1 | 
            -
            require ' | 
| 2 | 
            -
            require 'webmock/minitest'
         | 
| 3 | 
            -
            require 'nestful'
         | 
| 1 | 
            +
            require 'test_helper'
         | 
| 4 2 |  | 
| 5 | 
            -
             | 
| 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 | 
            -
                 | 
| 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 | 
            -
                 | 
| 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 ' | 
| 2 | 
            -
            require 'webmock/minitest'
         | 
| 3 | 
            -
            require 'nestful'
         | 
| 1 | 
            +
            require 'test_helper'
         | 
| 4 2 |  | 
| 5 | 
            -
             | 
| 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 ' | 
| 2 | 
            -
            require 'webmock/minitest'
         | 
| 3 | 
            -
            require 'nestful'
         | 
| 1 | 
            +
            require 'test_helper'
         | 
| 4 2 |  | 
| 5 | 
            -
             | 
| 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 ' | 
| 2 | 
            -
            require 'webmock/minitest'
         | 
| 3 | 
            -
            require 'nestful'
         | 
| 1 | 
            +
            require 'test_helper'
         | 
| 4 2 |  | 
| 5 | 
            -
             | 
| 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')
         | 
    
        data/test/test_helper.rb
    ADDED
    
    
    
        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. | 
| 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- | 
| 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
         |