source
stringclasses
1 value
repo
stringlengths
5
63
repo_url
stringlengths
24
82
path
stringlengths
5
167
language
stringclasses
1 value
license
stringclasses
5 values
stars
int64
10
51.4k
ref
stringclasses
23 values
size_bytes
int64
200
258k
text
stringlengths
137
258k
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/xml_file.rb
Ruby
mit
4,441
main
1,305
# frozen_string_literal: true ## # This class encapsulates an XML file. If Mechanize finds a content-type # of 'text/xml' or 'application/xml' this class will be instantiated and # returned. This class also opens up the +search+ and +at+ methods available # on the underlying Nokogiri::XML::Document object. # # Example:...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/chunked_termination_error.rb
Ruby
mit
4,441
main
206
# frozen_string_literal: true ## # Raised when Mechanize detects the chunked transfer-encoding may be # incorrectly terminated. class Mechanize::ChunkedTerminationError < Mechanize::ResponseReadError end
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/pluggable_parsers.rb
Ruby
mit
4,441
main
4,982
# frozen_string_literal: true require 'mechanize/file' require 'mechanize/file_saver' require 'mechanize/page' require 'mechanize/xml_file' require 'mime/types' ## # Mechanize allows different parsers for different content types. Mechanize # uses PluggableParser to determine which parser to use for any content type. ...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/file_connection.rb
Ruby
mit
4,441
main
435
# frozen_string_literal: true ## # Wrapper to make a file URI work like an http URI class Mechanize::FileConnection @instance = nil def self.new *a @instance ||= super end def request uri, request file_path = uri.select(:host, :path) .select { |part| part && (part.length > 0) } ...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/file.rb
Ruby
mit
4,441
main
2,322
# frozen_string_literal: true ## # This is the base class for the Pluggable Parsers. If Mechanize cannot find # an appropriate class to use for the content type, this class will be used. # For example, if you download an image/jpeg, Mechanize will not know how to # parse it, so this class will be instantiated. # # Thi...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/response_read_error.rb
Ruby
mit
4,441
main
942
# frozen_string_literal: true ## # Raised when Mechanize encounters an error while reading the response body # from the server. Contains the response headers and the response body up to # the error along with the initial error. class Mechanize::ResponseReadError < Mechanize::Error attr_reader :body_io attr_reade...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/robots_disallowed_error.rb
Ruby
mit
4,441
main
748
# frozen_string_literal: true # Exception that is raised when an access to a resource is disallowed by # robots.txt or by HTML document itself. class Mechanize::RobotsDisallowedError < Mechanize::Error def initialize(url) if url.is_a?(URI) @url = url.to_s @uri = url else @url = url.to_s ...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/redirect_not_get_or_head_error.rb
Ruby
mit
4,441
main
576
# frozen_string_literal: true ## # Raised when a POST, PUT, or DELETE request results in a redirect # see RFC 2616 10.3.2, 10.3.3 http://www.ietf.org/rfc/rfc2616.txt class Mechanize::RedirectNotGetOrHeadError < Mechanize::Error attr_reader :page, :response_code, :verb, :uri def initialize(page, verb) @page ...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/test_case/send_cookies_servlet.rb
Ruby
mit
4,441
main
371
# frozen_string_literal: true class SendCookiesServlet < WEBrick::HTTPServlet::AbstractServlet def do_GET(req, res) res.content_type = 'text/html' cookies = req.cookies.map do |c| "<li><a href=\"#\">#{c.name}:#{c.value}</a>" end.join "\n" res.body = <<-BODY <!DOCTYPE html> <title>Your cookies<...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/test_case/one_cookie_servlet.rb
Ruby
mit
4,441
main
347
# frozen_string_literal: true class OneCookieServlet < WEBrick::HTTPServlet::AbstractServlet def do_GET(req, res) cookie = WEBrick::Cookie.new("foo", "bar") cookie.path = "/" cookie.expires = Time.now + 86400 res.cookies << cookie res['Content-Type'] = "text/html" res.body = "<html><body>hello...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/test_case/content_type_servlet.rb
Ruby
mit
4,441
main
242
# frozen_string_literal: true class ContentTypeServlet < WEBrick::HTTPServlet::AbstractServlet def do_GET(req, res) ct = req.query['ct'] || "text/html; charset=utf-8" res['Content-Type'] = ct res.body = "Hello World" end end
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/test_case/header_servlet.rb
Ruby
mit
4,441
main
278
# frozen_string_literal: true class HeaderServlet < WEBrick::HTTPServlet::AbstractServlet def do_GET(req, res) res.content_type = "text/plain" req.query.each do |x,y| res[x] = y end req.each do |k, v| res.body << "#{k}|#{v}\n" end end end
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/test_case/form_servlet.rb
Ruby
mit
4,441
main
1,008
# frozen_string_literal: true class FormServlet < WEBrick::HTTPServlet::AbstractServlet def do_GET(req, res) res.content_type = 'text/html' query = [] req.query.each_key { |k| key = WEBrick::HTTPUtils.unescape k req.query[k].each_data { |data| value = WEBrick::HTTPUtils.unescape dat...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/test_case/servlets.rb
Ruby
mit
4,441
main
2,779
# frozen_string_literal: true require 'mechanize/test_case/bad_chunking_servlet' require 'mechanize/test_case/basic_auth_servlet' require 'mechanize/test_case/content_type_servlet' require 'mechanize/test_case/digest_auth_servlet' require 'mechanize/test_case/file_upload_servlet' require 'mechanize/test_case/form_servl...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/test_case/basic_auth_servlet.rb
Ruby
mit
4,441
main
629
# frozen_string_literal: true class BasicAuthServlet < WEBrick::HTTPServlet::AbstractServlet def do_GET(req,res) htpd = nil Tempfile.open 'dot.htpasswd' do |io| htpd = WEBrick::HTTPAuth::Htpasswd.new(io.path) htpd.set_passwd('Blah', 'user', 'pass') end authenticator = WEBrick::HTTPAuth::B...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/test_case/verb_servlet.rb
Ruby
mit
4,441
main
264
# frozen_string_literal: true class VerbServlet < WEBrick::HTTPServlet::AbstractServlet %w[HEAD GET POST PUT DELETE].each do |verb| define_method "do_#{verb}" do |req, res| res.header['X-Request-Method'] = verb res.body = verb end end end
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/test_case/server.rb
Ruby
mit
4,441
main
971
# frozen_string_literal: true require 'webrick' require 'mechanize/test_case/servlets' server = WEBrick::HTTPServer.new :Port => 8000 server.mount_proc '/' do |req, res| res.content_type = 'text/html' servlets = MECHANIZE_TEST_CASE_SERVLETS.map do |path, servlet| "<dt>#{servlet}<dd><a href=\"#{path}\">#{path}...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/test_case/http_refresh_servlet.rb
Ruby
mit
4,441
main
345
# frozen_string_literal: true class HttpRefreshServlet < WEBrick::HTTPServlet::AbstractServlet def do_GET(req, res) res['Content-Type'] = req.query['ct'] || "text/html" refresh_time = req.query['refresh_time'] || 0 refresh_url = req.query['refresh_url'] || '/' res['Refresh'] = " #{refresh_time};url=#{...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/test_case/gzip_servlet.rb
Ruby
mit
4,441
main
824
# frozen_string_literal: true require 'stringio' require 'zlib' class GzipServlet < WEBrick::HTTPServlet::AbstractServlet TEST_DIR = File.expand_path '../../../../test', __FILE__ def do_GET(req, res) if req['Accept-Encoding'] !~ /gzip/ then res.code = 400 res.body = 'Content-Encoding: gzip is not...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/test_case/refresh_without_url.rb
Ruby
mit
4,441
main
353
# frozen_string_literal: true class RefreshWithoutUrl < WEBrick::HTTPServlet::AbstractServlet @@count = 0 def do_GET(req, res) address = "#{req.host}:#{req.port}" res['Content-Type'] = "text/html" @@count += 1 if @@count > 1 res['Refresh'] = "0; url=http://#{address}/"; else res['Ref...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/test_case/refresh_with_empty_url.rb
Ruby
mit
4,441
main
359
# frozen_string_literal: true class RefreshWithEmptyUrl < WEBrick::HTTPServlet::AbstractServlet @@count = 0 def do_GET(req, res) address = "#{req.host}:#{req.port}" res.content_type = "text/html" @@count += 1 if @@count > 1 res['Refresh'] = "0; url=http://#{address}/"; else res['Ref...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/test_case/digest_auth_servlet.rb
Ruby
mit
4,441
main
788
# frozen_string_literal: true require 'logger' class DigestAuthServlet < WEBrick::HTTPServlet::AbstractServlet htpd = nil Tempfile.open 'digest.htpasswd' do |io| htpd = WEBrick::HTTPAuth::Htdigest.new(io.path) htpd.set_passwd('Blah', 'user', 'pass') end @@authenticator = WEBrick::HTTPAuth::DigestAuth...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/test_case/referer_servlet.rb
Ruby
mit
4,441
main
304
# frozen_string_literal: true class RefererServlet < WEBrick::HTTPServlet::AbstractServlet def do_GET(req, res) res['Content-Type'] = "text/html" res.body = req['Referer'] || '' end def do_POST(req, res) res['Content-Type'] = "text/html" res.body = req['Referer'] || '' end end
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/test_case/robots_txt_servlet.rb
Ruby
mit
4,441
main
381
# frozen_string_literal: true class RobotsTxtServlet < WEBrick::HTTPServlet::AbstractServlet def do_GET(req, res) if /301/ === req['Host'] && req.path == '/robots.txt' res['Location'] = 'http://301/robots_txt' res.code = 301 else res['Content-Type'] = 'text/plain' res.body = <<-'EOF' U...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/test_case/ntlm_servlet.rb
Ruby
mit
4,441
main
895
# frozen_string_literal: true class NTLMServlet < WEBrick::HTTPServlet::AbstractServlet def do_GET(req, res) if req['Authorization'] =~ /^NTLM (.*)/ then authorization = $1.unpack('m*').first if authorization =~ /^NTLMSSP\000\001/ then type_2 = 'TlRMTVNTUAACAAAADAAMADAAAAABAoEAASNFZ4mr' \ ...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/test_case/many_cookies_servlet.rb
Ruby
mit
4,441
main
1,132
# frozen_string_literal: true class ManyCookiesServlet < WEBrick::HTTPServlet::AbstractServlet def do_GET(req, res) name_cookie = WEBrick::Cookie.new("name", "Aaron") name_cookie.path = "/" name_cookie.expires = Time.now + 86400 res.cookies << name_cookie res.cookies << name_cookie res.cookies...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/test_case/response_code_servlet.rb
Ruby
mit
4,441
main
400
# frozen_string_literal: true class ResponseCodeServlet < WEBrick::HTTPServlet::AbstractServlet def do_GET(req, res) res['Content-Type'] = req.query['ct'] || "text/html" if req.query['code'] code = req.query['code'].to_i case code when 300, 301, 302, 303, 304, 305, 307 res['Location'...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/test_case/bad_chunking_servlet.rb
Ruby
mit
4,441
main
283
# frozen_string_literal: true class BadChunkingServlet < WEBrick::HTTPServlet::AbstractServlet def do_GET req, res res.keep_alive = false if res.respond_to? :keep_alive= res['Transfer-Encoding'] = 'chunked' res.body = <<-BODY a\r 0123456789\r 0\r BODY end end
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/test_case/infinite_redirect_servlet.rb
Ruby
mit
4,441
main
397
# frozen_string_literal: true class InfiniteRedirectServlet < WEBrick::HTTPServlet::AbstractServlet def do_GET(req, res) res['Content-Type'] = req.query['ct'] || "text/html" res.status = req.query['code'] ? req.query['code'].to_i : '302' number = req.query['q'] ? req.query['q'].to_i : 0 res['Location'...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/test_case/quoted_value_cookie_servlet.rb
Ruby
mit
4,441
main
364
# frozen_string_literal: true class QuotedValueCookieServlet < WEBrick::HTTPServlet::AbstractServlet def do_GET(req, res) cookie = WEBrick::Cookie.new("quoted", "\"value\"") cookie.path = "/" cookie.expires = Time.now + 86400 res.cookies << cookie res['Content-Type'] = "text/html" res.body = "...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/test_case/file_upload_servlet.rb
Ruby
mit
4,441
main
433
# frozen_string_literal: true class FileUploadServlet < WEBrick::HTTPServlet::AbstractServlet def do_POST req, res res.body = req.body end def do_GET req, res res.content_type = 'text/html' res.body = <<-BODY <!DOCTYPE html> <title>Fill in this form</title> <p>You can POST anything to this endpoint, ...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/test_case/infinite_refresh_servlet.rb
Ruby
mit
4,441
main
432
# frozen_string_literal: true class InfiniteRefreshServlet < WEBrick::HTTPServlet::AbstractServlet def do_GET(req, res) address = "#{req.host}:#{req.port}" res['Content-Type'] = req.query['ct'] || "text/html" res.status = req.query['code'] ? req.query['code'].to_i : '302' number = req.query['q'] ? req...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/test_case/modified_since_servlet.rb
Ruby
mit
4,441
main
552
# frozen_string_literal: true class ModifiedSinceServlet < WEBrick::HTTPServlet::AbstractServlet def do_GET(req, res) s_time = 'Fri, 04 May 2001 00:00:38 GMT' my_time = Time.parse(s_time) if req['If-Modified-Since'] your_time = Time.parse(req['If-Modified-Since']) if my_time > your_time ...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/test_case/many_cookies_as_string_servlet.rb
Ruby
mit
4,441
main
1,221
# frozen_string_literal: true class ManyCookiesAsStringServlet < WEBrick::HTTPServlet::AbstractServlet def do_GET(req, res) cookies = [] name_cookie = WEBrick::Cookie.new("name", "Aaron") name_cookie.path = "/" name_cookie.expires = Time.now + 86400 name_cookie.domain = 'localhost' cookies << ...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/test_case/one_cookie_no_spaces_servlet.rb
Ruby
mit
4,441
main
376
# frozen_string_literal: true class OneCookieNoSpacesServlet < WEBrick::HTTPServlet::AbstractServlet def do_GET(req, res) cookie = WEBrick::Cookie.new("foo", "bar") cookie.path = "/" cookie.expires = Time.now + 86400 res.cookies << cookie.to_s.gsub(/; /, ';') res['Content-Type'] = "text/html" ...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/test_case/redirect_servlet.rb
Ruby
mit
4,441
main
404
# frozen_string_literal: true class RedirectServlet < WEBrick::HTTPServlet::AbstractServlet def do_GET(req, res) res['Content-Type'] = req.query['ct'] || 'text/html' res.status = req.query['code'] ? req.query['code'].to_i : '302' res['Location'] = req['X-Location'] || '/verb' end alias :do_POST :do_G...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/page/meta_refresh.rb
Ruby
mit
4,441
main
2,092
# frozen_string_literal: true ## # This class encapsulates a meta element with a refresh http-equiv. Mechanize # treats meta refresh elements just like 'a' tags. MetaRefresh objects will # contain links, but most likely will have no text. class Mechanize::Page::MetaRefresh < Mechanize::Page::Link ## # Time to w...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/page/link.rb
Ruby
mit
4,441
main
2,668
# frozen_string_literal: true ## # This class encapsulates links. It contains the text and the URI for # 'a' tags parsed out of an HTML page. If the link contains an image, # the alt text will be used for that image. # # For example, the text for the following links with both be 'Hello World': # # <a href="http://e...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/page/label.rb
Ruby
mit
4,441
main
350
# frozen_string_literal: true ## # A form label on an HTML page class Mechanize::Page::Label attr_reader :node attr_reader :text attr_reader :page alias :to_s :text def initialize(node, page) @node = node @text = node.inner_text @page = page end def for (id = @node['for']) && page.searc...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/page/base.rb
Ruby
mit
4,441
main
244
# frozen_string_literal: true ## # A base element on an HTML page. Mechanize treats base tags just like 'a' # tags. Base objects will contain links, but most likely will have no text. class Mechanize::Page::Base < Mechanize::Page::Link end
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/page/frame.rb
Ruby
mit
4,441
main
716
# frozen_string_literal: true # A Frame object wraps a frame HTML element. Frame objects can be treated # just like Link objects. They contain #src, the #link they refer to and a # #name, the name of the frame they refer to. #src and #name are aliased to # #href and #text respectively so that a Frame object can be t...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/page/image.rb
Ruby
mit
4,441
main
3,363
# frozen_string_literal: true ## # An image element on an HTML page class Mechanize::Page::Image attr_reader :node attr_accessor :page attr_accessor :mech ## # Creates a new Mechanize::Page::Image from an image +node+ and source # +page+. def initialize node, page @node = node @page = page ...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/http/agent.rb
Ruby
mit
4,441
main
38,806
# frozen_string_literal: true require 'tempfile' require 'net/ntlm' require 'webrobots' ## # An HTTP (and local disk access) user agent. This class is an implementation # detail and is subject to change at any time. class Mechanize::HTTP::Agent CREDENTIAL_HEADERS = ['Authorization'] COOKIE_HEADERS = ['Cookie'] ...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/http/www_authenticate_parser.rb
Ruby
mit
4,441
main
3,375
# frozen_string_literal: true require 'strscan' ## # Parses the WWW-Authenticate HTTP header into separate challenges. class Mechanize::HTTP::WWWAuthenticateParser attr_accessor :scanner # :nodoc: ## # Creates a new header parser for WWW-Authenticate headers def initialize @scanner = nil end ## ...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/http/auth_realm.rb
Ruby
mit
4,441
main
558
# frozen_string_literal: true class Mechanize::HTTP::AuthRealm attr_reader :scheme attr_reader :uri attr_reader :realm def initialize scheme, uri, realm @scheme = scheme @uri = uri @realm = realm if realm end def == other self.class === other and @scheme == other.scheme and ...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/http/auth_challenge.rb
Ruby
mit
4,441
main
1,321
# frozen_string_literal: true class Mechanize::HTTP AuthChallenge = Struct.new :scheme, :params, :raw ## # A parsed WWW-Authenticate header class AuthChallenge ## # :attr_accessor: scheme # # The authentication scheme ## # :attr_accessor: params # # The authentication parame...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/http/auth_store.rb
Ruby
mit
4,441
main
3,086
# frozen_string_literal: true ## # A credential store for HTTP authentication. # # uri = URI 'http://example' # # store = Mechanize::HTTP::AuthStore.new # store.add_auth uri, 'user1', 'pass' # store.add_auth uri, 'user2', 'pass', 'realm' # # user, pass = store.credentials_for uri, 'realm' #=> 'user2', 'pass' ...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/http/content_disposition_parser.rb
Ruby
mit
4,441
main
4,506
# frozen_string_literal: true # coding: BINARY require 'strscan' require 'time' class Mechanize::HTTP ContentDisposition = Struct.new :type, :filename, :creation_date, :modification_date, :read_date, :size, :parameters end ## # Parser Content-Disposition headers that loosely follows RFC 2183. # # Beyond RFC 21...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/form/file_upload.rb
Ruby
mit
4,441
main
662
# frozen_string_literal: true # This class represents a file upload field found in a form. To use this # class, set FileUpload#file_data= to the data of the file you want to upload # and FileUpload#mime_type= to the appropriate mime type of the file. # # See the example in EXAMPLES class Mechanize::Form::FileUpload <...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/form/image_button.rb
Ruby
mit
4,441
main
426
# frozen_string_literal: true ## # This class represents an image button in a form. Use the x and y methods to # set the x and y positions for where the mouse "clicked". class Mechanize::Form::ImageButton < Mechanize::Form::Button attr_accessor :x, :y def initialize *args @x = nil @y = nil super en...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/form/check_box.rb
Ruby
mit
4,441
main
469
# frozen_string_literal: true ## # This class represents a check box found in a Form. To activate the CheckBox # in the Form, set the checked method to true. class Mechanize::Form::CheckBox < Mechanize::Form::RadioButton def query_value [[@name, @value || "on"]] end def inspect # :nodoc: "[%s:0x%x t...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/form/select_list.rb
Ruby
mit
4,441
main
1,087
# frozen_string_literal: true # This class represents a select list or drop down box in a Form. Set the # value for the list by calling SelectList#value=. SelectList contains a list # of Option that were found. After finding the correct option, set the select # lists value to the option value: # # selectlist.value...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/form/field.rb
Ruby
mit
4,441
main
2,559
# frozen_string_literal: true ## # This class represents a field in a form. It handles the following input # tags found in a form: # # * text # * password # * hidden # * int # * textarea # * keygen # # To set the value of a field, just use the value method: # # field.value = "foo" class Mechanize::Form::Field ext...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/form/keygen.rb
Ruby
mit
4,441
main
1,014
# frozen_string_literal: true ## # This class represents a keygen (public / private key generator) found in a # Form. The field will automatically generate a key pair and compute its own # value to match the challenge. Call key to access the public/private key # pair. class Mechanize::Form::Keygen < Mechanize::Form::F...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/form/option.rb
Ruby
mit
4,441
main
1,183
# frozen_string_literal: true ## # This class contains an option found within SelectList. A SelectList can # have many Option classes associated with it. An option can be selected by # calling Option#tick, or Option#click. # # To select the first option in a list: # # select_list.first.tick class Mechanize::Form::...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/form/radio_button.rb
Ruby
mit
4,441
main
1,197
# frozen_string_literal: true ## # This class represents a radio button found in a Form. To activate the # RadioButton in the Form, set the checked method to true. class Mechanize::Form::RadioButton < Mechanize::Form::Field attr_accessor :checked attr_reader :form def initialize node, form @checked = !!nod...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
lib/mechanize/form/multi_select_list.rb
Ruby
mit
4,441
main
1,916
# frozen_string_literal: true ## # This class represents a select list where multiple values can be selected. # MultiSelectList#value= accepts an array, and those values are used as # values for the select list. For example, to select multiple values, # simply do this: # # list.value = ['one', 'two'] # # Single valu...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
test/test_mechanize_http_auth_store.rb
Ruby
mit
4,441
main
5,469
# coding: utf-8 # frozen_string_literal: true require 'mechanize/test_case' class TestMechanizeHttpAuthStore < Mechanize::TestCase def setup super @store = Mechanize::HTTP::AuthStore.new @uri = URI.parse 'http://example/' end def test_add_auth @store.add_auth @uri + '/path', 'user', 'pass' ...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
test/test_mechanize_page_link.rb
Ruby
mit
4,441
main
10,391
# coding: utf-8 # frozen_string_literal: true require 'mechanize/test_case' puts "Nokogiri::VERSION_INFO: #{Nokogiri::VERSION_INFO}" class TestMechanizePageLink < Mechanize::TestCase WINDOWS_1255 = <<-HTML <meta http-equiv="content-type" content="text/html; charset=windows-1255"> <title>hi</title> HTML BAD =...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
test/test_mechanize_form_image_button.rb
Ruby
mit
4,441
main
324
# frozen_string_literal: true require 'mechanize/test_case' class TestMechanizeFormImageButton < Mechanize::TestCase def test_query_value button = Mechanize::Form::ImageButton.new 'name' => 'image_button' assert_equal [%w[image_button.x 0], %w[image_button.y 0]], button.query_value end e...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
test/test_mechanize_file_request.rb
Ruby
mit
4,441
main
516
# frozen_string_literal: true require 'mechanize/test_case' class TestMechanizeFileRequest < Mechanize::TestCase def setup @uri = URI.parse 'file:///nonexistent' @r = Mechanize::FileRequest.new @uri end def test_initialize assert_equal @uri, @r.uri assert_equal '/nonexistent', @r.path ass...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
test/test_mechanize_xml_file.rb
Ruby
mit
4,441
main
605
# frozen_string_literal: true require 'mechanize/test_case' class TestMechanizeXmlFile < Mechanize::TestCase def setup super uri = URI 'http://example.com/foo.xml' @xml = Mechanize::XmlFile.new uri, nil, <<-XML <languages> <language>Ruby</language> <language>Perl</language> ...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
test/test_mechanize_page_encoding.rb
Ruby
mit
4,441
main
6,328
# -*- coding: utf-8 -*- # frozen_string_literal: true require 'mechanize/test_case' # tests for Page encoding and charset and parsing class TestMechanizePageEncoding < Mechanize::TestCase MECH_ASCII_ENCODING = 'US-ASCII' def setup super @uri = URI('http://localhost/') @response_headers = { 'content...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
test/test_mechanize_file_connection.rb
Ruby
mit
4,441
main
976
# frozen_string_literal: true require 'mechanize/test_case' class TestMechanizeFileConnection < Mechanize::TestCase def test_request file_path = File.expand_path(__FILE__) uri = URI.parse "file://#{file_path}" conn = Mechanize::FileConnection.new body = +'' conn.request uri, nil do |response| ...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
test/test_mechanize_http_agent.rb
Ruby
mit
4,441
main
53,690
# coding: utf-8 # frozen_string_literal: true require 'mechanize/test_case' unless RUBY_PLATFORM == 'java' require 'brotli' require 'zstd-ruby' end class TestMechanizeHttpAgent < Mechanize::TestCase def setup super @agent = @mech.agent @uri = URI.parse 'http://example/' @req = Net::HTTP::Get...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
test/test_mechanize_form_select_list.rb
Ruby
mit
4,441
main
1,600
# frozen_string_literal: true require 'mechanize/test_case' class TestMechanizeFormSelectList < Mechanize::TestCase def setup super page = html_page <<-BODY <form name="form1" method="post" action="/form_post"> <select name="select"> <option value="1">Option 1</option> <option value="2" selected>...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
test/test_mechanize_file.rb
Ruby
mit
4,441
main
2,819
# frozen_string_literal: true require 'mechanize/test_case' class TestMechanizeFile < Mechanize::TestCase def setup super @parser = Mechanize::File end def test_save uri = URI 'http://example/name.html' page = Mechanize::File.new uri, nil, '0123456789' Dir.mktmpdir do |dir| Dir.chdi...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
test/test_mechanize_file_response.rb
Ruby
mit
4,441
main
1,394
# frozen_string_literal: true require 'mechanize/test_case' class TestMechanizeFileResponse < Mechanize::TestCase def test_file_path res = Mechanize::FileResponse.new("/path/to/foo.html") assert_equal("/path/to/foo.html", res.file_path) end def test_content_type Tempfile.open %w[pi .nothtml] do |tem...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
test/test_mechanize_http_content_disposition_parser.rb
Ruby
mit
4,441
main
4,577
# frozen_string_literal: true require 'mechanize/test_case' class TestMechanizeHttpContentDispositionParser < Mechanize::TestCase def setup super @parser = Mechanize::HTTP::ContentDispositionParser.new end def test_parse now = Time.at Time.now.to_i content_disposition = @parser.parse \ ...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
test/test_mechanize_redirect_not_get_or_head_error.rb
Ruby
mit
4,441
main
278
# frozen_string_literal: true require 'mechanize/test_case' class TestMechanizeRedirectNotGetOrHead < Mechanize::TestCase def test_to_s page = fake_page error = Mechanize::RedirectNotGetOrHeadError.new(page, :put) assert_match(/ PUT /, error.to_s) end end
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
test/test_mechanize_form_file_upload.rb
Ruby
mit
4,441
main
436
# frozen_string_literal: true require 'mechanize/test_case' class TestMechanizeFormFileUpload < Mechanize::TestCase def test_file_name field = node 'input' field = Mechanize::Form::FileUpload.new field, 'a&b' assert_equal 'a&b', field.file_name end def test_file_name_entity field = node 'input...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
test/test_mechanize_form_encoding.rb
Ruby
mit
4,441
main
3,280
# coding: utf-8 # frozen_string_literal: true require 'mechanize/test_case' class TestMechanizeFormEncoding < Mechanize::TestCase # See also: tests of Util.from_native_charset # Encoding test should do with non-utf-8 characters INPUTTED_VALUE = "テスト" # "test" in Japanese UTF-8 encoding CONTENT_ENCODING = 'Sh...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
test/test_mechanize_redirect_limit_reached_error.rb
Ruby
mit
4,441
main
463
# frozen_string_literal: true require 'mechanize/test_case' class TestMechanizeRedirectLimitReachedError < Mechanize::TestCase def setup super @error = Mechanize::RedirectLimitReachedError.new fake_page, 10 end def test_message assert_equal 'Redirect limit of 10 reached', @error.message end d...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
test/test_mechanize_form_multi_select_list.rb
Ruby
mit
4,441
main
2,097
# frozen_string_literal: true require 'mechanize/test_case' class TestMechanizeFormMultiSelectList < Mechanize::TestCase def setup super page = html_page <<-BODY <form name="form1" method="post" action="/form_post"> <select name="select" multiple> <option value="1">Option 1</option> <option value...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
test/test_mechanize_subclass.rb
Ruby
mit
4,441
main
389
# frozen_string_literal: true require 'mechanize/test_case' class TestMechanizeSubclass < Mechanize::TestCase class Parent < Mechanize @html_parser = :parser @log = :log end class Child < Parent end def test_subclass_inherits_html_parser assert_equal :parser, Child.html_parser end def tes...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
test/test_mechanize_http_www_authenticate_parser.rb
Ruby
mit
4,441
main
4,716
# frozen_string_literal: true require 'mechanize/test_case' class TestMechanizeHttpWwwAuthenticateParser < Mechanize::TestCase def setup super @parser = Mechanize::HTTP::WWWAuthenticateParser.new end def test_auth_param @parser.scanner = StringScanner.new 'realm=here' param = @parser.auth_par...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
test/test_mechanize_element_not_found_error.rb
Ruby
mit
4,441
main
340
# frozen_string_literal: true require 'mechanize/test_case' class TestMechanizeRedirectLimitReachedError < Mechanize::TestCase def test_to_s page = fake_page error = Mechanize::ElementNotFoundError.new(page, :element, :conditions) assert_match(/element/, error.to_s) assert_match(/conditions/, erro...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
test/test_mechanize_cookie_jar.rb
Ruby
mit
4,441
main
18,921
# frozen_string_literal: true require 'mechanize/test_case' require 'fileutils' class TestMechanizeCookieJar < Mechanize::TestCase def setup super @jar = Mechanize::CookieJar.new @jar.extend Minitest::Assertions def @jar.add(*args) capture_io { super } end def @jar.jar(*args) ...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
test/test_mechanize_pluggable_parser.rb
Ruby
mit
4,441
main
1,451
# frozen_string_literal: true require 'mechanize/test_case' class TestMechanizePluggableParser < Mechanize::TestCase def setup super @pp = @mech.pluggable_parser end def test_aref @pp['text/html'] = Mechanize::Download assert_equal Mechanize::Download, @pp['text/html'] end def test_csv ...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
test/test_mechanize_page_image.rb
Ruby
mit
4,441
main
5,765
# frozen_string_literal: true require 'mechanize/test_case' class TestMechanizePageImage < Mechanize::TestCase def setup super @uri = URI 'http://example/' @src = (@uri + 'a.jpg').to_s @empty_page = Mechanize::Page.new(@uri, nil, '', 200, @mech) end def img attributes img = node 'img', at...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
test/test_mechanize_history.rb
Ruby
mit
4,441
main
1,716
# frozen_string_literal: true require 'mechanize/test_case' class TestMechanizeHistory < Mechanize::TestCase def setup super @uri = URI 'http://example/' @uri2 = @uri + '/a' @history = Mechanize::History.new end def test_initialize assert_empty @history end def test_clear @history...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
test/test_mechanize_cookie.rb
Ruby
mit
4,441
main
16,850
# frozen_string_literal: true require 'mechanize/test_case' module Enumerable def combine masks = inject([[], 1]){|(ar, m), e| [ar << m, m << 1 ] }[0] all = masks.inject(0){ |al, m| al|m } result = [] for i in 1..all do tmp = [] each_with_index do |e, idx| tmp << e unless (masks[...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
test/test_mechanize_form_radio_button.rb
Ruby
mit
4,441
main
2,018
# frozen_string_literal: true require 'mechanize/test_case' class TestMechanizeFormRadioButton < Mechanize::TestCase def setup super @page = html_page <<-BODY <form name="form1" method="post" action="/form_post"> <label for="blue">Blue</label> <input type="radio" name="color" value="blue" id="blue"> ...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
test/test_mechanize_util.rb
Ruby
mit
4,441
main
4,031
# coding: utf-8 # frozen_string_literal: true require 'mechanize/test_case' class TestMechanizeUtil < Mechanize::TestCase INPUTTED_VALUE = "テスト" # "test" in Japanese UTF-8 encoding CONTENT_ENCODING = 'Shift_JIS' # one of Japanese encoding ENCODED_VALUE = "\x83\x65\x83\x58\x83\x67".dup.force_encoding(::Encoding...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
test/test_mechanize_file_saver.rb
Ruby
mit
4,441
main
369
# frozen_string_literal: true require 'mechanize/test_case' class TestMechanizeFileSaver < Mechanize::TestCase def setup super @uri = URI 'http://example' @io = StringIO.new 'hello world' end def test_initialize in_tmpdir do Mechanize::FileSaver.new @uri, nil, @io, 200 assert File...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
test/test_mechanize_http_auth_challenge.rb
Ruby
mit
4,441
main
1,412
# frozen_string_literal: true require 'mechanize/test_case' class TestMechanizeHttpAuthChallenge < Mechanize::TestCase def setup super @uri = URI 'http://example/' @AR = Mechanize::HTTP::AuthRealm @AC = Mechanize::HTTP::AuthChallenge @challenge = @AC.new 'Digest', { 'realm' => 'r' }, 'Digest re...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
test/test_mechanize_response_read_error.rb
Ruby
mit
4,441
main
633
# frozen_string_literal: true require 'mechanize/test_case' class TestMechanizeResponseReadError < Mechanize::TestCase def setup super @error = 'error message' @response = Response.new @response['content-length'] = 3 @body_io = StringIO.new 'body' end def test_force_parse @response['co...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
test/test_mechanize_headers.rb
Ruby
mit
4,441
main
832
# frozen_string_literal: true require 'mechanize/test_case' class TestMechanizeHeaders < Mechanize::TestCase def setup super @headers = Mechanize::Headers.new @headers['content-type'] = 'text/html' @headers['Content-encoding'] = 'gzip' @headers['SERVER'] = 'Apache/2.2' end def test_aref ...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
test/test_mechanize_download.rb
Ruby
mit
4,441
main
2,237
# frozen_string_literal: true require 'mechanize/test_case' class TestMechanizeDownload < Mechanize::TestCase def setup super @parser = Mechanize::Download end def test_body uri = URI.parse 'http://example/foo.html' body_io = StringIO.new '0123456789' download = @parser.new uri, nil, body...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
test/test_mechanize_form.rb
Ruby
mit
4,441
main
32,558
# frozen_string_literal: true require 'mechanize/test_case' class TestMechanizeForm < Mechanize::TestCase def setup super @uri = URI 'http://example' @page = page @uri @form = Mechanize::Form.new node('form', 'name' => @NAME), @mech, @page end def test_action form = Mechanize::Form.new no...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
test/test_mechanize_page_frame.rb
Ruby
mit
4,441
main
405
# frozen_string_literal: true require 'mechanize/test_case' class TestMechanizePageFrame < Mechanize::TestCase def test_content page = page 'http://example/referer' frame = node 'frame', 'name' => 'frame1', 'src' => 'http://example/' frame = Mechanize::Page::Frame.new frame, @mech, page frame.conte...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
test/test_mechanize_parser.rb
Ruby
mit
4,441
main
6,920
# frozen_string_literal: true require 'mechanize/test_case' class TestMechanizeParser < Mechanize::TestCase class P include Mechanize::Parser attr_accessor :filename attr_accessor :response attr_accessor :uri def initialize @uri = URI 'http://example' @full_path = false end e...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
test/test_mechanize_form_keygen.rb
Ruby
mit
4,441
main
948
# frozen_string_literal: true require 'mechanize/test_case' class TestMechanizeFormKeygen < Mechanize::TestCase def setup super keygen = node('keygen', 'name' => 'userkey', 'challenge' => 'f4832e1d200df3df8c5c859edcabe52f') @keygen = Mechanize::Form::Keygen.new keyg...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
test/test_mechanize_form_option.rb
Ruby
mit
4,441
main
1,088
# frozen_string_literal: true require 'mechanize/test_case' class TestMechanizeFormOption < Mechanize::TestCase def setup super page = html_page <<-BODY <form name="form1" method="post" action="/form_post"> <select name="select"> <option value="1">Option 1</option> <option value="2" selected>Opti...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
test/test_mechanize_form_field.rb
Ruby
mit
4,441
main
1,771
# frozen_string_literal: true require 'mechanize/test_case' class TestMechanizeFormField < Mechanize::TestCase def test_inspect field = node 'input' field = Mechanize::Form::Field.new field, 'a&b' assert_match "value: a&b", field.inspect end def test_name field = node 'input', 'name' => 'a&b' ...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
test/test_mechanize_form_check_box.rb
Ruby
mit
4,441
main
1,058
# frozen_string_literal: true require 'mechanize/test_case' class TestMechanizeFormCheckBox < Mechanize::TestCase def setup super @page = @mech.get('http://localhost/tc_checkboxes.html') end def test_search form = @page.forms.first checkbox = form.checkbox_with(name: 'green') assert_equal...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
test/test_multi_select.rb
Ruby
mit
4,441
main
4,266
# frozen_string_literal: true require 'mechanize/test_case' class MultiSelectTest < Mechanize::TestCase def setup super @page = @mech.get("http://localhost/form_multi_select.html") @form = @page.forms.first end def test_option_with o = @form.field_with(:name => 'list').option_with(:value => '1'...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
test/test_mechanize_http_auth_realm.rb
Ruby
mit
4,441
main
1,105
# frozen_string_literal: true require 'mechanize/test_case' class TestMechanizeHttpAuthRealm < Mechanize::TestCase def setup super @uri = URI 'http://example/' @AR = Mechanize::HTTP::AuthRealm @realm = @AR.new 'Digest', @uri, 'r' end def test_initialize assert_equal 'r', @realm.realm ...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
test/test_mechanize_page_meta_refresh.rb
Ruby
mit
4,441
main
4,081
# frozen_string_literal: true require 'mechanize/test_case' class TestMechanizePageMetaRefresh < Mechanize::TestCase def setup super @MR = Mechanize::Page::MetaRefresh @uri = URI 'http://example/here/' end def util_page delay, uri body = <<-BODY <head><meta http-equiv="refresh" content="#{del...
github
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize
test/test_mechanize_page.rb
Ruby
mit
4,441
main
7,031
# frozen_string_literal: true require 'mechanize/test_case' class TestMechanizePage < Mechanize::TestCase def setup super @uri = URI 'http://example/' end def test_selector_methods page = html_page <<-BODY <html> <meta> <head><title></title> <body> <span class="name" id="out">Eamonn</spa...