dnsimpler 0.0.2 → 0.0.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 +8 -8
- data/lib/dnsimpler/error.rb +12 -0
- data/lib/dnsimpler/http.rb +10 -6
- data/lib/dnsimpler/try.rb +1 -1
- data/lib/dnsimpler/version.rb +1 -1
- data/lib/dnsimpler.rb +1 -0
- data/test/dnsimpler/error_test.rb +22 -0
- data/test/dnsimpler/http_test.rb +13 -0
- metadata +5 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,15 +1,15 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            !binary "U0hBMQ==":
         | 
| 3 3 | 
             
              metadata.gz: !binary |-
         | 
| 4 | 
            -
                 | 
| 4 | 
            +
                Yzk3MzdmOGUxNTk4NWIxMmEzY2E5NzcyOTYyMGU0ZGNlOGZmNjQ2YQ==
         | 
| 5 5 | 
             
              data.tar.gz: !binary |-
         | 
| 6 | 
            -
                 | 
| 6 | 
            +
                Y2Q1NDFiMDUyMzBmOWRjOGNhYTJiNzI2Y2E5OGMzNTUzY2U1MmQ1Nw==
         | 
| 7 7 | 
             
            SHA512:
         | 
| 8 8 | 
             
              metadata.gz: !binary |-
         | 
| 9 | 
            -
                 | 
| 10 | 
            -
                 | 
| 11 | 
            -
                 | 
| 9 | 
            +
                Njc4OTUxNTIwMjBkNTAzYzVkZjU1ZTA0NWM0N2ZmOTYxMWYxNGI1ZTMzYTQy
         | 
| 10 | 
            +
                Y2JjM2JjOGNjMGM0ZDBmMDkzMGQzMGVkZGZlOTk5NTdiZDVmYmUzMzEyYjUw
         | 
| 11 | 
            +
                YTgxNDJkOTA1YTM5Zjc4ZmMyNmU1ZjUxY2E3OTM1NzkzNGQwM2M=
         | 
| 12 12 | 
             
              data.tar.gz: !binary |-
         | 
| 13 | 
            -
                 | 
| 14 | 
            -
                 | 
| 15 | 
            -
                 | 
| 13 | 
            +
                MGI4YjcwN2Q3NGU1MTYyNjAwZjU2YWFjNGFhNTg4ZTVmOTdkMGRmMDI3NWNk
         | 
| 14 | 
            +
                YjYzZmQxZWEwNzUyMzRlMjhlZjNjYjQyMTBjOTgxY2Y3MjY1MmIzNjZhNTdi
         | 
| 15 | 
            +
                NzQ2NzJjYTIxNzVjOTY0ODFlYzFkYzdjZTNhM2RhODU3N2VjMDc=
         | 
    
        data/lib/dnsimpler/http.rb
    CHANGED
    
    | @@ -37,15 +37,19 @@ module DNSimpler | |
| 37 37 |  | 
| 38 38 | 
             
                      req = super path, opts, &blk
         | 
| 39 39 |  | 
| 40 | 
            -
                       | 
| 40 | 
            +
                      if (200...400).include? req.code
         | 
| 41 | 
            +
                        response = OpenStruct.new(code: req.code, body: req.parsed_response)
         | 
| 41 42 |  | 
| 42 | 
            -
             | 
| 43 | 
            -
             | 
| 43 | 
            +
                        if DNSimpler.debug
         | 
| 44 | 
            +
                          response.request = req
         | 
| 44 45 |  | 
| 45 | 
            -
             | 
| 46 | 
            -
             | 
| 46 | 
            +
                          puts "Request Options: " + opts.to_s
         | 
| 47 | 
            +
                        end
         | 
| 47 48 |  | 
| 48 | 
            -
             | 
| 49 | 
            +
                        return response
         | 
| 50 | 
            +
                      else
         | 
| 51 | 
            +
                        raise Error.new(req.code, req.parsed_response, req)
         | 
| 52 | 
            +
                      end
         | 
| 49 53 | 
             
                    end
         | 
| 50 54 |  | 
| 51 55 | 
             
                  RUBY_EVAL
         | 
    
        data/lib/dnsimpler/try.rb
    CHANGED
    
    
    
        data/lib/dnsimpler/version.rb
    CHANGED
    
    
    
        data/lib/dnsimpler.rb
    CHANGED
    
    
