Sha256: 16a9a9aa3e66187bb91b1ae73e2e4a727ce4f4a4ca6980197e0181501485157d
Contents?: true
Size: 1.53 KB
Versions: 1
Compression:
Stored size: 1.53 KB
Contents
require 'open-uri' # Don't allow downloaded files to be created as StringIO. Force a tempfile to be created. OpenURI::Buffer.send :remove_const, 'StringMax' if OpenURI::Buffer.const_defined?('StringMax') OpenURI::Buffer.const_set 'StringMax', 0 require 'mechanize' glob = File.expand_path("../actions/*.rb", __FILE__) Dir[glob].each do |file| require file end class Mechanize::Page def preview file = Tempfile.new(['mechanize', '.html']) file.write(self.content) file.close system("open #{file.path}") sleep 3 file.unlink end end module ZombieFans class Robot include Actions::Logger include Actions::Auth include Actions::Confirm include Actions::Avatar include Actions::Repo include Actions::User include Actions::Persist extend Actions::Persist::ClassMethods init_attributes extend Actions::Query::ClassMethods attr_reader :agent AGENT_ALIASES = [ 'Linux Firefox', 'Linux Konqueror', 'Linux Mozilla', 'Mac Firefox', 'Mac Mozilla', 'Mac Safari 4', 'Mac Safari', 'Windows Chrome', 'Windows IE 6', 'Windows IE 7', 'Windows IE 8', 'Windows IE 9', 'Windows IE 10', 'Windows IE 11', 'Windows Edge', 'Windows Mozilla', 'Windows Firefox' ] def initialize attributes = {} # assign attributes attributes.each do |key, value| instance_variable_set(:"@#{key}", value) end @agent = Mechanize.new do |agent| agent.user_agent_alias = AGENT_ALIASES.sample agent.agent.allowed_error_codes = [500] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
zombie_fans-0.2.0 | lib/zombie_fans/robot.rb |