mechanize 0.6.11 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of mechanize might be problematic. Click here for more details.
- data/CHANGELOG.txt +8 -0
- data/Manifest.txt +31 -22
- data/lib/mechanize.rb +2 -652
- data/lib/www/mechanize.rb +635 -0
- data/lib/www/mechanize/content_type_error.rb +16 -0
- data/lib/www/mechanize/cookie.rb +64 -0
- data/lib/{mechanize/cookie.rb → www/mechanize/cookie_jar.rb} +0 -60
- data/lib/www/mechanize/file.rb +73 -0
- data/lib/www/mechanize/file_saver.rb +39 -0
- data/lib/{mechanize → www/mechanize}/form.rb +119 -137
- data/lib/www/mechanize/form/button.rb +8 -0
- data/lib/www/mechanize/form/check_box.rb +13 -0
- data/lib/www/mechanize/form/field.rb +28 -0
- data/lib/www/mechanize/form/file_upload.rb +24 -0
- data/lib/www/mechanize/form/image_button.rb +23 -0
- data/lib/www/mechanize/form/multi_select_list.rb +69 -0
- data/lib/www/mechanize/form/option.rb +51 -0
- data/lib/www/mechanize/form/radio_button.rb +38 -0
- data/lib/www/mechanize/form/select_list.rb +41 -0
- data/lib/www/mechanize/headers.rb +12 -0
- data/lib/{mechanize → www/mechanize}/history.rb +0 -0
- data/lib/{mechanize → www/mechanize}/inspect.rb +21 -28
- data/lib/{mechanize → www/mechanize}/list.rb +0 -0
- data/lib/{mechanize → www/mechanize}/monkey_patch.rb +19 -0
- data/lib/www/mechanize/page.rb +121 -0
- data/lib/www/mechanize/page/base.rb +10 -0
- data/lib/www/mechanize/page/frame.rb +22 -0
- data/lib/www/mechanize/page/link.rb +50 -0
- data/lib/www/mechanize/page/meta.rb +10 -0
- data/lib/www/mechanize/pluggable_parsers.rb +93 -0
- data/lib/{mechanize/errors.rb → www/mechanize/response_code_error.rb} +1 -13
- data/test/{test_includes.rb → helper.rb} +4 -18
- data/test/{test_servlets.rb → servlets.rb} +0 -0
- data/test/tc_authenticate.rb +1 -8
- data/test/tc_bad_links.rb +3 -10
- data/test/tc_blank_form.rb +1 -8
- data/test/tc_checkboxes.rb +1 -8
- data/test/tc_cookie_class.rb +1 -6
- data/test/tc_cookie_jar.rb +1 -7
- data/test/tc_cookies.rb +10 -17
- data/test/tc_encoded_links.rb +5 -12
- data/test/tc_errors.rb +4 -11
- data/test/tc_follow_meta.rb +1 -8
- data/test/tc_form_action.rb +6 -14
- data/test/tc_form_as_hash.rb +1 -9
- data/test/tc_form_button.rb +5 -8
- data/test/tc_form_no_inputname.rb +1 -8
- data/test/tc_forms.rb +16 -24
- data/test/tc_frames.rb +3 -10
- data/test/tc_gzipping.rb +2 -9
- data/test/tc_history.rb +5 -12
- data/test/tc_html_unscape_forms.rb +8 -15
- data/test/tc_if_modified_since.rb +1 -6
- data/test/tc_keep_alive.rb +1 -8
- data/test/tc_links.rb +12 -19
- data/test/tc_mech.rb +26 -34
- data/test/{test_mechanize_file.rb → tc_mechanize_file.rb} +1 -6
- data/test/tc_multi_select.rb +10 -17
- data/test/tc_no_attributes.rb +1 -8
- data/test/tc_page.rb +3 -10
- data/test/tc_pluggable_parser.rb +8 -15
- data/test/tc_post_form.rb +3 -10
- data/test/tc_pretty_print.rb +3 -10
- data/test/tc_radiobutton.rb +2 -9
- data/test/tc_referer.rb +13 -20
- data/test/tc_relative_links.rb +1 -8
- data/test/tc_response_code.rb +14 -21
- data/test/tc_save_file.rb +1 -9
- data/test/tc_select.rb +3 -10
- data/test/tc_select_all.rb +2 -10
- data/test/tc_select_none.rb +2 -10
- data/test/tc_select_noopts.rb +2 -9
- data/test/tc_set_fields.rb +2 -9
- data/test/tc_ssl_server.rb +5 -12
- data/test/tc_subclass.rb +2 -9
- data/test/tc_textarea.rb +2 -9
- data/test/tc_upload.rb +2 -9
- data/test/test_all.rb +4 -43
- metadata +96 -80
- data/lib/mechanize/form_elements.rb +0 -254
- data/lib/mechanize/net-overrides/net/http.rb +0 -2107
- data/lib/mechanize/net-overrides/net/https.rb +0 -172
- data/lib/mechanize/net-overrides/net/protocol.rb +0 -380
- data/lib/mechanize/page.rb +0 -138
- data/lib/mechanize/page_elements.rb +0 -77
- data/lib/mechanize/parsers/rexml_page.rb +0 -35
- data/lib/mechanize/pluggable_parsers.rb +0 -204
- data/lib/mechanize/rexml.rb +0 -236
- data/setup.rb +0 -1585
- data/test/tc_proxy.rb +0 -25
- data/test/tc_watches.rb +0 -32
| @@ -0,0 +1,13 @@ | |
| 1 | 
            +
            module WWW
         | 
