Sha256: 14b07ba7ed6361720e3120c37475df39c25b7b785ea933e7d8f5534aa422c7f0

Contents?: true

Size: 478 Bytes

Versions: 31

Compression:

Stored size: 478 Bytes

Contents

class Gillbus
  class FaradayResponseFileLogger < Faraday::Middleware

    def initialize(app, dir = '.')
      @dir = dir
      super(app)
    end

    def call(env)
      path = env.url.path
      @app.call(env).on_complete do |environment|
        sanitized_path = path.gsub(/[^A-Za-z0-9_-]+/, '_').gsub(/^_|_$/, '')
        sanitized_path = '_' if sanitized_path == ''
        File.write(@dir + '/' + sanitized_path, env.body) if env.body != ''
      end
    end

  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
gillbus-0.14.7 lib/gillbus/drivers/faraday_response_file_logger.rb
gillbus-0.14.6 lib/gillbus/drivers/faraday_response_file_logger.rb
gillbus-0.14.5 lib/gillbus/drivers/faraday_response_file_logger.rb
gillbus-0.14.4 lib/gillbus/drivers/faraday_response_file_logger.rb
gillbus-0.14.3 lib/gillbus/drivers/faraday_response_file_logger.rb
gillbus-0.14.2 lib/gillbus/drivers/faraday_response_file_logger.rb
gillbus-0.14.1 lib/gillbus/drivers/faraday_response_file_logger.rb
gillbus-0.14.0 lib/gillbus/drivers/faraday_response_file_logger.rb
gillbus-0.13.0 lib/gillbus/drivers/faraday_response_file_logger.rb
gillbus-0.12.0 lib/gillbus/drivers/faraday_response_file_logger.rb
gillbus-0.11.0 lib/gillbus/drivers/faraday_response_file_logger.rb