Sha256: 5dd116925f92472c53ebd4657c516c04bd99997862240ac3af1c9281abd2b794

Contents?: true

Size: 573 Bytes

Versions: 15

Compression:

Stored size: 573 Bytes

Contents

module Gemfury
  class Client
    class Handle503 < Faraday::Middleware
      def call(env)
        # This prevents errors in ParseJson 
        @app.call(env).on_complete do |out|
          out[:body] = '' if out[:status] == 503
        end
      end
    end

    class ParseJson < Faraday::Response::Middleware
      def parse(body)
        body =~ /\A\s*\z/ ? nil : MultiJson.decode(body)
      end

      def on_complete(response)
        ok = response.request_headers['Accept'] =~ /json\z/
        response.body = parse(response.body) if ok
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
gemfury-0.12.1 lib/gemfury/client/middleware.rb
gemfury-0.12.0 lib/gemfury/client/middleware.rb
gemfury-0.12.0.rc2 lib/gemfury/client/middleware.rb
gemfury-0.12.0.rc1 lib/gemfury/client/middleware.rb
gemfury-0.11.0 lib/gemfury/client/middleware.rb
gemfury-0.11.0.rc1 lib/gemfury/client/middleware.rb
gemfury-0.10.0 lib/gemfury/client/middleware.rb
gemfury-0.10.0.rc1 lib/gemfury/client/middleware.rb
gemfury-0.9.1 lib/gemfury/client/middleware.rb
gemfury-0.9.0.rc1 lib/gemfury/client/middleware.rb
gemfury-0.8.0 lib/gemfury/client/middleware.rb
gemfury-0.8.0.rc1 lib/gemfury/client/middleware.rb
gemfury-0.7.0 lib/gemfury/client/middleware.rb
gemfury-0.6.0 lib/gemfury/client/middleware.rb
gemfury-0.6.0.rc1 lib/gemfury/client/middleware.rb