| 2 | 
            +
              class Mechanize
         | 
| 3 | 
            +
                class Form
         | 
| 4 | 
            +
                  # This class represents a check box found in a Form.  To activate the
         | 
| 5 | 
            +
                  # CheckBox in the Form, set the checked method to true.
         | 
| 6 | 
            +
                  class CheckBox < RadioButton
         | 
| 7 | 
            +
                    def query_value
         | 
| 8 | 
            +
                      [[@name, @value || "on"]]
         | 
| 9 | 
            +
                    end
         | 
| 10 | 
            +
                  end
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
            end
         | 
| @@ -0,0 +1,28 @@ | |
| 1 | 
            +
            module WWW
         | 
| 2 | 
            +
              class Mechanize
         | 
| 3 | 
            +
                class Form
         | 
| 4 | 
            +
                  # This class represents a field in a form.  It handles the following input
         | 
| 5 | 
            +
                  # tags found in a form:
         | 
| 6 | 
            +
                  # text, password, hidden, int, textarea
         | 
| 7 | 
            +
                  #
         | 
| 8 | 
            +
                  # To set the value of a field, just use the value method:
         | 
| 9 | 
            +
                  # field.value = "foo"
         | 
| 10 | 
            +
                  class Field
         | 
| 11 | 
            +
                    attr_accessor :name, :value
         | 
| 12 | 
            +
                  
         | 
| 13 | 
            +
                    def initialize(name, value)
         | 
| 14 | 
            +
                      @name = Mechanize.html_unescape(name)
         | 
| 15 | 
            +
                      @value = if value.is_a? String
         | 
| 16 | 
            +
                                 Mechanize.html_unescape(value)
         | 
| 17 | 
            +
                               else
         | 
| 18 | 
            +
                                 value
         | 
| 19 | 
            +
                               end
         | 
| 20 | 
            +
                    end
         | 
| 21 | 
            +
                  
         | 
| 22 | 
            +
                    def query_value
         | 
| 23 | 
            +
                      [[@name, @value || '']]
         | 
| 24 | 
            +
                    end
         | 
| 25 | 
            +
                  end
         | 
| 26 | 
            +
                end
         | 
| 27 | 
            +
              end
         | 
| 28 | 
            +
            end
         | 
| @@ -0,0 +1,24 @@ | |
| 1 | 
            +
            module WWW
         | 
| 2 | 
            +
              class Mechanize
         | 
| 3 | 
            +
                class Form
         | 
| 4 | 
            +
                  # This class represents a file upload field found in a form.  To use this
         | 
