Sha256: 1f5b0e43b238a7b73e0be24764d0c29f3fa32df7eb2f4c0a696e447d76ce0ed8

Contents?: true

Size: 809 Bytes

Versions: 7

Compression:

Stored size: 809 Bytes

Contents

module Ridley
  module Middleware
    # @author Jamie Winsor <jamie@vialstudios.com>
    class ChefResponse < Faraday::Response::Middleware
      class << self
        # Determines if a response from the Chef server was successful
        #
        # @param [Hash] env
        #   a faraday request env
        #
        # @return [Boolean]
        def success?(env)
          (200..210).to_a.index(env[:status].to_i) ? true : false
        end
      end

      include Ridley::Logging

      def on_complete(env)
        log.debug { "==> handling Chef response" }
        log.debug { "request env: #{env}" }
        
        unless self.class.success?(env)
          log.debug { "** error encounted in Chef response" }
          raise Errors::HTTPError.fabricate(env)
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ridley-0.8.3 lib/ridley/middleware/chef_response.rb
ridley-0.8.2 lib/ridley/middleware/chef_response.rb
ridley-0.8.1 lib/ridley/middleware/chef_response.rb
ridley-0.8.0 lib/ridley/middleware/chef_response.rb
ridley-0.7.0 lib/ridley/middleware/chef_response.rb
ridley-0.7.0.rc4 lib/ridley/middleware/chef_response.rb
ridley-0.7.0.rc3 lib/ridley/middleware/chef_response.rb