Sha256: 87cc9bf1e4d2c5a8db1029f21854d38da2d74afdf4baf85fbf873d1242d48a15

Contents?: true

Size: 721 Bytes

Versions: 32

Compression:

Stored size: 721 Bytes

Contents

require 'mechanize'

module Cosgrove
  class Agent < Mechanize
    COOKIE_FILE ||= 'cookies.yml'
    
    def initialize
      super('cosgrove')
      
      @agent.user_agent = 'Mozilla/5.0 (iPad; U; CPU OS 3_2_1 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Mobile/7B405'
      @agent.keep_alive = false
      @agent.open_timeout = 10
      @agent.read_timeout = 10
      
      # Cookie management, see: https://gist.github.com/makevoid/4282237
      @agent.pre_connect_hooks << Proc.new do 
        @agent.cookie_jar.load COOKIE_FILE if ::File.exist?(COOKIE_FILE)
      end
      
      @agent.post_connect_hooks << Proc.new do
        @agent.cookie_jar.save COOKIE_FILE
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
cosgrove-0.0.4.4 lib/cosgrove/agent.rb
cosgrove-0.0.4.3 lib/cosgrove/agent.rb
cosgrove-0.0.4.2 lib/cosgrove/agent.rb
cosgrove-0.0.4.1 lib/cosgrove/agent.rb
cosgrove-0.0.4.0 lib/cosgrove/agent.rb
cosgrove-0.0.4.0pre3 lib/cosgrove/agent.rb
cosgrove-0.0.4.0pre2 lib/cosgrove/agent.rb
cosgrove-0.0.4.0pre1 lib/cosgrove/agent.rb
cosgrove-0.0.3.5 lib/cosgrove/agent.rb
cosgrove-0.0.3.4 lib/cosgrove/agent.rb
cosgrove-0.0.3.3 lib/cosgrove/agent.rb
cosgrove-0.0.3.2 lib/cosgrove/agent.rb
cosgrove-0.0.3.1 lib/cosgrove/agent.rb
cosgrove-0.0.3rc1 lib/cosgrove/agent.rb
cosgrove-0.0.2 lib/cosgrove/agent.rb
cosgrove-0.0.1 lib/cosgrove/agent.rb
cosgrove-0.0.1rc16 lib/cosgrove/agent.rb
cosgrove-0.0.1rc15 lib/cosgrove/agent.rb
cosgrove-0.0.1rc14 lib/cosgrove/agent.rb
cosgrove-0.0.1rc13 lib/cosgrove/agent.rb