| 5 | 
            +
                  # class, set WWW::FileUpload#file_data= to the data of the file you want
         | 
| 6 | 
            +
                  # to upload and WWW::FileUpload#mime_type= to the appropriate mime type
         | 
| 7 | 
            +
                  # of the file.
         | 
| 8 | 
            +
                  # See the example in EXAMPLES[link://files/EXAMPLES_txt.html]
         | 
| 9 | 
            +
                  class FileUpload < Field
         | 
| 10 | 
            +
                    attr_accessor :file_name # File name
         | 
| 11 | 
            +
                    attr_accessor :mime_type # Mime Type (Optional)
         | 
| 12 | 
            +
                    
         | 
| 13 | 
            +
                    alias :file_data :value
         | 
| 14 | 
            +
                    alias :file_data= :value=
         | 
| 15 | 
            +
                  
         | 
| 16 | 
            +
                    def initialize(name, file_name)
         | 
| 17 | 
            +
                      @file_name = Mechanize.html_unescape(file_name)
         | 
| 18 | 
            +
                      @file_data = nil
         | 
| 19 | 
            +
                      super(name, @file_data)
         | 
| 20 | 
            +
                    end
         | 
| 21 | 
            +
                  end
         | 
| 22 | 
            +
                end
         | 
| 23 | 
            +
              end
         | 
| 24 | 
            +
            end
         | 
| @@ -0,0 +1,23 @@ | |
| 1 | 
            +
            module WWW
         | 
| 2 | 
            +
              class Mechanize
         | 
| 3 | 
            +
                class Form
         | 
| 4 | 
            +
                  # This class represents an image button in a form.  Use the x and y methods
         | 
| 5 | 
            +
                  # to set the x and y positions for where the mouse "clicked".
         | 
| 6 | 
            +
                  class ImageButton < Button
         | 
| 7 | 
            +
                    attr_accessor :x, :y
         | 
| 8 | 
            +
                    
         | 
| 9 | 
            +
                    def initialize(name, value)
         | 
| 10 | 
            +
                      @x = nil
         | 
| 11 | 
            +
                      @y = nil
         | 
| 12 | 
            +
                      super(name, value)
         | 
| 13 | 
            +
                    end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                    def query_value
         | 
| 16 | 
            +
                        super <<
         | 
| 17 | 
            +
                         [@name + ".x", (@x || 0).to_s] <<
         | 
| 18 | 
            +
                         [@name + ".y", (@y || 0).to_s]
         | 
| 19 | 
            +
                    end
         | 
| 20 | 
            +
                  end
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
            end
         | 
| @@ -0,0 +1,69 @@ | |
| 1 | 
            +
            module WWW
         | 
| 2 | 
            +
              class Mechanize
         | 
| 3 | 
            +
                class Form
         | 
| 4 | 
            +
                  # This class represents a select list where multiple values can be selected.
         | 
| 5 | 
            +
                  # MultiSelectList#value= accepts an array, and those values are used as
         | 
| 6 | 
            +
                  # values for the select list.  For example, to select multiple values,
         | 
| 7 | 
            +
                  # simply do this:
         | 
| 8 | 
            +
                  #  list.value = ['one', 'two']
         | 
| 9 | 
            +
                  # Single values are still supported, so these two are the same:
         | 
| 10 | 
            +
                  #  list.value = ['one']
         | 
| 11 | 
            +
                  #  list.value = 'one'
         | 
| 12 | 
            +
                  class MultiSelectList < Field
         | 
| 13 | 
            +
                    attr_accessor :options
         | 
| 14 | 
            +
                  
         | 
| 15 | 
            +
                    def initialize(name, node)
         | 
| 16 | 
            +
                      value = []
         | 
| 17 | 
            +
                      @options = WWW::Mechanize::List.new
         | 
| 18 | 
            +
                  
         | 
| 19 | 
            +
                      # parse
         | 
| 20 | 
            +
                      (node/'option').each do |n|
         | 
| 21 | 
            +
                        option = Option.new(n, self)
         | 
| 22 | 
            +
                        @options << option
         | 
