tenderlove-mechanize 0.9.3.20090623142847 → 0.9.3.20090911221705

Sign up to get free protection for your applications and to get access to all the features.
Files changed (165) hide show
  1. data/Manifest.txt +55 -48
  2. data/Rakefile +12 -22
  3. data/lib/mechanize.rb +618 -4
  4. data/lib/mechanize/chain.rb +33 -0
  5. data/lib/mechanize/chain/auth_headers.rb +78 -0
  6. data/lib/mechanize/chain/body_decoding_handler.rb +46 -0
  7. data/lib/mechanize/chain/connection_resolver.rb +76 -0
  8. data/lib/mechanize/chain/custom_headers.rb +21 -0
  9. data/lib/{www/mechanize → mechanize}/chain/handler.rb +1 -1
  10. data/lib/mechanize/chain/header_resolver.rb +51 -0
  11. data/lib/mechanize/chain/parameter_resolver.rb +22 -0
  12. data/lib/{www/mechanize → mechanize}/chain/post_connect_hook.rb +0 -0
  13. data/lib/mechanize/chain/pre_connect_hook.rb +20 -0
  14. data/lib/mechanize/chain/request_resolver.rb +30 -0
  15. data/lib/mechanize/chain/response_body_parser.rb +38 -0
  16. data/lib/mechanize/chain/response_header_handler.rb +48 -0
  17. data/lib/mechanize/chain/response_reader.rb +39 -0
  18. data/lib/mechanize/chain/ssl_resolver.rb +40 -0
  19. data/lib/mechanize/chain/uri_resolver.rb +75 -0
  20. data/lib/mechanize/content_type_error.rb +14 -0
  21. data/lib/mechanize/cookie.rb +70 -0
  22. data/lib/mechanize/cookie_jar.rb +188 -0
  23. data/lib/mechanize/file.rb +71 -0
  24. data/lib/mechanize/file_response.rb +60 -0
  25. data/lib/mechanize/file_saver.rb +37 -0
  26. data/lib/mechanize/form.rb +378 -0
  27. data/lib/mechanize/form/button.rb +9 -0
  28. data/lib/mechanize/form/check_box.rb +11 -0
  29. data/lib/mechanize/form/field.rb +30 -0
  30. data/lib/mechanize/form/file_upload.rb +22 -0
  31. data/lib/mechanize/form/image_button.rb +21 -0
  32. data/lib/mechanize/form/multi_select_list.rb +67 -0
  33. data/lib/mechanize/form/option.rb +49 -0
  34. data/lib/mechanize/form/radio_button.rb +49 -0
  35. data/lib/mechanize/form/select_list.rb +43 -0
  36. data/lib/mechanize/headers.rb +11 -0
  37. data/lib/mechanize/history.rb +65 -0
  38. data/lib/mechanize/inspect.rb +88 -0
  39. data/lib/{www/mechanize → mechanize}/monkey_patch.rb +4 -6
  40. data/lib/mechanize/page.rb +206 -0
  41. data/lib/mechanize/page/base.rb +8 -0
  42. data/lib/mechanize/page/frame.rb +20 -0
  43. data/lib/mechanize/page/image.rb +26 -0
  44. data/lib/mechanize/page/label.rb +20 -0
  45. data/lib/mechanize/page/link.rb +48 -0
  46. data/lib/mechanize/page/meta.rb +50 -0
  47. data/lib/mechanize/pluggable_parsers.rb +101 -0
  48. data/lib/mechanize/redirect_limit_reached_error.rb +16 -0
  49. data/lib/mechanize/redirect_not_get_or_head_error.rb +18 -0
  50. data/lib/mechanize/response_code_error.rb +22 -0
  51. data/lib/mechanize/unsupported_scheme_error.rb +8 -0
  52. data/lib/mechanize/util.rb +67 -0
  53. data/mechanize.gemspec +8 -8
  54. data/test/chain/test_argument_validator.rb +2 -2
  55. data/test/chain/test_auth_headers.rb +2 -2
  56. data/test/chain/test_custom_headers.rb +2 -2
  57. data/test/chain/test_header_resolver.rb +3 -3
  58. data/test/chain/test_parameter_resolver.rb +4 -4
  59. data/test/chain/test_request_resolver.rb +4 -4
  60. data/test/chain/test_response_reader.rb +3 -3
  61. data/test/helper.rb +1 -1
  62. data/test/htdocs/tc_bad_charset.html +9 -0
  63. data/test/htdocs/tc_charset.html +6 -0
  64. data/test/htdocs/test_bad_encoding.html +52 -0
  65. data/test/test_authenticate.rb +3 -3
  66. data/test/test_bad_links.rb +1 -1
  67. data/test/test_blank_form.rb +1 -1
  68. data/test/test_checkboxes.rb +1 -1
  69. data/test/test_content_type.rb +2 -2
  70. data/test/test_cookie_class.rb +12 -12
  71. data/test/test_cookie_jar.rb +13 -13
  72. data/test/test_cookies.rb +1 -1
  73. data/test/test_encoded_links.rb +1 -1
  74. data/test/test_errors.rb +2 -2
  75. data/test/test_follow_meta.rb +3 -3
  76. data/test/test_form_action.rb +1 -1
  77. data/test/test_form_as_hash.rb +1 -1
  78. data/test/test_form_button.rb +2 -2
  79. data/test/test_form_no_inputname.rb +1 -1
  80. data/test/test_forms.rb +1 -1
  81. data/test/test_frames.rb +1 -1
  82. data/test/test_get_headers.rb +1 -1
  83. data/test/test_gzipping.rb +2 -2
  84. data/test/test_hash_api.rb +1 -1
  85. data/test/test_history.rb +7 -7
  86. data/test/test_history_added.rb +1 -1
  87. data/test/test_html_unscape_forms.rb +7 -7
  88. data/test/test_if_modified_since.rb +1 -1
  89. data/test/test_keep_alive.rb +1 -1
  90. data/test/test_links.rb +2 -2
  91. data/test/test_mech.rb +2 -2
  92. data/test/test_mechanize_file.rb +7 -7
  93. data/test/test_meta.rb +2 -2
  94. data/test/test_multi_select.rb +1 -1
  95. data/test/test_no_attributes.rb +1 -1
  96. data/test/test_option.rb +1 -1
  97. data/test/test_page.rb +3 -3
  98. data/test/test_pluggable_parser.rb +14 -14
  99. data/test/test_post_form.rb +1 -1
  100. data/test/test_pretty_print.rb +2 -2
  101. data/test/test_radiobutton.rb +1 -1
  102. data/test/test_redirect_limit_reached.rb +1 -3
  103. data/test/test_redirect_verb_handling.rb +1 -3
  104. data/test/test_referer.rb +1 -1
  105. data/test/test_relative_links.rb +1 -1
  106. data/test/test_request.rb +1 -1
  107. data/test/test_response_code.rb +3 -3
  108. data/test/test_save_file.rb +3 -3
  109. data/test/test_scheme.rb +3 -3
  110. data/test/test_select.rb +2 -2
  111. data/test/test_select_all.rb +1 -1
  112. data/test/test_select_none.rb +1 -1
  113. data/test/test_select_noopts.rb +1 -1
  114. data/test/test_set_fields.rb +1 -1
  115. data/test/test_ssl_server.rb +1 -1
  116. data/test/test_subclass.rb +1 -1
  117. data/test/test_textarea.rb +1 -1
  118. data/test/test_upload.rb +1 -1
  119. data/test/test_verbs.rb +1 -1
  120. metadata +61 -56
  121. data/lib/www/mechanize.rb +0 -619
  122. data/lib/www/mechanize/chain.rb +0 -34
  123. data/lib/www/mechanize/chain/auth_headers.rb +0 -80
  124. data/lib/www/mechanize/chain/body_decoding_handler.rb +0 -48
  125. data/lib/www/mechanize/chain/connection_resolver.rb +0 -78
  126. data/lib/www/mechanize/chain/custom_headers.rb +0 -23
  127. data/lib/www/mechanize/chain/header_resolver.rb +0 -53
  128. data/lib/www/mechanize/chain/parameter_resolver.rb +0 -24
  129. data/lib/www/mechanize/chain/pre_connect_hook.rb +0 -22
  130. data/lib/www/mechanize/chain/request_resolver.rb +0 -32
  131. data/lib/www/mechanize/chain/response_body_parser.rb +0 -40
  132. data/lib/www/mechanize/chain/response_header_handler.rb +0 -50
  133. data/lib/www/mechanize/chain/response_reader.rb +0 -41
  134. data/lib/www/mechanize/chain/ssl_resolver.rb +0 -42
  135. data/lib/www/mechanize/chain/uri_resolver.rb +0 -77
  136. data/lib/www/mechanize/content_type_error.rb +0 -16
  137. data/lib/www/mechanize/cookie.rb +0 -72
  138. data/lib/www/mechanize/cookie_jar.rb +0 -191
  139. data/lib/www/mechanize/file.rb +0 -73
  140. data/lib/www/mechanize/file_response.rb +0 -62
  141. data/lib/www/mechanize/file_saver.rb +0 -39
  142. data/lib/www/mechanize/form.rb +0 -360
  143. data/lib/www/mechanize/form/button.rb +0 -8
  144. data/lib/www/mechanize/form/check_box.rb +0 -13
  145. data/lib/www/mechanize/form/field.rb +0 -28
  146. data/lib/www/mechanize/form/file_upload.rb +0 -24
  147. data/lib/www/mechanize/form/image_button.rb +0 -23
  148. data/lib/www/mechanize/form/multi_select_list.rb +0 -69
  149. data/lib/www/mechanize/form/option.rb +0 -51
  150. data/lib/www/mechanize/form/radio_button.rb +0 -38
  151. data/lib/www/mechanize/form/select_list.rb +0 -45
  152. data/lib/www/mechanize/headers.rb +0 -12
  153. data/lib/www/mechanize/history.rb +0 -67
  154. data/lib/www/mechanize/inspect.rb +0 -90
  155. data/lib/www/mechanize/page.rb +0 -181
  156. data/lib/www/mechanize/page/base.rb +0 -10
  157. data/lib/www/mechanize/page/frame.rb +0 -22
  158. data/lib/www/mechanize/page/link.rb +0 -50
  159. data/lib/www/mechanize/page/meta.rb +0 -51
  160. data/lib/www/mechanize/pluggable_parsers.rb +0 -103
  161. data/lib/www/mechanize/redirect_limit_reached_error.rb +0 -18
  162. data/lib/www/mechanize/redirect_not_get_or_head_error.rb +0 -20
  163. data/lib/www/mechanize/response_code_error.rb +0 -25
  164. data/lib/www/mechanize/unsupported_scheme_error.rb +0 -10
  165. data/lib/www/mechanize/util.rb +0 -76
