Sha256: 2dd698144b43c0e876a9f224162320d85c6acc8ff63b3e6d3c4c771c69213114

Contents?: true

Size: 706 Bytes

Versions: 8

Compression:

Stored size: 706 Bytes

Contents

module Voyager
  class Connection

    attr_reader :http_client

    def initialize(options = {})
      @http_client = options[:http_client] || HTTPClient.new
      @cookie_path = options[:cookie_path]

      set_cookie_path if @cookie_path
      

    end


    def request(url, options = {})
      request = @http_client.get_content(url, options)
      @http_client.cookie_manager.save_all_cookies(true) if @cookie_path
      return request
    end

    private


    def set_cookie_path
      cookie_directory = File.dirname(@cookie_path)

      FileUtils.mkdir_p(cookie_directory) unless File.exists?(cookie_directory)

      @http_client.set_cookie_store(@cookie_path)
      
      
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
voyager_api-0.2.5 lib/voyager_connection.rb
voyager_api-0.2.4 lib/voyager_connection.rb
voyager_api-0.2.3 lib/voyager_connection.rb
voyager_api-0.2.2 lib/voyager_connection.rb
voyager_api-0.2.0 lib/voyager_connection.rb
voyager_api-0.1.2 lib/voyager_connection.rb
voyager_api-0.1.1 lib/voyager_connection.rb
voyager_api-0.1.0 lib/voyager_connection.rb