| 23 | 
            +
                      end
         | 
| 24 | 
            +
                      super(name, value)
         | 
| 25 | 
            +
                    end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                    def query_value
         | 
| 28 | 
            +
                      value ? value.collect { |v| [name, v] } : ''
         | 
| 29 | 
            +
                    end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                    # Select no options
         | 
| 32 | 
            +
                    def select_none
         | 
| 33 | 
            +
                      @value = []
         | 
| 34 | 
            +
                      options.each { |o| o.untick }
         | 
| 35 | 
            +
                    end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                    # Select all options
         | 
| 38 | 
            +
                    def select_all
         | 
| 39 | 
            +
                      @value = []
         | 
| 40 | 
            +
                      options.each { |o| o.tick }
         | 
| 41 | 
            +
                    end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                    # Get a list of all selected options
         | 
| 44 | 
            +
                    def selected_options
         | 
| 45 | 
            +
                      @options.find_all { |o| o.selected? }
         | 
| 46 | 
            +
                    end
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                    def value=(values)
         | 
| 49 | 
            +
                      select_none
         | 
| 50 | 
            +
                      values.each do |value|
         | 
| 51 | 
            +
                        option = options.find { |o| o.value == value }
         | 
| 52 | 
            +
                        if option.nil?
         | 
| 53 | 
            +
                          @value.push(value)
         | 
| 54 | 
            +
                        else
         | 
| 55 | 
            +
                          option.select
         | 
| 56 | 
            +
                        end
         | 
| 57 | 
            +
                      end
         | 
| 58 | 
            +
                    end
         | 
| 59 | 
            +
             | 
| 60 | 
            +
                    def value
         | 
| 61 | 
            +
                      value = []
         | 
| 62 | 
            +
                      value.push(*@value)
         | 
| 63 | 
            +
                      value.push(*selected_options.collect { |o| o.value })
         | 
| 64 | 
            +
                      value
         | 
| 65 | 
            +
                    end
         | 
| 66 | 
            +
                  end
         | 
| 67 | 
            +
                end
         | 
| 68 | 
            +
              end
         | 
| 69 | 
            +
            end
         | 
| @@ -0,0 +1,51 @@ | |
| 1 | 
            +
            module WWW
         | 
| 2 | 
            +
              class Mechanize
         | 
| 3 | 
            +
                class Form
         | 
| 4 | 
            +
                  # This class contains option an option found within SelectList.  A
         | 
| 5 | 
            +
                  # SelectList can have many Option classes associated with it.  An option
         | 
| 6 | 
            +
                  # can be selected by calling Option#tick, or Option#click.  For example,
         | 
| 7 | 
            +
                  # select the first option in a list:
         | 
| 8 | 
            +
                  #  select_list.first.tick
         | 
| 9 | 
            +
                  class Option
         | 
| 10 | 
            +
                    attr_reader :value, :selected, :text, :select_list
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                    alias :to_s :value
         | 
| 13 | 
            +
                    alias :selected? :selected
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                    def initialize(node, select_list)
         | 
| 16 | 
            +
                      @text     = node.inner_text
         | 
| 17 | 
            +
                      @value    = Mechanize.html_unescape(node['value'])
         | 
| 18 | 
            +
                      @selected = node.has_attribute? 'selected'
         | 
| 19 | 
            +
                      @select_list = select_list # The select list this option belongs to
         | 
| 20 | 
            +
                    end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                    # Select this option
         | 
| 23 | 
            +
                    def select
         | 
| 24 | 
            +
                      unselect_peers
         | 
| 25 | 
            +
                      @selected = true
         | 
| 26 | 
            +
                    end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                    # Unselect this option
         | 
| 29 | 
            +
                    def unselect
         | 
| 30 | 
            +
                      @selected = false
         | 
| 31 | 
            +
                    end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                    alias :tick   :select
         | 
| 34 | 
            +
                    alias :untick :unselect
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                    # Toggle the selection value of this option
         | 
| 37 | 
            +
                    def click
         | 
| 38 | 
            +
                      unselect_peers
         | 
