repo
stringlengths
5
92
file_url
stringlengths
80
287
file_path
stringlengths
5
197
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:37:27
2026-01-04 17:58:21
truncated
bool
2 classes
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/test/test_mechanize_page_frame.rb
test/test_mechanize_page_frame.rb
# 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...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/test/test_mechanize_http_auth_challenge.rb
test/test_mechanize_http_auth_challenge.rb
# 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...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/test/test_mechanize_page_image.rb
test/test_mechanize_page_image.rb
# 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...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/test/test_mechanize_xml_file.rb
test/test_mechanize_xml_file.rb
# 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> ...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/test/test_mechanize_subclass.rb
test/test_mechanize_subclass.rb
# 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...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/test/test_mechanize_form_radio_button.rb
test/test_mechanize_form_radio_button.rb
# 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"> ...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/test/test_mechanize_image.rb
test/test_mechanize_image.rb
# frozen_string_literal: true require 'mechanize/test_case' class TestMechanizeImage < Mechanize::TestCase # empty subclass, no tests end
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/test/test_mechanize_file_response.rb
test/test_mechanize_file_response.rb
# 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...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/test/test_mechanize_redirect_not_get_or_head_error.rb
test/test_mechanize_redirect_not_get_or_head_error.rb
# 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
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/test/test_mechanize_http_content_disposition_parser.rb
test/test_mechanize_http_content_disposition_parser.rb
# 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 \ ...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/test/test_mechanize_page.rb
test/test_mechanize_page.rb
# 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...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/test/test_mechanize_http_auth_store.rb
test/test_mechanize_http_auth_store.rb
# 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' ...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/test/test_mechanize_pluggable_parser.rb
test/test_mechanize_pluggable_parser.rb
# 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 ...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/test/test_mechanize_form_textarea.rb
test/test_mechanize_form_textarea.rb
# frozen_string_literal: true require 'mechanize/test_case' class TestMechanizeFormTextarea < Mechanize::TestCase def setup super @page = @mech.get("http://localhost/tc_textarea.html") end def test_empty_text_area form = @page.forms_with(:name => 'form1').first assert_equal('', form.field_with...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/test/test_mechanize_form_option.rb
test/test_mechanize_form_option.rb
# 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...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/test/test_mechanize_form_keygen.rb
test/test_mechanize_form_keygen.rb
# 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...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/test/test_mechanize_download.rb
test/test_mechanize_download.rb
# 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...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/test/test_mechanize_file_connection.rb
test/test_mechanize_file_connection.rb
# 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| ...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/test/test_mechanize_page_meta_refresh.rb
test/test_mechanize_page_meta_refresh.rb
# 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...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/test/test_mechanize_form_image_button.rb
test/test_mechanize_form_image_button.rb
# 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...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/test/test_mechanize_http_auth_realm.rb
test/test_mechanize_http_auth_realm.rb
# 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 ...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/test/test_multi_select.rb
test/test_multi_select.rb
# 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'...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/test/test_mechanize_directory_saver.rb
test/test_mechanize_directory_saver.rb
# frozen_string_literal: true require 'mechanize/test_case' class TestMechanizeDirectorySaver < Mechanize::TestCase def setup super @uri = URI 'http://example/relative/tc_relative_links.html' @io = StringIO.new 'hello world' end def test_self_save_to in_tmpdir do saver = Mechanize::Direc...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/test/test_mechanize_http_agent.rb
test/test_mechanize_http_agent.rb
# 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...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
true
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/test/test_mechanize_form_field.rb
test/test_mechanize_form_field.rb
# 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' ...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/test/test_mechanize_history.rb
test/test_mechanize_history.rb
# 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...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/test/test_mechanize_util.rb
test/test_mechanize_util.rb
# 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...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/test/test_mechanize_headers.rb
test/test_mechanize_headers.rb
# 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 ...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/test/test_mechanize_form_encoding.rb
test/test_mechanize_form_encoding.rb
# 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...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/test/test_mechanize.rb
test/test_mechanize.rb
# coding: utf-8 # frozen_string_literal: true require 'mechanize/test_case' class TestMechanize < Mechanize::TestCase def setup super @uri = URI 'http://example/' @req = Net::HTTP::Get.new '/' @res = Net::HTTPOK.allocate @res.instance_variable_set :@code, 200 @res.instance_variable_set :@...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
true
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/test/test_mechanize_file_request.rb
test/test_mechanize_file_request.rb
# 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...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/test/test_mechanize_form_multi_select_list.rb
test/test_mechanize_form_multi_select_list.rb
# 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...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/test/test_mechanize_file.rb
test/test_mechanize_file.rb
# 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...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/test/test_mechanize_element_not_found_error.rb
test/test_mechanize_element_not_found_error.rb
# 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...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/test/test_mechanize_form.rb
test/test_mechanize_form.rb
# 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...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/test/test_mechanize_cookie.rb
test/test_mechanize_cookie.rb
# 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[...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/test/test_mechanize_http_www_authenticate_parser.rb
test/test_mechanize_http_www_authenticate_parser.rb
# 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...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/test/test_mechanize_response_read_error.rb
test/test_mechanize_response_read_error.rb
# 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...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/test/test_mechanize_redirect_limit_reached_error.rb
test/test_mechanize_redirect_limit_reached_error.rb
# 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...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/test/test_mechanize_form_select_list.rb
test/test_mechanize_form_select_list.rb
# 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>...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/test/test_mechanize_form_file_upload.rb
test/test_mechanize_form_file_upload.rb
# 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...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/examples/proxy_req.rb
examples/proxy_req.rb
require 'rubygems' require 'mechanize' agent = Mechanize.new agent.set_proxy('localhost', '8000') page = agent.get(ARGV[0]) puts page.body
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/examples/flickr_upload.rb
examples/flickr_upload.rb
require 'rubygems' require 'mechanize' agent = Mechanize.new # Get the flickr sign in page page = agent.get 'http://flickr.com/signin/flickr/' # Fill out the login form form = page.form_with :name => 'flickrloginform' form.email = ARGV[0] form.password = ARGV[1] form.submit # Go to the upload page page...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/examples/latest_user_agents.rb
examples/latest_user_agents.rb
require 'mechanize' require 'ostruct' # LatestUAFetcher fetches latest user agents from `WhatIsMyBrowser.com`. # It can use to update `Mechanize::AGENT_ALIASES`. class LatestUAFetcher attr_reader :user_agents USER_AGENT_TYPES = OpenStruct.new( linux_firefox: "Linux Firefox", mac_firefox: "Mac Firefox", ...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/examples/rubygems.rb
examples/rubygems.rb
# This example logs a user in to rubygems and prints out the body of the # page after logging the user in. require 'rubygems' require 'mechanize' require 'logger' # Create a new mechanize object mech = Mechanize.new mech.log = Logger.new $stderr mech.agent.http.debug_output = $stderr # Load the rubygems website page ...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/examples/mech-dump.rb
examples/mech-dump.rb
require 'rubygems' require 'mechanize' agent = Mechanize.new puts agent.get(ARGV[0]).inspect
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/examples/wikipedia_links_to_philosophy.rb
examples/wikipedia_links_to_philosophy.rb
require 'mechanize' require 'tsort' ## # This example implements the alt-text of http://xkcd.com/903/ which states: # # Wikipedia trivia: if you take any article, click on the first link in the # article text not in parentheses or italics, and then repeat, you will # eventually end up at "Philosophy". class Wikipedia...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/examples/spider.rb
examples/spider.rb
require 'rubygems' require 'mechanize' agent = Mechanize.new agent.max_history = nil # unlimited history stack = agent.get(ARGV[0]).links while l = stack.pop next unless l.uri host = l.uri.host next unless host.nil? or host == agent.history.first.uri.host next if agent.visited? l.href puts "crawling #{l.ur...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize.rb
lib/mechanize.rb
# frozen_string_literal: true require 'mechanize/version' require 'fileutils' require 'forwardable' require 'net/http/digest_auth' require 'net/http/persistent' require 'nokogiri' require 'openssl' require 'pp' require 'stringio' require 'uri' require 'webrick/httputils' require 'zlib' ## # The Mechanize library is us...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
true
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/redirect_not_get_or_head_error.rb
lib/mechanize/redirect_not_get_or_head_error.rb
# 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 ...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/chunked_termination_error.rb
lib/mechanize/chunked_termination_error.rb
# frozen_string_literal: true ## # Raised when Mechanize detects the chunked transfer-encoding may be # incorrectly terminated. class Mechanize::ChunkedTerminationError < Mechanize::ResponseReadError end
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/download.rb
lib/mechanize/download.rb
# frozen_string_literal: true ## # Download is a pluggable parser for downloading files without loading them # into memory first. You may subclass this class to handle content types you # do not wish to load into memory first. # # See Mechanize::PluggableParser for instructions on using this class. class Mechanize::D...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/test_case.rb
lib/mechanize/test_case.rb
# frozen_string_literal: true require 'mechanize' require 'logger' require 'tempfile' require 'tmpdir' require 'webrick' require 'zlib' require 'rubygems' begin gem 'minitest' rescue Gem::LoadError end require 'minitest/autorun' ## # A generic test case for testing mechanize. Using a subclass of # Mechanize::Tes...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/version.rb
lib/mechanize/version.rb
# frozen_string_literal: true class Mechanize VERSION = "2.14.0" end
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/cookie_jar.rb
lib/mechanize/cookie_jar.rb
# frozen_string_literal: true warn 'mechanize/cookie_jar will be deprecated. Please migrate to the http-cookie APIs.' if $VERBOSE require 'http/cookie_jar' require 'http/cookie_jar/yaml_saver' require 'mechanize/cookie' class Mechanize module CookieJarIMethods include CookieDeprecated def add(arg1, arg2 =...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/content_type_error.rb
lib/mechanize/content_type_error.rb
# frozen_string_literal: true ## # This error is raised when a pluggable parser tries to parse a content type # that it does not know how to handle. For example if Mechanize::Page were to # try to parse a PDF, a ContentTypeError would be thrown. class Mechanize::ContentTypeError < Mechanize::Error attr_reader :cont...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/prependable.rb
lib/mechanize/prependable.rb
# frozen_string_literal: true # Fake implementation of prepend(), which does not support overriding # inherited methods nor methods that are formerly overridden by # another invocation of prepend(). # # Here's what <Original>.prepend(<Wrapper>) does: # # - Create an anonymous stub module (hereinafter <Stub>) and define...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/directory_saver.rb
lib/mechanize/directory_saver.rb
# frozen_string_literal: true ## # Unlike Mechanize::FileSaver, the directory saver places all downloaded files # in a single pre-specified directory. # # You must register the directory to save to before using the directory saver: # # agent.pluggable_parser['image'] = \ # Mechanize::DirectorySaver.save_to 'image...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/file_saver.rb
lib/mechanize/file_saver.rb
# frozen_string_literal: true ## # This is a pluggable parser that automatically saves every file it # encounters. Unlike Mechanize::DirectorySaver, the file saver saves the # responses as a tree, reflecting the host and file path. # # == Example # # This example saves all .pdf files # # require 'mechanize' # # ag...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/response_read_error.rb
lib/mechanize/response_read_error.rb
# 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...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/unauthorized_error.rb
lib/mechanize/unauthorized_error.rb
# frozen_string_literal: true class Mechanize::UnauthorizedError < Mechanize::ResponseCodeError attr_reader :challenges def initialize page, challenges, message super page, message @challenges = challenges end def to_s out = super if @challenges then realms = @challenges.map(&:realm_na...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/page.rb
lib/mechanize/page.rb
# frozen_string_literal: true ## # This class encapsulates an HTML page. If Mechanize finds a content # type of 'text/html', this class will be instantiated and returned. # # Example: # # require 'mechanize' # # agent = Mechanize.new # agent.get('http://google.com/').class # => Mechanize::Page class Mechanize::...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/form.rb
lib/mechanize/form.rb
# frozen_string_literal: true require 'mechanize/element_matcher' # This class encapsulates a form parsed out of an HTML page. Each type of # input field available in a form can be accessed through this object. # # == Examples # # Find a form and print out its fields # # form = page.forms.first # => Mechanize::Form...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/file.rb
lib/mechanize/file.rb
# 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...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/robots_disallowed_error.rb
lib/mechanize/robots_disallowed_error.rb
# 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 ...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/xml_file.rb
lib/mechanize/xml_file.rb
# 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:...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/parser.rb
lib/mechanize/parser.rb
# frozen_string_literal: true ## # The parser module provides standard methods for accessing the headers and # content of a response that are shared across pluggable parsers. module Mechanize::Parser extend Forwardable special_filenames = Regexp.union %w[ AUX COM1 COM2 COM3 COM4 COM5 ...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/file_connection.rb
lib/mechanize/file_connection.rb
# 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) } ...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/element_matcher.rb
lib/mechanize/element_matcher.rb
# frozen_string_literal: true module Mechanize::ElementMatcher def elements_with singular, plural = "#{singular}s" class_eval <<-CODE def #{plural}_with criteria = {} selector = method = nil if String === criteria then criteria = {:name => criteria} else criteria...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/response_code_error.rb
lib/mechanize/response_code_error.rb
# frozen_string_literal: true # This error is raised when Mechanize encounters a response code it does not # know how to handle. Currently, this exception will be thrown if Mechanize # encounters response codes other than 200, 301, or 302. Any other response # code is up to the user to handle. class Mechanize::Respo...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/http.rb
lib/mechanize/http.rb
# frozen_string_literal: true ## # Mechanize::HTTP contains classes for communicated with HTTP servers. All # API under this namespace is considered private and is subject to change at # any time. class Mechanize::HTTP end
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/unsupported_scheme_error.rb
lib/mechanize/unsupported_scheme_error.rb
# frozen_string_literal: true class Mechanize::UnsupportedSchemeError < Mechanize::Error attr_accessor :scheme, :uri def initialize(scheme, uri) @scheme = scheme @uri = uri end end
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/pluggable_parsers.rb
lib/mechanize/pluggable_parsers.rb
# 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. ...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/redirect_limit_reached_error.rb
lib/mechanize/redirect_limit_reached_error.rb
# frozen_string_literal: true ## # Raised when too many redirects are sent class Mechanize::RedirectLimitReachedError < Mechanize::Error attr_reader :page attr_reader :redirects attr_reader :response_code def initialize page, redirects @page = page @redirects = redirects @response_co...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/file_response.rb
lib/mechanize/file_response.rb
# frozen_string_literal: true ## # Fake response for dealing with file:/// requests class Mechanize::FileResponse attr_reader :file_path def initialize(file_path) @file_path = file_path @uri = nil end def read_body raise Mechanize::ResponseCodeError.new(self) unless File.exist? @file...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/cookie.rb
lib/mechanize/cookie.rb
# frozen_string_literal: true warn 'mechanize/cookie will be deprecated. Please migrate to the http-cookie APIs.' if $VERBOSE require 'http/cookie' class Mechanize module CookieDeprecated def __deprecated__(to = nil) $VERBOSE or return method = caller_locations(1,1).first.base_label to ||= me...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/headers.rb
lib/mechanize/headers.rb
# frozen_string_literal: true class Mechanize::Headers < Hash def [](key) super(key.downcase) end def []=(key, value) super(key.downcase, value) end def key?(key) super(key.downcase) end def canonical_each block_given? or return enum_for(__method__) each { |key, value| key = k...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/element_not_found_error.rb
lib/mechanize/element_not_found_error.rb
# frozen_string_literal: true ## # Raised when an an element was not found on the Page class Mechanize::ElementNotFoundError < Mechanize::Error attr_reader :source attr_reader :element attr_reader :conditions def initialize source, element, conditions @source = source @element = element @...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/history.rb
lib/mechanize/history.rb
# frozen_string_literal: true ## # This class manages history for your mechanize object. class Mechanize::History < Array attr_accessor :max_size def initialize(max_size = nil) @max_size = max_size @history_index = {} end def initialize_copy(orig) super @history_index = orig.instance_...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/image.rb
lib/mechanize/image.rb
# frozen_string_literal: true ## # An Image holds downloaded data for an image/* response. class Mechanize::Image < Mechanize::Download end
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/file_request.rb
lib/mechanize/file_request.rb
# frozen_string_literal: true ## # A wrapper for a file URI that makes a request that works like a # Net::HTTPRequest class Mechanize::FileRequest attr_accessor :uri def initialize uri @uri = uri end def add_field *a end alias []= add_field def path @uri.path end def each_header end ...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/util.rb
lib/mechanize/util.rb
# frozen_string_literal: true require 'cgi' require 'nkf' class Mechanize::Util # default mime type data for Page::Image#mime_type. # You can use another Apache-compatible mimetab. # mimetab = WEBrick::HTTPUtils.load_mime_types('/etc/mime.types') # Mechanize::Util::DefaultMimeTypes.replace(mimetab) Defau...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/test_case/robots_txt_servlet.rb
lib/mechanize/test_case/robots_txt_servlet.rb
# 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...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/test_case/many_cookies_as_string_servlet.rb
lib/mechanize/test_case/many_cookies_as_string_servlet.rb
# 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 << ...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/test_case/send_cookies_servlet.rb
lib/mechanize/test_case/send_cookies_servlet.rb
# 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<...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/test_case/http_refresh_servlet.rb
lib/mechanize/test_case/http_refresh_servlet.rb
# 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=#{...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/test_case/content_type_servlet.rb
lib/mechanize/test_case/content_type_servlet.rb
# 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
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/test_case/many_cookies_servlet.rb
lib/mechanize/test_case/many_cookies_servlet.rb
# 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...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/test_case/header_servlet.rb
lib/mechanize/test_case/header_servlet.rb
# 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
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/test_case/referer_servlet.rb
lib/mechanize/test_case/referer_servlet.rb
# 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
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/test_case/refresh_with_empty_url.rb
lib/mechanize/test_case/refresh_with_empty_url.rb
# 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...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/test_case/modified_since_servlet.rb
lib/mechanize/test_case/modified_since_servlet.rb
# 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 ...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/test_case/response_code_servlet.rb
lib/mechanize/test_case/response_code_servlet.rb
# 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'...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/test_case/gzip_servlet.rb
lib/mechanize/test_case/gzip_servlet.rb
# 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...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/test_case/file_upload_servlet.rb
lib/mechanize/test_case/file_upload_servlet.rb
# 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, ...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/test_case/one_cookie_servlet.rb
lib/mechanize/test_case/one_cookie_servlet.rb
# 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...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/test_case/servlets.rb
lib/mechanize/test_case/servlets.rb
# 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...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/test_case/infinite_redirect_servlet.rb
lib/mechanize/test_case/infinite_redirect_servlet.rb
# 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'...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/test_case/infinite_refresh_servlet.rb
lib/mechanize/test_case/infinite_refresh_servlet.rb
# 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...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false
sparklemotion/mechanize
https://github.com/sparklemotion/mechanize/blob/4e192760df6c2311d54e527c2b07a5fa4826c5fb/lib/mechanize/test_case/ntlm_servlet.rb
lib/mechanize/test_case/ntlm_servlet.rb
# 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' \ ...
ruby
MIT
4e192760df6c2311d54e527c2b07a5fa4826c5fb
2026-01-04T15:46:19.932284Z
false