| @@ -0,0 +1,22 @@ | |
| 1 | 
            +
            require 'test_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            class DNSimpler::ErrorTest < MiniTest::Test
         | 
| 4 | 
            +
             | 
| 5 | 
            +
              test "initialize" do
         | 
| 6 | 
            +
                assert_raises DNSimpler::Error do
         | 
| 7 | 
            +
                  raise DNSimpler::Error.new(200, {body: 'blah'}, nil)
         | 
| 8 | 
            +
                end
         | 
| 9 | 
            +
              end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
              %w[code body response].each do |attr|
         | 
| 12 | 
            +
                class_eval <<-RUBY_EVAL, __FILE__, __LINE__
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                  test "##{attr}" do
         | 
| 15 | 
            +
                    error = DNSimpler::Error.new(200, {body: 'blah'}, true)
         | 
| 16 | 
            +
                    refute_nil error.#{attr}
         | 
| 17 | 
            +
                  end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                RUBY_EVAL
         | 
| 20 | 
            +
              end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
            end
         | 
    
        data/test/dnsimpler/http_test.rb
    CHANGED
    
    | @@ -3,10 +3,23 @@ require 'test_helper' | |
| 3 3 | 
             
            module DNSimpler
         | 
| 4 4 | 
             
              class HTTPTest < MiniTest::Test
         | 
| 5 5 |  | 
| 6 | 
            +
                def setup
         | 
| 7 | 
            +
                  super
         | 
| 8 | 
            +
                  stub_request(:get, "#{DNSimpler.base_uri}v1/domains/example.com").to_return(status: 404, body: {"message"=>"Domain `example.com' not found"}.to_json)
         | 
| 9 | 
            +
                end
         | 
| 10 | 
            +
             | 
| 6 11 | 
             
                test "#base_options" do
         | 
| 7 12 | 
             
                  assert_instance_of Hash, HTTP.base_options
         | 
| 8 13 | 
             
                end
         | 
| 9 14 |  | 
| 15 | 
            +
                test "an error is raised for a failed request" do
         | 
| 16 | 
            +
                  error = assert_raises ::DNSimpler::Error do
         | 
| 17 | 
            +
                    HTTP.get("v1/domains/example.com")
         | 
| 18 | 
            +
                  end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                  refute (200...400).include? error.code
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
             | 
| 10 23 | 
             
                %w[get post head delete patch put].each do |method|
         | 
| 11 24 | 
             
                  class_eval <<-RUBY_EVAL
         | 
| 12 25 |  | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: dnsimpler
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.0. | 
| 4 | 
            +
              version: 0.0.3
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Daniel Westendorf
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2015-01- | 
| 11 | 
            +
            date: 2015-01-08 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: httparty
         | 
| @@ -83,9 +83,11 @@ files: | |
| 83 83 | 
             
            - Rakefile
         | 
| 84 84 | 
             
            - dnsimpler.gemspec
         | 
| 85 85 | 
             
            - lib/dnsimpler.rb
         | 
| 86 | 
            +
            - lib/dnsimpler/error.rb
         | 
| 86 87 | 
             
            - lib/dnsimpler/http.rb
         | 
| 87 88 | 
             
            - lib/dnsimpler/try.rb
         | 
| 88 89 | 
             
            - lib/dnsimpler/version.rb
         | 
| 90 | 
            +
            - test/dnsimpler/error_test.rb
         | 
| 89 91 | 
             
            - test/dnsimpler/http_test.rb
         | 
| 90 92 | 
             
            - test/dnsimpler/try_test.rb
         | 
| 91 93 | 
             
            - test/dnsimpler_test.rb
         | 
| @@ -116,6 +118,7 @@ specification_version: 4 | |
| 116 118 | 
             
            summary: A simple DNSimple API wrapper that always provides the response you're looking
         | 
| 117 119 | 
             
              for.
         | 
| 118 120 | 
             
            test_files:
         | 
| 121 | 
            +
            - test/dnsimpler/error_test.rb
         | 
| 119 122 | 
             
            - test/dnsimpler/http_test.rb
         | 
| 120 123 | 
             
            - test/dnsimpler/try_test.rb
         | 
| 121 124 | 
             
            - test/dnsimpler_test.rb
         |