| 39 | 
            +
                      @selected = !@selected
         | 
| 40 | 
            +
                    end
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                    private
         | 
| 43 | 
            +
                    def unselect_peers
         | 
| 44 | 
            +
                      if @select_list.instance_of? SelectList
         | 
| 45 | 
            +
                        @select_list.select_none
         | 
| 46 | 
            +
                      end
         | 
| 47 | 
            +
                    end
         | 
| 48 | 
            +
                  end
         | 
| 49 | 
            +
                end
         | 
| 50 | 
            +
              end
         | 
| 51 | 
            +
            end
         | 
| @@ -0,0 +1,38 @@ | |
| 1 | 
            +
            module WWW
         | 
| 2 | 
            +
              class Mechanize
         | 
| 3 | 
            +
                class Form
         | 
| 4 | 
            +
                  # This class represents a radio button found in a Form.  To activate the
         | 
| 5 | 
            +
                  # RadioButton in the Form, set the checked method to true.
         | 
| 6 | 
            +
                  class RadioButton < Field
         | 
| 7 | 
            +
                    attr_accessor :checked
         | 
| 8 | 
            +
                  
         | 
| 9 | 
            +
                    def initialize(name, value, checked, form)
         | 
| 10 | 
            +
                      @checked = checked
         | 
| 11 | 
            +
                      @form    = form
         | 
| 12 | 
            +
                      super(name, value)
         | 
| 13 | 
            +
                    end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                    def check
         | 
| 16 | 
            +
                      uncheck_peers
         | 
| 17 | 
            +
                      @checked = true
         | 
| 18 | 
            +
                    end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                    def uncheck
         | 
| 21 | 
            +
                      @checked = false
         | 
| 22 | 
            +
                    end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                    def click
         | 
| 25 | 
            +
                      @checked = !@checked
         | 
| 26 | 
            +
                    end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                    private
         | 
| 29 | 
            +
                    def uncheck_peers
         | 
| 30 | 
            +
                      @form.radiobuttons.name(name).each do |b|
         | 
| 31 | 
            +
                        next if b.value == value
         | 
| 32 | 
            +
                        b.uncheck
         | 
| 33 | 
            +
                      end
         | 
| 34 | 
            +
                    end
         | 
| 35 | 
            +
                  end
         | 
| 36 | 
            +
                end
         | 
| 37 | 
            +
              end
         | 
| 38 | 
            +
            end
         | 
| @@ -0,0 +1,41 @@ | |
| 1 | 
            +
            module WWW
         | 
| 2 | 
            +
              class Mechanize
         | 
| 3 | 
            +
                class Form
         | 
| 4 | 
            +
                  # This class represents a select list or drop down box in a Form.  Set the
         | 
| 5 | 
            +
                  # value for the list by calling SelectList#value=.  SelectList contains a
         | 
| 6 | 
            +
                  # list of Option that were found.  After finding the correct option, set
         | 
| 7 | 
            +
                  # the select lists value to the option value:
         | 
| 8 | 
            +
                  #  selectlist.value = selectlist.options.first.value
         | 
| 9 | 
            +
                  # Options can also be selected by "clicking" or selecting them.  See Option
         | 
| 10 | 
            +
                  class SelectList < MultiSelectList
         | 
| 11 | 
            +
                    def initialize(name, node)
         | 
| 12 | 
            +
                      super(name, node)
         | 
| 13 | 
            +
                      if selected_options.length > 1
         | 
| 14 | 
            +
                        selected_options.reverse[1..selected_options.length].each do |o|
         | 
| 15 | 
            +
                          o.unselect
         | 
| 16 | 
            +
                        end
         | 
| 17 | 
            +
                      end
         | 
| 18 | 
            +
                    end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                    def value
         | 
| 21 | 
            +
                      value = super
         | 
| 22 | 
            +
                      if value.length > 0
         | 
| 23 | 
            +
                        value.last
         | 
| 24 | 
            +
                      elsif @options.length > 0
         | 
| 25 | 
            +
                        @options.first.value
         | 
| 26 | 
            +
                      else
         | 