@@ -0,0 +1,16 @@
1
+ class Mechanize
2
+ # Thrown when too many redirects are sent
3
+ class RedirectLimitReachedError < RuntimeError
4
+ attr_reader :page, :response_code, :redirects
5
+ def initialize(page, redirects)
6
+ @page = page
7
+ @redirects = redirects
8
+ @response_code = page.code
9
+ end
10
+
11
+ def to_s
12
+ "Maximum redirect limit (#{redirects}) reached"
13
+ end
14
+ alias :inspect :to_s
15
+ end
16
+ end
@@ -0,0 +1,18 @@
1
+ class Mechanize
2
+ # Thrown when a POST, PUT, or DELETE request results in a redirect
3
+ # see RFC 2616 10.3.2, 10.3.3 http://www.ietf.org/rfc/rfc2616.txt
4
+ class RedirectNotGetOrHeadError < RuntimeError
5
+ attr_reader :page, :response_code, :verb, :uri
6
+ def initialize(page, verb)
7
+ @page = page
8
+ @verb = verb
9
+ @uri = page.uri
10
+ @response_code = page.code
11
+ end
12
+
13
+ def to_s
14
+ "#{@response_code} redirect received after a #{@verb} request"
15
+ end
16
+ alias :inspect :to_s
17
+ end
18
+ end
@@ -0,0 +1,22 @@
1
+ class Mechanize
2
+ # =Synopsis
3
+ # This error is thrown when Mechanize encounters a response code it does
4
+ # not know how to handle. Currently, this exception will be thrown
5
+ # if Mechanize encounters response codes other than 200, 301, or 302.
6
+ # Any other response code is up to the user to handle.
7
+ class ResponseCodeError < RuntimeError
8
+ attr_reader :response_code
9
+ attr_reader :page
10
+
11
+ def initialize(page)
12
+ @page = page
13
+ @response_code = page.code
14
+ end
15
+
16
+ def to_s
17
+ "#{response_code} => #{Net::HTTPResponse::CODE_TO_OBJ[response_code]}"
18
+ end
19
+
20
+ def inspect; to_s; end
21
+ end
22
+ end
@@ -0,0 +1,8 @@
1
+ class Mechanize
2
+ class UnsupportedSchemeError < RuntimeError
3
+ attr_accessor :scheme
4
+ def initialize(scheme)
5
+ @scheme = scheme
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,67 @@
1
+ require 'cgi'
2
+
3
+ class Mechanize
4
+ class Util
5
+ CODE_DIC = {
6
+ :JIS => "ISO-2022-JP",
7
+ :EUC => "EUC-JP",
8
+ :SJIS => "SHIFT_JIS",
9
+ :UTF8 => "UTF-8", :UTF16 => "UTF-16", :UTF32 => "UTF-32"}
10
+
11
+ class << self
12
+ def build_query_string(parameters, enc=nil)
13
+ parameters.map { |k,v|
14
+ # WEBrick::HTTP.escape* has some problems about m17n on ruby-1.9.*.
15
+ [CGI.escape(k.to_s), CGI.escape(v.to_s)].join("=") if k
16
+ }.compact.join('&')
17
+ end
18
+
19
+ def to_native_charset(s, code=nil)
20
+ if Mechanize.html_parser == Nokogiri::HTML
21
+ return unless s
22
+ code ||= detect_charset(s)
23
+ Iconv.iconv("UTF-8", code, s).join("")
24
+ else
25
+ s
26
+ end
27
+ end
28
+
29
+ def from_native_charset(s, code)
30
+ if Mechanize.html_parser == Nokogiri::HTML
31
+ return unless s
32
+ Iconv.iconv(code, "UTF-8", s).join("")
33
+ else
34
+ return s
35
+ end
36
+ end
37
+
38
+ def html_unescape(s)
39
+ return s unless s
40
+ s.gsub(/&(\w+|#[0-9]+);/) { |match|
41
+ number = case match
42
+ when /&(\w+);/
43
+ Mechanize.html_parser::NamedCharacters[$1]
44
+ when /&#([0-9]+);/
45
+ $1.to_i
46
+ end
47
+
48
+ number ? ([number].pack('U') rescue match) : match
49
+ }
50
+ end
51
+
52
+ def detect_charset(src)
53
+ tmp = NKF.guess(src || "<html></html>")
54
+ if RUBY_VERSION >= "1.9.0"
55
+ enc = tmp.to_s.upcase
56
+ else
57
+ enc = NKF.constants.find{|c|
58
+ NKF.const_get(c) == tmp
59
+ }
60
+ enc = CODE_DIC[enc.intern]
61
+ end
62
+ enc || "ISO-8859-1"
63
+ end
64
+
65
+ end
66
+ end
67
+ end
data/mechanize.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{mechanize}
5
- s.version = "0.9.3.20090623142847"
5
+ s.version = "0.9.3.20090911221705"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Aaron Patterson", "Mike Dalessio"]
9
- s.date = %q{2009-06-23}
9
+ s.date = %q{2009-09-11}
10
10
  s.description = %q{The Mechanize library is used for automating interaction with websites.
11
11
  Mechanize automatically stores and sends cookies, follows redirects,
12
12
  can follow links, and submit forms. Form fields can be populated and
@@ -14,13 +14,13 @@ submitted. Mechanize also keeps track of the sites that you have visited as
14
14
  a history.}
15
15
  s.email = ["aaronp@rubyforge.org", "mike.dalessio@gmail.com"]
16
16
  s.extra_rdoc_files = ["Manifest.txt", "CHANGELOG.rdoc", "EXAMPLES.rdoc", "FAQ.rdoc", "GUIDE.rdoc", "LICENSE.rdoc", "README.rdoc"]
17
- s.files = ["CHANGELOG.rdoc", "EXAMPLES.rdoc", "FAQ.rdoc", "GUIDE.rdoc", "LICENSE.rdoc", "Manifest.txt", "README.rdoc", "Rakefile", "examples/flickr_upload.rb", "examples/mech-dump.rb", "examples/proxy_req.rb", "examples/rubyforge.rb", "examples/spider.rb", "lib/mechanize.rb", "lib/www/mechanize.rb", "lib/www/mechanize/chain.rb", "lib/www/mechanize/chain/auth_headers.rb", "lib/www/mechanize/chain/body_decoding_handler.rb", "lib/www/mechanize/chain/connection_resolver.rb", "lib/www/mechanize/chain/custom_headers.rb", "lib/www/mechanize/chain/handler.rb", "lib/www/mechanize/chain/header_resolver.rb", "lib/www/mechanize/chain/parameter_resolver.rb", "lib/www/mechanize/chain/post_connect_hook.rb", "lib/www/mechanize/chain/pre_connect_hook.rb", "lib/www/mechanize/chain/request_resolver.rb", "lib/www/mechanize/chain/response_body_parser.rb", "lib/www/mechanize/chain/response_header_handler.rb", "lib/www/mechanize/chain/response_reader.rb", "lib/www/mechanize/chain/ssl_resolver.rb", "lib/www/mechanize/chain/uri_resolver.rb", "lib/www/mechanize/content_type_error.rb", "lib/www/mechanize/cookie.rb", "lib/www/mechanize/cookie_jar.rb", "lib/www/mechanize/file.rb", "lib/www/mechanize/file_response.rb", "lib/www/mechanize/file_saver.rb", "lib/www/mechanize/form.rb", "lib/www/mechanize/form/button.rb", "lib/www/mechanize/form/check_box.rb", "lib/www/mechanize/form/field.rb", "lib/www/mechanize/form/file_upload.rb", "lib/www/mechanize/form/image_button.rb", "lib/www/mechanize/form/multi_select_list.rb", "lib/www/mechanize/form/option.rb", "lib/www/mechanize/form/radio_button.rb", "lib/www/mechanize/form/select_list.rb", "lib/www/mechanize/headers.rb", "lib/www/mechanize/history.rb", "lib/www/mechanize/inspect.rb", "lib/www/mechanize/monkey_patch.rb", "lib/www/mechanize/page.rb", "lib/www/mechanize/page/base.rb", "lib/www/mechanize/page/frame.rb", "lib/www/mechanize/page/link.rb", "lib/www/mechanize/page/meta.rb", "lib/www/mechanize/pluggable_parsers.rb", "lib/www/mechanize/redirect_limit_reached_error.rb", "lib/www/mechanize/redirect_not_get_or_head_error.rb", "lib/www/mechanize/response_code_error.rb", "lib/www/mechanize/unsupported_scheme_error.rb", "lib/www/mechanize/util.rb", "mechanize.gemspec", "test/chain/test_argument_validator.rb", "test/chain/test_custom_headers.rb", "test/chain/test_parameter_resolver.rb", "test/chain/test_request_resolver.rb", "test/chain/test_response_reader.rb", "test/data/htpasswd", "test/data/server.crt", "test/data/server.csr", "test/data/server.key", "test/data/server.pem", "test/helper.rb", "test/htdocs/alt_text.html", "test/htdocs/bad_form_test.html", "test/htdocs/button.jpg", "test/htdocs/empty_form.html", "test/htdocs/file_upload.html", "test/htdocs/find_link.html", "test/htdocs/form_multi_select.html", "test/htdocs/form_multival.html", "test/htdocs/form_no_action.html", "test/htdocs/form_no_input_name.html", "test/htdocs/form_select.html", "test/htdocs/form_select_all.html", "test/htdocs/form_select_none.html", "test/htdocs/form_select_noopts.html", "test/htdocs/form_set_fields.html", "test/htdocs/form_test.html", "test/htdocs/frame_test.html", "test/htdocs/google.html", "test/htdocs/iframe_test.html", "test/htdocs/index.html", "test/htdocs/link with space.html", "test/htdocs/meta_cookie.html", "test/htdocs/no_title_test.html", "test/htdocs/relative/tc_relative_links.html", "test/htdocs/tc_bad_links.html", "test/htdocs/tc_base_link.html", "test/htdocs/tc_blank_form.html", "test/htdocs/tc_checkboxes.html", "test/htdocs/tc_encoded_links.html", "test/htdocs/tc_follow_meta.html", "test/htdocs/tc_form_action.html", "test/htdocs/tc_links.html", "test/htdocs/tc_no_attributes.html", "test/htdocs/tc_pretty_print.html", "test/htdocs/tc_radiobuttons.html", "test/htdocs/tc_referer.html", "test/htdocs/tc_relative_links.html", "test/htdocs/tc_textarea.html", "test/htdocs/unusual______.html", "test/servlets.rb", "test/ssl_server.rb", "test/test_authenticate.rb", "test/test_bad_links.rb", "test/test_blank_form.rb", "test/test_checkboxes.rb", "test/test_content_type.rb", "test/test_cookie_class.rb", "test/test_cookie_jar.rb", "test/test_cookies.rb", "test/test_encoded_links.rb", "test/test_errors.rb", "test/test_follow_meta.rb", "test/test_form_action.rb", "test/test_form_as_hash.rb", "test/test_form_button.rb", "test/test_form_no_inputname.rb", "test/test_forms.rb", "test/test_frames.rb", "test/test_get_headers.rb", "test/test_gzipping.rb", "test/test_hash_api.rb", "test/test_history.rb", "test/test_history_added.rb", "test/test_html_unscape_forms.rb", "test/test_if_modified_since.rb", "test/test_keep_alive.rb", "test/test_links.rb", "test/test_mech.rb", "test/test_mechanize_file.rb", "test/test_multi_select.rb", "test/test_no_attributes.rb", "test/test_option.rb", "test/test_page.rb", "test/test_pluggable_parser.rb", "test/test_post_form.rb", "test/test_pretty_print.rb", "test/test_radiobutton.rb", "test/test_redirect_limit_reached.rb", "test/test_redirect_verb_handling.rb", "test/test_referer.rb", "test/test_relative_links.rb", "test/test_request.rb", "test/test_response_code.rb", "test/test_save_file.rb", "test/test_scheme.rb", "test/test_select.rb", "test/test_select_all.rb", "test/test_select_none.rb", "test/test_select_noopts.rb", "test/test_set_fields.rb", "test/test_ssl_server.rb", "test/test_subclass.rb", "test/test_textarea.rb", "test/test_upload.rb", "test/test_verbs.rb", "test/chain/test_auth_headers.rb", "test/chain/test_header_resolver.rb", "test/test_meta.rb"]
17
+ s.files = ["CHANGELOG.rdoc", "EXAMPLES.rdoc", "FAQ.rdoc", "GUIDE.rdoc", "LICENSE.rdoc", "Manifest.txt", "README.rdoc", "Rakefile", "examples/flickr_upload.rb", "examples/mech-dump.rb", "examples/proxy_req.rb", "examples/rubyforge.rb", "examples/spider.rb", "lib/mechanize.rb", "lib/mechanize/chain.rb", "lib/mechanize/chain/auth_headers.rb", "lib/mechanize/chain/body_decoding_handler.rb", "lib/mechanize/chain/connection_resolver.rb", "lib/mechanize/chain/custom_headers.rb", "lib/mechanize/chain/handler.rb", "lib/mechanize/chain/header_resolver.rb", "lib/mechanize/chain/parameter_resolver.rb", "lib/mechanize/chain/post_connect_hook.rb", "lib/mechanize/chain/pre_connect_hook.rb", "lib/mechanize/chain/request_resolver.rb", "lib/mechanize/chain/response_body_parser.rb", "lib/mechanize/chain/response_header_handler.rb", "lib/mechanize/chain/response_reader.rb", "lib/mechanize/chain/ssl_resolver.rb", "lib/mechanize/chain/uri_resolver.rb", "lib/mechanize/content_type_error.rb", "lib/mechanize/cookie.rb", "lib/mechanize/cookie_jar.rb", "lib/mechanize/file.rb", "lib/mechanize/file_response.rb", "lib/mechanize/file_saver.rb", "lib/mechanize/form.rb", "lib/mechanize/form/button.rb", "lib/mechanize/form/check_box.rb", "lib/mechanize/form/field.rb", "lib/mechanize/form/file_upload.rb", "lib/mechanize/form/image_button.rb", "lib/mechanize/form/multi_select_list.rb", "lib/mechanize/form/option.rb", "lib/mechanize/form/radio_button.rb", "lib/mechanize/form/select_list.rb", "lib/mechanize/headers.rb", "lib/mechanize/history.rb", "lib/mechanize/inspect.rb", "lib/mechanize/monkey_patch.rb", "lib/mechanize/page.rb", "lib/mechanize/page/base.rb", "lib/mechanize/page/frame.rb", "lib/mechanize/page/image.rb", "lib/mechanize/page/label.rb", "lib/mechanize/page/link.rb", "lib/mechanize/page/meta.rb", "lib/mechanize/pluggable_parsers.rb", "lib/mechanize/redirect_limit_reached_error.rb", "lib/mechanize/redirect_not_get_or_head_error.rb", "lib/mechanize/response_code_error.rb", "lib/mechanize/unsupported_scheme_error.rb", "lib/mechanize/util.rb", "mechanize.gemspec", "test/chain/test_argument_validator.rb", "test/chain/test_auth_headers.rb", "test/chain/test_custom_headers.rb", "test/chain/test_header_resolver.rb", "test/chain/test_parameter_resolver.rb", "test/chain/test_request_resolver.rb", "test/chain/test_response_reader.rb", "test/data/htpasswd", "test/data/server.crt", "test/data/server.csr", "test/data/server.key", "test/data/server.pem", "test/helper.rb", "test/htdocs/alt_text.html", "test/htdocs/bad_form_test.html", "test/htdocs/button.jpg", "test/htdocs/empty_form.html", "test/htdocs/file_upload.html", "test/htdocs/find_link.html", "test/htdocs/form_multi_select.html", "test/htdocs/form_multival.html", "test/htdocs/form_no_action.html", "test/htdocs/form_no_input_name.html", "test/htdocs/form_select.html", "test/htdocs/form_select_all.html", "test/htdocs/form_select_none.html", "test/htdocs/form_select_noopts.html", "test/htdocs/form_set_fields.html", "test/htdocs/form_test.html", "test/htdocs/frame_test.html", "test/htdocs/google.html", "test/htdocs/iframe_test.html", "test/htdocs/index.html", "test/htdocs/link with space.html", "test/htdocs/meta_cookie.html", "test/htdocs/no_title_test.html", "test/htdocs/relative/tc_relative_links.html", "test/htdocs/tc_bad_charset.html", "test/htdocs/tc_bad_links.html", "test/htdocs/tc_base_link.html", "test/htdocs/tc_blank_form.html", "test/htdocs/tc_charset.html", "test/htdocs/tc_checkboxes.html", "test/htdocs/tc_encoded_links.html", "test/htdocs/tc_follow_meta.html", "test/htdocs/tc_form_action.html", "test/htdocs/tc_links.html", "test/htdocs/tc_no_attributes.html", "test/htdocs/tc_pretty_print.html", "test/htdocs/tc_radiobuttons.html", "test/htdocs/tc_referer.html", "test/htdocs/tc_relative_links.html", "test/htdocs/tc_textarea.html", "test/htdocs/test_bad_encoding.html", "test/htdocs/unusual______.html", "test/servlets.rb", "test/ssl_server.rb", "test/test_authenticate.rb", "test/test_bad_links.rb", "test/test_blank_form.rb", "test/test_checkboxes.rb", "test/test_content_type.rb", "test/test_cookie_class.rb", "test/test_cookie_jar.rb", "test/test_cookies.rb", "test/test_encoded_links.rb", "test/test_errors.rb", "test/test_follow_meta.rb", "test/test_form_action.rb", "test/test_form_as_hash.rb", "test/test_form_button.rb", "test/test_form_no_inputname.rb", "test/test_forms.rb", "test/test_frames.rb", "test/test_get_headers.rb", "test/test_gzipping.rb", "test/test_hash_api.rb", "test/test_history.rb", "test/test_history_added.rb", "test/test_html_unscape_forms.rb", "test/test_if_modified_since.rb", "test/test_keep_alive.rb", "test/test_links.rb", "test/test_mech.rb", "test/test_mechanize_file.rb", "test/test_meta.rb", "test/test_multi_select.rb", "test/test_no_attributes.rb", "test/test_option.rb", "test/test_page.rb", "test/test_pluggable_parser.rb", "test/test_post_form.rb", "test/test_pretty_print.rb", "test/test_radiobutton.rb", "test/test_redirect_limit_reached.rb", "test/test_redirect_verb_handling.rb", "test/test_referer.rb", "test/test_relative_links.rb", "test/test_request.rb", "test/test_response_code.rb", "test/test_save_file.rb", "test/test_scheme.rb", "test/test_select.rb", "test/test_select_all.rb", "test/test_select_none.rb", "test/test_select_noopts.rb", "test/test_set_fields.rb", "test/test_ssl_server.rb", "test/test_subclass.rb", "test/test_textarea.rb", "test/test_upload.rb", "test/test_verbs.rb"]
18
18
  s.homepage = %q{http://mechanize.rubyforge.org/}
19
19
  s.rdoc_options = ["--main", "README.rdoc"]
20
20
  s.require_paths = ["lib"]
21
21
  s.rubyforge_project = %q{mechanize}
22
- s.rubygems_version = %q{1.3.4}
23
- s.summary = %q{Mechanize provides automated web-browsing}
22
+ s.rubygems_version = %q{1.3.5}
23
+ s.summary = %q{The Mechanize library is used for automating interaction with websites}
24
24
  s.test_files = ["test/chain/test_argument_validator.rb", "test/chain/test_auth_headers.rb", "test/chain/test_custom_headers.rb", "test/chain/test_header_resolver.rb", "test/chain/test_parameter_resolver.rb", "test/chain/test_request_resolver.rb", "test/chain/test_response_reader.rb", "test/test_authenticate.rb", "test/test_bad_links.rb", "test/test_blank_form.rb", "test/test_checkboxes.rb", "test/test_content_type.rb", "test/test_cookie_class.rb", "test/test_cookie_jar.rb", "test/test_cookies.rb", "test/test_encoded_links.rb", "test/test_errors.rb", "test/test_follow_meta.rb", "test/test_form_action.rb", "test/test_form_as_hash.rb", "test/test_form_button.rb", "test/test_form_no_inputname.rb", "test/test_forms.rb", "test/test_frames.rb", "test/test_get_headers.rb", "test/test_gzipping.rb", "test/test_hash_api.rb", "test/test_history.rb", "test/test_history_added.rb", "test/test_html_unscape_forms.rb", "test/test_if_modified_since.rb", "test/test_keep_alive.rb", "test/test_links.rb", "test/test_mech.rb", "test/test_mechanize_file.rb", "test/test_meta.rb", "test/test_multi_select.rb", "test/test_no_attributes.rb", "test/test_option.rb", "test/test_page.rb", "test/test_pluggable_parser.rb", "test/test_post_form.rb", "test/test_pretty_print.rb", "test/test_radiobutton.rb", "test/test_redirect_limit_reached.rb", "test/test_redirect_verb_handling.rb", "test/test_referer.rb", "test/test_relative_links.rb", "test/test_request.rb", "test/test_response_code.rb", "test/test_save_file.rb", "test/test_scheme.rb", "test/test_select.rb", "test/test_select_all.rb", "test/test_select_none.rb", "test/test_select_noopts.rb", "test/test_set_fields.rb", "test/test_ssl_server.rb", "test/test_subclass.rb", "test/test_textarea.rb", "test/test_upload.rb", "test/test_verbs.rb"]
25
25
 
26
26
  if s.respond_to? :specification_version then
@@ -29,13 +29,13 @@ a history.}
29
29
 
30
30
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
31
31
  s.add_runtime_dependency(%q<nokogiri>, [">= 1.2.1"])
32
- s.add_development_dependency(%q<hoe>, [">= 2.2.0"])
32
+ s.add_development_dependency(%q<hoe>, [">= 2.3.3"])
33
33
  else
34
34
  s.add_dependency(%q<nokogiri>, [">= 1.2.1"])
35
- s.add_dependency(%q<hoe>, [">= 2.2.0"])
35
+ s.add_dependency(%q<hoe>, [">= 2.3.3"])
36
36
  end
37
37
  else
38
38
  s.add_dependency(%q<nokogiri>, [">= 1.2.1"])
39
- s.add_dependency(%q<hoe>, [">= 2.2.0"])
39
+ s.add_dependency(%q<hoe>, [">= 2.3.3"])
40
40
  end
41
41
  end
@@ -2,8 +2,8 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', "helper"))
2
2
 
3
3
  class TestURIResolver < Test::Unit::TestCase
4
4
  def test_handle
5
- v = WWW::Mechanize::Chain.new([
6
- WWW::Mechanize::Chain::URIResolver.new(Hash.new { |h,k|
5
+ v = Mechanize::Chain.new([
6
+ Mechanize::Chain::URIResolver.new(Hash.new { |h,k|
7
7
  h[k] = lambda { |u,r| u }
8
8
  })
9
9
  ])
@@ -4,8 +4,8 @@ class TestAuthHeaders < Test::Unit::TestCase
4
4
  def test_auth
5
5
  url = URI.parse('http://www.anthonychaves.net/tests.xml')
6
6
  digest = %Q!Digest realm="www.anthonychaves.net", qop="auth", algorithm=MD5, nonce="MTI0NTEyMTYyNjo0ZTY2MjhlZWMyZmM1ZjA0M2Y1Njc1MGU0YTA2MWY5OQ==", opaque="9f455d4e71e8d46a6d3aaef8bf8b0d9e"!
7
- v = WWW::Mechanize::Chain.new([
8
- WWW::Mechanize::Chain::AuthHeaders.new({(url.host) => :digest}, "anthony", "password", digest)
7
+ v = Mechanize::Chain.new([
8
+ Mechanize::Chain::AuthHeaders.new({(url.host) => :digest}, "anthony", "password", digest)
9
9
  ])
10
10
 
11
11
  hash = {
@@ -2,8 +2,8 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', "helper"))
2
2
 
3
3
  class TestCustomHeaders < Test::Unit::TestCase
4
4
  def test_handle
5
- v = WWW::Mechanize::Chain.new([
6
- WWW::Mechanize::Chain::CustomHeaders.new
5
+ v = Mechanize::Chain.new([
6
+ Mechanize::Chain::CustomHeaders.new
7
7
  ])
8
8
  url = URI.parse('http://tenderlovemaking.com/')
9
9
  hash = {
@@ -2,11 +2,11 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', "helper"))
2
2
 
3
3
  class TestHeaderResolver < Test::Unit::TestCase
4
4
  def setup
5
- @chain = WWW::Mechanize::Chain.new([
6
- WWW::Mechanize::Chain::HeaderResolver.new(
5
+ @chain = Mechanize::Chain.new([
6
+ Mechanize::Chain::HeaderResolver.new(
7
7
  true,
8
8
  300,
9
- WWW::Mechanize::CookieJar.new,
9
+ Mechanize::CookieJar.new,
10
10
  'foobar',
11
11
  {
12
12
  'hello' => 'world',
@@ -2,8 +2,8 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', "helper"))
2
2
 
3
3
  class TestParameterResolver < Test::Unit::TestCase
4
4
  def test_handle_get
5
- v = WWW::Mechanize::Chain.new([
6
- WWW::Mechanize::Chain::ParameterResolver.new
5
+ v = Mechanize::Chain.new([
6
+ Mechanize::Chain::ParameterResolver.new
7
7
  ])
8
8
  hash = {
9
9
  :uri => URI.parse('http://google.com/'),
@@ -18,8 +18,8 @@ class TestParameterResolver < Test::Unit::TestCase
18
18
  end
19
19
 
20
20
  def test_handle_post
21
- v = WWW::Mechanize::Chain.new([
22
- WWW::Mechanize::Chain::ParameterResolver.new
21
+ v = Mechanize::Chain.new([
22
+ Mechanize::Chain::ParameterResolver.new
23
23
  ])
24
24
  hash = {
25
25
  :uri => URI.parse('http://google.com/'),
@@ -2,8 +2,8 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', "helper"))
2
2
 
3
3
  class TestRequestResolver < Test::Unit::TestCase
4
4
  def test_handle_get
5
- v = WWW::Mechanize::Chain.new([
6
- WWW::Mechanize::Chain::RequestResolver.new
5
+ v = Mechanize::Chain.new([
6
+ Mechanize::Chain::RequestResolver.new
7
7
  ])
8
8
  hash = {
9
9
  :uri => URI.parse('http://google.com'),
@@ -15,8 +15,8 @@ class TestRequestResolver < Test::Unit::TestCase
15
15
  end
16
16
 
17
17
  def test_handle_post
18
- v = WWW::Mechanize::Chain.new([
19
- WWW::Mechanize::Chain::RequestResolver.new
18
+ v = Mechanize::Chain.new([
19
+ Mechanize::Chain::RequestResolver.new
20
20
  ])
21
21
  hash = {
22
22
  :uri => URI.parse('http://google.com'),
@@ -9,10 +9,10 @@ class TestResponseReader < Test::Unit::TestCase
9
9
  def code; 999; end
10
10
  end
11
11
 
12
- v = WWW::Mechanize::Chain.new([
13
- WWW::Mechanize::Chain::ResponseReader.new(response)
12
+ v = Mechanize::Chain.new([
13
+ Mechanize::Chain::ResponseReader.new(response)
14
14
  ])
15
- assert_raises(WWW::Mechanize::ResponseCodeError) {
15
+ assert_raises(Mechanize::ResponseCodeError) {
16
16
  begin
17
17
  v.handle({})
18
18
  rescue Exception => x
data/test/helper.rb CHANGED
@@ -16,7 +16,7 @@ module MechTestHelper
16
16
  </body></html>
17
17
  END
18
18
  html_response = { 'content-type' => 'text/html' }
19
- page = WWW::Mechanize::Page.new( nil, html_response, html, 200, agent )
19
+ page = Mechanize::Page.new( nil, html_response, html, 200, agent )
20
20
  end
21
21
  end
22
22
 
@@ -0,0 +1,9 @@
1
+ <!-- correct encoding: ISO-8859-2 -->
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=windows-1255"/>
5
+ </head>
6
+ <body>
7
+ <p>Bia�ystok</p>
8
+ </body>
9
+ </html>
@@ -0,0 +1,6 @@
1
+ <html>
2
+ <head>
3
+ <meta http-equiv="Content-Type" content="text/html; charset=windows-1255"/>
4
+ </head>
5
+ <body></body>
6
+ </html>
@@ -0,0 +1,52 @@
1
+ <html>
2
+ <head>
3
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8; charset=utf-8"/>
4
+ <title>Page Title</title>
5
+ </head>
6
+ <body>
7
+ <h1>Post Form 1</h1>
8
+ <form name="post_form1" method="post" action="/form_post?a=b&amp;b=c">
9
+ <table>
10
+ <tr>
11
+ <td>First Name</td>
12
+ <td><input type="text" name="first_name" /></td>
13
+ </tr>
14
+ </table><br />
15
+ <input type="submit" value="Submit" />
16
+ </form>
17
+
18
+ <h1>Post Form 2</h1>
19
+ <form name="post_form2" method="get" action="/form_post?a=b&amp;b=c">
20
+ <table>
21
+ <tr>
22
+ <td>First Name</td>
23
+ <td><input type="text" name="first_name" /></td>
24
+ </tr>
25
+ </table><br />
26
+ <input type="submit" value="Submit" />
27
+ </form>
28
+
29
+ <h1>Post Form 3</h1>
30
+ <form name="post_form3" method="post" action="/form_post?a=b&b=c">
31
+ <table>
32
+ <tr>
33
+ <td>First Name</td>
34
+ <td><input type="text" name="first_name" /></td>
35
+ </tr>
36
+ </table><br />
37
+ <input type="submit" value="Submit" />
38
+ </form>
39
+
40
+ <h1>Post Form 4</h1>
41
+ <form name="post_form4" method="post" action="/form_post#1">
42
+ <table>
43
+ <tr>
44
+ <td>First Name</td>
45
+ <td><input type="text" name="first_name" /></td>
46
+ </tr>
47
+ </table><br />
48
+ <input type="submit" value="Submit" />
49
+ </form>
50
+ </body>
51
+ </html>
52
+
@@ -3,7 +3,7 @@ require 'pp'
3
3
 
4
4
  class BasicAuthTest < Test::Unit::TestCase
5
5
  def setup
6
- @agent = WWW::Mechanize.new
6
+ @agent = Mechanize.new
7
7
  end
8
8
 
9
9
  def test_auth_success
@@ -55,7 +55,7 @@ class BasicAuthTest < Test::Unit::TestCase
55
55
  @agent.basic_auth('aaron', 'aaron')
56
56
  begin
57
57
  page = @agent.get("http://localhost/basic_auth")
58
- rescue WWW::Mechanize::ResponseCodeError => e
58
+ rescue Mechanize::ResponseCodeError => e
59
59
  assert_equal("401", e.response_code)
60
60
  end
61
61
  end
@@ -63,7 +63,7 @@ class BasicAuthTest < Test::Unit::TestCase
63
63
  def test_auth_failure
64
64
  begin
65
65
  page = @agent.get("http://localhost/basic_auth")
66
- rescue WWW::Mechanize::ResponseCodeError => e
66
+ rescue Mechanize::ResponseCodeError => e
67
67
  assert_equal("401", e.response_code)
68
68
  end
69
69
  end
@@ -2,7 +2,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), "helper"))
2
2
 
3
3
  class TestBadLinks < Test::Unit::TestCase
4
4
  def setup
5
- @agent = WWW::Mechanize.new
5
+ @agent = Mechanize.new
6
6
  @page = @agent.get("http://localhost/tc_bad_links.html")
7
7
  end
8
8
 
@@ -2,7 +2,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), "helper"))
2
2
 
3
3
  class BlankFormTest < Test::Unit::TestCase
4
4
  def setup
5
- @agent = WWW::Mechanize.new
5
+ @agent = Mechanize.new
6
6
  end
7
7
 
8
8
  def test_blank_form_query_string
@@ -2,7 +2,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), "helper"))
2
2
 
3
3
  class TestCheckBoxes < Test::Unit::TestCase
4
4
  def setup
5
- @agent = WWW::Mechanize.new
5
+ @agent = Mechanize.new
6
6
  @page = @agent.get('http://localhost/tc_checkboxes.html')
7
7
  end
8
8
 
@@ -2,12 +2,12 @@ require File.expand_path(File.join(File.dirname(__FILE__), "helper"))
2
2
 
3
3
  class TestContentType < Test::Unit::TestCase
4
4
  def setup
5
- @agent = WWW::Mechanize.new
5
+ @agent = Mechanize.new
6
6
  end
7
7
 
8
8
  def test_application_xhtml_xml
9
9
  url = 'http://localhost/content_type_test?ct=application/xhtml%2Bxml'
10
10
  page = @agent.get url
11
- assert_equal WWW::Mechanize::Page, page.class, "xhtml docs should return a Page"
11
+ assert_equal Mechanize::Page, page.class, "xhtml docs should return a Page"
12
12
  end
13
13
  end