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.16.7 lib/gillbus/drivers/faraday_response_file_logger.rb
gillbus-0.16.6 lib/gillbus/drivers/faraday_response_file_logger.rb
gillbus-0.16.5 lib/gillbus/drivers/faraday_response_file_logger.rb
gillbus-0.16.4 lib/gillbus/drivers/faraday_response_file_logger.rb
gillbus-0.16.3 lib/gillbus/drivers/faraday_response_file_logger.rb
gillbus-0.16.2 lib/gillbus/drivers/faraday_response_file_logger.rb
gillbus-0.16.1 lib/gillbus/drivers/faraday_response_file_logger.rb
gillbus-0.15.7 lib/gillbus/drivers/faraday_response_file_logger.rb
gillbus-0.15.6 lib/gillbus/drivers/faraday_response_file_logger.rb
gillbus-0.15.5 lib/gillbus/drivers/faraday_response_file_logger.rb
gillbus-0.15.4 lib/gillbus/drivers/faraday_response_file_logger.rb
gillbus-0.15.3 lib/gillbus/drivers/faraday_response_file_logger.rb
gillbus-0.15.2 lib/gillbus/drivers/faraday_response_file_logger.rb
gillbus-0.15.1 lib/gillbus/drivers/faraday_response_file_logger.rb
gillbus-0.15.0 lib/gillbus/drivers/faraday_response_file_logger.rb
gillbus-0.14.12 lib/gillbus/drivers/faraday_response_file_logger.rb
gillbus-0.14.11 lib/gillbus/drivers/faraday_response_file_logger.rb
gillbus-0.14.10 lib/gillbus/drivers/faraday_response_file_logger.rb
gillbus-0.14.9 lib/gillbus/drivers/faraday_response_file_logger.rb
gillbus-0.14.8 lib/gillbus/drivers/faraday_response_file_logger.rb