| 27 | 
            +
                        nil
         | 
| 28 | 
            +
                      end
         | 
| 29 | 
            +
                    end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                    def value=(new)
         | 
| 32 | 
            +
                      if new != new.to_s and new.respond_to? :first
         | 
| 33 | 
            +
                        super([new.first])
         | 
| 34 | 
            +
                      else
         | 
| 35 | 
            +
                        super([new.to_s])
         | 
| 36 | 
            +
                      end
         | 
| 37 | 
            +
                    end
         | 
| 38 | 
            +
                  end
         | 
| 39 | 
            +
                end
         | 
| 40 | 
            +
              end
         | 
| 41 | 
            +
            end
         | 
| 
            File without changes
         | 
| @@ -12,48 +12,41 @@ module WWW | |
| 12 12 |  | 
| 13 13 | 
             
                class Page
         | 
| 14 14 | 
             
                  def pretty_print(q)
         | 
| 15 | 
            -
                    parse_html
         | 
| 16 15 | 
             
                    q.object_group(self) {
         | 
| 17 16 | 
             
                      q.breakable
         | 
| 18 17 | 
             
                      q.group(1, '{url', '}') {q.breakable; q.pp uri }
         | 
| 19 18 | 
             
                      q.breakable
         | 
| 20 19 | 
             
                      q.group(1, '{meta', '}') {
         | 
| 21 | 
            -
                         | 
| 20 | 
            +
                        meta.each { |link| q.breakable; q.pp link }
         | 
| 22 21 | 
             
                      }
         | 
| 23 22 | 
             
                      q.breakable
         | 
| 24 23 | 
             
                      q.group(1, '{title', '}') { q.breakable; q.pp title }
         | 
| 25 24 | 
             
                      q.breakable
         | 
| 26 25 | 
             
                      q.group(1, '{iframes', '}') {
         | 
| 27 | 
            -
                         | 
| 26 | 
            +
                        iframes.each { |link| q.breakable; q.pp link }
         | 
| 28 27 | 
             
                      }
         | 
| 29 28 | 
             
                      q.breakable
         | 
| 30 29 | 
             
                      q.group(1, '{frames', '}') {
         | 
| 31 | 
            -
                         | 
| 30 | 
            +
                        frames.each { |link| q.breakable; q.pp link }
         | 
| 32 31 | 
             
                      }
         | 
| 33 32 | 
             
                      q.breakable
         | 
| 34 33 | 
             
                      q.group(1, '{links', '}') {
         | 
| 35 | 
            -
                         | 
| 34 | 
            +
                        links.each { |link| q.breakable; q.pp link }
         | 
| 36 35 | 
             
                      }
         | 
| 37 36 | 
             
                      q.breakable
         | 
| 38 37 | 
             
                      q.group(1, '{forms', '}') {
         | 
| 39 | 
            -
                         | 
| 38 | 
            +
                        forms.each { |form| q.breakable; q.pp form }
         | 
| 40 39 | 
             
                      }
         | 
| 41 40 | 
             
                    }
         | 
| 42 41 | 
             
                  end
         | 
| 43 | 
            -
                  if RUBY_VERSION > '1.8.4'
         | 
| 44 | 
            -
                    alias :inspect  :pretty_inspect
         | 
| 45 | 
            -
                  end
         | 
| 46 | 
            -
                end
         | 
| 47 42 |  | 
| 48 | 
            -
             | 
| 49 | 
            -
             | 
| 50 | 
            -
             | 
| 51 | 
            -
             | 
| 52 | 
            -
             | 
| 53 | 
            -
             | 
| 54 | 
            -
             | 
| 55 | 
            -
                  if RUBY_VERSION > '1.8.4'
         | 
| 56 | 
            -
                    alias :inspect  :pretty_inspect
         | 
| 43 | 
            +
                  class Link
         | 
| 44 | 
            +
                    def pretty_print(q)
         | 
| 45 | 
            +
                      q.object_group(self) {
         | 
| 46 | 
            +
                        q.breakable; q.pp text
         | 
| 47 | 
            +
                        q.breakable; q.pp href
         | 
| 48 | 
            +
                      }
         | 
| 49 | 
            +
                    end
         | 
| 57 50 | 
             
                  end
         | 
| 58 51 | 
             
                end
         | 
| 59 52 |  | 
| @@ -64,30 +57,30 @@ module WWW | |
| 64 57 | 
             
                      q.breakable; q.group(1, '{method', '}') { q.breakable; q.pp method }
         | 
| 65 58 | 
             
                      q.breakable; q.group(1, '{action', '}') { q.breakable; q.pp action }
         | 
| 66 59 | 
             
                      q.breakable; q.group(1, '{fields', '}') {
         | 
| 67 | 
            -
                         | 
| 60 | 
            +
                        fields.each do |field|
         | 
| 68 61 | 
             
                          q.breakable
         | 
| 69 62 | 
             
                          q.pp field
         | 
| 70 63 | 
             
                        end
         | 
| 71 64 | 
             
                      }
         | 
| 72 65 | 
             
                      q.breakable; q.group(1, '{radiobuttons', '}') {
         | 
| 73 | 
            -
                         | 
| 66 | 
            +
                        radiobuttons.each { |b| q.breakable; q.pp b }
         | 
| 74 67 | 
             
                      }
         | 
| 75 68 | 
             
                      q.breakable; q.group(1, '{checkboxes', '}') {
         | 
| 76 | 
            -
                         | 
| 69 | 
            +
                        checkboxes.each { |b| q.breakable; q.pp b }
         | 
| 77 70 | 
             
                      }
         | 
| 78 71 | 
             
                      q.breakable; q.group(1, '{file_uploads', '}') {
         | 
| 79 | 
            -
                         | 
| 72 | 
            +
                        file_uploads.each { |b| q.breakable; q.pp b }
         | 
| 80 73 | 
             
                      }
         | 
| 81 74 | 
             
                      q.breakable; q.group(1, '{buttons', '}') {
         | 
| 82 | 
            -
                         | 
| 75 | 
            +
                        buttons.each { |b| q.breakable; q.pp b }
         | 
| 83 76 | 
             
                      }
         | 
| 84 77 | 
             
                    }
         | 
| 85 78 | 
             
                  end
         | 
| 86 | 
            -
                end
         | 
| 87 79 |  | 
| 88 | 
            -
             | 
| 89 | 
            -
             | 
| 90 | 
            -
             | 
| 80 | 
            +
                  class RadioButton
         | 
| 81 | 
            +
                    def pretty_print_instance_variables
         | 
| 82 | 
            +
                      [:@checked, :@name, :@value]
         | 
| 83 | 
            +
                    end
         | 
| 91 84 | 
             
                  end
         | 
| 92 85 | 
             
                end
         | 
| 93 86 | 
             
              end
         | 
| 
            File without changes
         | 
| @@ -13,3 +13,22 @@ module Net | |
| 13 13 | 
             
              end
         | 
| 14 14 | 
             
            end
         | 
| 15 15 |  | 
| 16 | 
            +
            # Monkey patch for ruby 1.8.4
         | 
| 17 | 
            +
            unless RUBY_VERSION > "1.8.4"
         | 
| 18 | 
            +
            module Net # :nodoc:
         | 
| 19 | 
            +
              class HTTPResponse # :nodoc:
         | 
| 20 | 
            +
                CODE_TO_OBJ['500'] = HTTPInternalServerError
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
            end
         | 
| 23 | 
            +
            else
         | 
| 24 | 
            +
            module WWW
         | 
| 25 | 
            +
              class Mechanize
         | 
| 26 | 
            +
                class Page
         | 
| 27 | 
            +
                  alias :inspect  :pretty_inspect
         | 
| 28 | 
            +
                  class Link
         | 
| 29 | 
            +
                    alias :inspect  :pretty_inspect
         | 
| 30 | 
            +
                  end
         | 
| 31 | 
            +
                end
         | 
| 32 | 
            +
              end
         | 
| 33 | 
            +
            end
         | 
| 34 | 
            +
            end
         |