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.
- data/Manifest.txt +55 -48
- data/Rakefile +12 -22
- data/lib/mechanize.rb +618 -4
- data/lib/mechanize/chain.rb +33 -0
- data/lib/mechanize/chain/auth_headers.rb +78 -0
- data/lib/mechanize/chain/body_decoding_handler.rb +46 -0
- data/lib/mechanize/chain/connection_resolver.rb +76 -0
- data/lib/mechanize/chain/custom_headers.rb +21 -0
- data/lib/{www/mechanize → mechanize}/chain/handler.rb +1 -1
- data/lib/mechanize/chain/header_resolver.rb +51 -0
- data/lib/mechanize/chain/parameter_resolver.rb +22 -0
- data/lib/{www/mechanize → mechanize}/chain/post_connect_hook.rb +0 -0
- data/lib/mechanize/chain/pre_connect_hook.rb +20 -0
- data/lib/mechanize/chain/request_resolver.rb +30 -0
- data/lib/mechanize/chain/response_body_parser.rb +38 -0
- data/lib/mechanize/chain/response_header_handler.rb +48 -0
- data/lib/mechanize/chain/response_reader.rb +39 -0
- data/lib/mechanize/chain/ssl_resolver.rb +40 -0
- data/lib/mechanize/chain/uri_resolver.rb +75 -0
- data/lib/mechanize/content_type_error.rb +14 -0
- data/lib/mechanize/cookie.rb +70 -0
- data/lib/mechanize/cookie_jar.rb +188 -0
- data/lib/mechanize/file.rb +71 -0
- data/lib/mechanize/file_response.rb +60 -0
- data/lib/mechanize/file_saver.rb +37 -0
- data/lib/mechanize/form.rb +378 -0
- data/lib/mechanize/form/button.rb +9 -0
- data/lib/mechanize/form/check_box.rb +11 -0
- data/lib/mechanize/form/field.rb +30 -0
- data/lib/mechanize/form/file_upload.rb +22 -0
- data/lib/mechanize/form/image_button.rb +21 -0
- data/lib/mechanize/form/multi_select_list.rb +67 -0
- data/lib/mechanize/form/option.rb +49 -0
- data/lib/mechanize/form/radio_button.rb +49 -0
- data/lib/mechanize/form/select_list.rb +43 -0
- data/lib/mechanize/headers.rb +11 -0
- data/lib/mechanize/history.rb +65 -0
- data/lib/mechanize/inspect.rb +88 -0
- data/lib/{www/mechanize → mechanize}/monkey_patch.rb +4 -6
- data/lib/mechanize/page.rb +206 -0
- data/lib/mechanize/page/base.rb +8 -0
- data/lib/mechanize/page/frame.rb +20 -0
- data/lib/mechanize/page/image.rb +26 -0
- data/lib/mechanize/page/label.rb +20 -0
- data/lib/mechanize/page/link.rb +48 -0
- data/lib/mechanize/page/meta.rb +50 -0
- data/lib/mechanize/pluggable_parsers.rb +101 -0
- data/lib/mechanize/redirect_limit_reached_error.rb +16 -0
- data/lib/mechanize/redirect_not_get_or_head_error.rb +18 -0
- data/lib/mechanize/response_code_error.rb +22 -0
- data/lib/mechanize/unsupported_scheme_error.rb +8 -0
- data/lib/mechanize/util.rb +67 -0
- data/mechanize.gemspec +8 -8
- data/test/chain/test_argument_validator.rb +2 -2
- data/test/chain/test_auth_headers.rb +2 -2
- data/test/chain/test_custom_headers.rb +2 -2
- data/test/chain/test_header_resolver.rb +3 -3
- data/test/chain/test_parameter_resolver.rb +4 -4
- data/test/chain/test_request_resolver.rb +4 -4
- data/test/chain/test_response_reader.rb +3 -3
- data/test/helper.rb +1 -1
- data/test/htdocs/tc_bad_charset.html +9 -0
- data/test/htdocs/tc_charset.html +6 -0
- data/test/htdocs/test_bad_encoding.html +52 -0
- data/test/test_authenticate.rb +3 -3
- data/test/test_bad_links.rb +1 -1
- data/test/test_blank_form.rb +1 -1
- data/test/test_checkboxes.rb +1 -1
- data/test/test_content_type.rb +2 -2
- data/test/test_cookie_class.rb +12 -12
- data/test/test_cookie_jar.rb +13 -13
- data/test/test_cookies.rb +1 -1
- data/test/test_encoded_links.rb +1 -1
- data/test/test_errors.rb +2 -2
- data/test/test_follow_meta.rb +3 -3
- data/test/test_form_action.rb +1 -1
- data/test/test_form_as_hash.rb +1 -1
- data/test/test_form_button.rb +2 -2
- data/test/test_form_no_inputname.rb +1 -1
- data/test/test_forms.rb +1 -1
- data/test/test_frames.rb +1 -1
- data/test/test_get_headers.rb +1 -1
- data/test/test_gzipping.rb +2 -2
- data/test/test_hash_api.rb +1 -1
- data/test/test_history.rb +7 -7
- data/test/test_history_added.rb +1 -1
- data/test/test_html_unscape_forms.rb +7 -7
- data/test/test_if_modified_since.rb +1 -1
- data/test/test_keep_alive.rb +1 -1
- data/test/test_links.rb +2 -2
- data/test/test_mech.rb +2 -2
- data/test/test_mechanize_file.rb +7 -7
- data/test/test_meta.rb +2 -2
- data/test/test_multi_select.rb +1 -1
- data/test/test_no_attributes.rb +1 -1
- data/test/test_option.rb +1 -1
- data/test/test_page.rb +3 -3
- data/test/test_pluggable_parser.rb +14 -14
- data/test/test_post_form.rb +1 -1
- data/test/test_pretty_print.rb +2 -2
- data/test/test_radiobutton.rb +1 -1
- data/test/test_redirect_limit_reached.rb +1 -3
- data/test/test_redirect_verb_handling.rb +1 -3
- data/test/test_referer.rb +1 -1
- data/test/test_relative_links.rb +1 -1
- data/test/test_request.rb +1 -1
- data/test/test_response_code.rb +3 -3
- data/test/test_save_file.rb +3 -3
- data/test/test_scheme.rb +3 -3
- data/test/test_select.rb +2 -2
- data/test/test_select_all.rb +1 -1
- data/test/test_select_none.rb +1 -1
- data/test/test_select_noopts.rb +1 -1
- data/test/test_set_fields.rb +1 -1
- data/test/test_ssl_server.rb +1 -1
- data/test/test_subclass.rb +1 -1
- data/test/test_textarea.rb +1 -1
- data/test/test_upload.rb +1 -1
- data/test/test_verbs.rb +1 -1
- metadata +61 -56
- data/lib/www/mechanize.rb +0 -619
- data/lib/www/mechanize/chain.rb +0 -34
- data/lib/www/mechanize/chain/auth_headers.rb +0 -80
- data/lib/www/mechanize/chain/body_decoding_handler.rb +0 -48
- data/lib/www/mechanize/chain/connection_resolver.rb +0 -78
- data/lib/www/mechanize/chain/custom_headers.rb +0 -23
- data/lib/www/mechanize/chain/header_resolver.rb +0 -53
- data/lib/www/mechanize/chain/parameter_resolver.rb +0 -24
- data/lib/www/mechanize/chain/pre_connect_hook.rb +0 -22
- data/lib/www/mechanize/chain/request_resolver.rb +0 -32
- data/lib/www/mechanize/chain/response_body_parser.rb +0 -40
- data/lib/www/mechanize/chain/response_header_handler.rb +0 -50
- data/lib/www/mechanize/chain/response_reader.rb +0 -41
- data/lib/www/mechanize/chain/ssl_resolver.rb +0 -42
- data/lib/www/mechanize/chain/uri_resolver.rb +0 -77
- data/lib/www/mechanize/content_type_error.rb +0 -16
- data/lib/www/mechanize/cookie.rb +0 -72
- data/lib/www/mechanize/cookie_jar.rb +0 -191
- data/lib/www/mechanize/file.rb +0 -73
- data/lib/www/mechanize/file_response.rb +0 -62
- data/lib/www/mechanize/file_saver.rb +0 -39
- data/lib/www/mechanize/form.rb +0 -360
- data/lib/www/mechanize/form/button.rb +0 -8
- data/lib/www/mechanize/form/check_box.rb +0 -13
- data/lib/www/mechanize/form/field.rb +0 -28
- data/lib/www/mechanize/form/file_upload.rb +0 -24
- data/lib/www/mechanize/form/image_button.rb +0 -23
- data/lib/www/mechanize/form/multi_select_list.rb +0 -69
- data/lib/www/mechanize/form/option.rb +0 -51
- data/lib/www/mechanize/form/radio_button.rb +0 -38
- data/lib/www/mechanize/form/select_list.rb +0 -45
- data/lib/www/mechanize/headers.rb +0 -12
- data/lib/www/mechanize/history.rb +0 -67
- data/lib/www/mechanize/inspect.rb +0 -90
- data/lib/www/mechanize/page.rb +0 -181
- data/lib/www/mechanize/page/base.rb +0 -10
- data/lib/www/mechanize/page/frame.rb +0 -22
- data/lib/www/mechanize/page/link.rb +0 -50
- data/lib/www/mechanize/page/meta.rb +0 -51
- data/lib/www/mechanize/pluggable_parsers.rb +0 -103
- data/lib/www/mechanize/redirect_limit_reached_error.rb +0 -18
- data/lib/www/mechanize/redirect_not_get_or_head_error.rb +0 -20
- data/lib/www/mechanize/response_code_error.rb +0 -25
- data/lib/www/mechanize/unsupported_scheme_error.rb +0 -10
- data/lib/www/mechanize/util.rb +0 -76
@@ -0,0 +1,11 @@
|
|
1
|
+
class Mechanize
|
2
|
+
class Form
|
3
|
+
# This class represents a check box found in a Form. To activate the
|
4
|
+
# CheckBox in the Form, set the checked method to true.
|
5
|
+
class CheckBox < RadioButton
|
6
|
+
def query_value
|
7
|
+
[[@name, @value || "on"]]
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
class Mechanize
|
2
|
+
class Form
|
3
|
+
# This class represents a field in a form. It handles the following input
|
4
|
+
# tags found in a form:
|
5
|
+
# text, password, hidden, int, textarea
|
6
|
+
#
|
7
|
+
# To set the value of a field, just use the value method:
|
8
|
+
# field.value = "foo"
|
9
|
+
class Field
|
10
|
+
attr_accessor :name, :value
|
11
|
+
|
12
|
+
def initialize(name, value)
|
13
|
+
@name = Util.html_unescape(name)
|
14
|
+
@value = if value.is_a? String
|
15
|
+
Util.html_unescape(value)
|
16
|
+
else
|
17
|
+
value
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def query_value
|
22
|
+
[[@name, @value || '']]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class Text < Field; end
|
27
|
+
class Textarea < Field; end
|
28
|
+
class Hidden < Field; end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class Mechanize
|
2
|
+
class Form
|
3
|
+
# This class represents a file upload field found in a form. To use this
|
4
|
+
# class, set WWW::FileUpload#file_data= to the data of the file you want
|
5
|
+
# to upload and WWW::FileUpload#mime_type= to the appropriate mime type
|
6
|
+
# of the file.
|
7
|
+
# See the example in EXAMPLES[link://files/EXAMPLES_txt.html]
|
8
|
+
class FileUpload < Field
|
9
|
+
attr_accessor :file_name # File name
|
10
|
+
attr_accessor :mime_type # Mime Type (Optional)
|
11
|
+
|
12
|
+
alias :file_data :value
|
13
|
+
alias :file_data= :value=
|
14
|
+
|
15
|
+
def initialize(name, file_name)
|
16
|
+
@file_name = Util.html_unescape(file_name)
|
17
|
+
@file_data = nil
|
18
|
+
super(name, @file_data)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class Mechanize
|
2
|
+
class Form
|
3
|
+
# This class represents an image button in a form. Use the x and y methods
|
4
|
+
# to set the x and y positions for where the mouse "clicked".
|
5
|
+
class ImageButton < Button
|
6
|
+
attr_accessor :x, :y
|
7
|
+
|
8
|
+
def initialize(name, value)
|
9
|
+
@x = nil
|
10
|
+
@y = nil
|
11
|
+
super(name, value)
|
12
|
+
end
|
13
|
+
|
14
|
+
def query_value
|
15
|
+
super <<
|
16
|
+
[@name + ".x", (@x || 0).to_s] <<
|
17
|
+
[@name + ".y", (@y || 0).to_s]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
class Mechanize
|
2
|
+
class Form
|
3
|
+
# This class represents a select list where multiple values can be selected.
|
4
|
+
# MultiSelectList#value= accepts an array, and those values are used as
|
5
|
+
# values for the select list. For example, to select multiple values,
|
6
|
+
# simply do this:
|
7
|
+
# list.value = ['one', 'two']
|
8
|
+
# Single values are still supported, so these two are the same:
|
9
|
+
# list.value = ['one']
|
10
|
+
# list.value = 'one'
|
11
|
+
class MultiSelectList < Field
|
12
|
+
attr_accessor :options
|
13
|
+
|
14
|
+
def initialize(name, node)
|
15
|
+
value = []
|
16
|
+
@options = []
|
17
|
+
|
18
|
+
# parse
|
19
|
+
node.search('option').each do |n|
|
20
|
+
option = Option.new(n, self)
|
21
|
+
@options << option
|
22
|
+
end
|
23
|
+
super(name, value)
|
24
|
+
end
|
25
|
+
|
26
|
+
def query_value
|
27
|
+
value ? value.collect { |v| [name, v] } : ''
|
28
|
+
end
|
29
|
+
|
30
|
+
# Select no options
|
31
|
+
def select_none
|
32
|
+
@value = []
|
33
|
+
options.each { |o| o.untick }
|
34
|
+
end
|
35
|
+
|
36
|
+
# Select all options
|
37
|
+
def select_all
|
38
|
+
@value = []
|
39
|
+
options.each { |o| o.tick }
|
40
|
+
end
|
41
|
+
|
42
|
+
# Get a list of all selected options
|
43
|
+
def selected_options
|
44
|
+
@options.find_all { |o| o.selected? }
|
45
|
+
end
|
46
|
+
|
47
|
+
def value=(values)
|
48
|
+
select_none
|
49
|
+
[values].flatten.each do |value|
|
50
|
+
option = options.find { |o| o.value == value }
|
51
|
+
if option.nil?
|
52
|
+
@value.push(value)
|
53
|
+
else
|
54
|
+
option.select
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def value
|
60
|
+
value = []
|
61
|
+
value.push(*@value)
|
62
|
+
value.push(*selected_options.collect { |o| o.value })
|
63
|
+
value
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
class Mechanize
|
2
|
+
class Form
|
3
|
+
# This class contains option an option found within SelectList. A
|
4
|
+
# SelectList can have many Option classes associated with it. An option
|
5
|
+
# can be selected by calling Option#tick, or Option#click. For example,
|
6
|
+
# select the first option in a list:
|
7
|
+
# select_list.first.tick
|
8
|
+
class Option
|
9
|
+
attr_reader :value, :selected, :text, :select_list
|
10
|
+
|
11
|
+
alias :to_s :value
|
12
|
+
alias :selected? :selected
|
13
|
+
|
14
|
+
def initialize(node, select_list)
|
15
|
+
@text = node.inner_text
|
16
|
+
@value = Util.html_unescape(node['value'] || node.inner_text)
|
17
|
+
@selected = node.has_attribute? 'selected'
|
18
|
+
@select_list = select_list # The select list this option belongs to
|
19
|
+
end
|
20
|
+
|
21
|
+
# Select this option
|
22
|
+
def select
|
23
|
+
unselect_peers
|
24
|
+
@selected = true
|
25
|
+
end
|
26
|
+
|
27
|
+
# Unselect this option
|
28
|
+
def unselect
|
29
|
+
@selected = false
|
30
|
+
end
|
31
|
+
|
32
|
+
alias :tick :select
|
33
|
+
alias :untick :unselect
|
34
|
+
|
35
|
+
# Toggle the selection value of this option
|
36
|
+
def click
|
37
|
+
unselect_peers
|
38
|
+
@selected = !@selected
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
def unselect_peers
|
43
|
+
if @select_list.instance_of? SelectList
|
44
|
+
@select_list.select_none
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
class Mechanize
|
2
|
+
class Form
|
3
|
+
# This class represents a radio button found in a Form. To activate the
|
4
|
+
# RadioButton in the Form, set the checked method to true.
|
5
|
+
class RadioButton < Field
|
6
|
+
attr_accessor :checked
|
7
|
+
|
8
|
+
def initialize(name, value, checked, form, node)
|
9
|
+
@checked = checked
|
10
|
+
@form = form
|
11
|
+
@node = node
|
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 ? uncheck : check
|
26
|
+
end
|
27
|
+
|
28
|
+
def label
|
29
|
+
(id = self['id']) && @form.page.labels_hash[id] || nil
|
30
|
+
end
|
31
|
+
|
32
|
+
def text
|
33
|
+
label.text rescue nil
|
34
|
+
end
|
35
|
+
|
36
|
+
def [](key)
|
37
|
+
@node[key]
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
def uncheck_peers
|
42
|
+
@form.radiobuttons_with(:name => name).each do |b|
|
43
|
+
next if b.value == value
|
44
|
+
b.uncheck
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
class Mechanize
|
2
|
+
class Form
|
3
|
+
# This class represents a select list or drop down box in a Form. Set the
|
4
|
+
# value for the list by calling SelectList#value=. SelectList contains a
|
5
|
+
# list of Option that were found. After finding the correct option, set
|
6
|
+
# the select lists value to the option value:
|
7
|
+
# selectlist.value = selectlist.options.first.value
|
8
|
+
# Options can also be selected by "clicking" or selecting them. See Option
|
9
|
+
class SelectList < MultiSelectList
|
10
|
+
def initialize(name, node)
|
11
|
+
super(name, node)
|
12
|
+
if selected_options.length > 1
|
13
|
+
selected_options.reverse[1..selected_options.length].each do |o|
|
14
|
+
o.unselect
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def value
|
20
|
+
value = super
|
21
|
+
if value.length > 0
|
22
|
+
value.last
|
23
|
+
elsif @options.length > 0
|
24
|
+
@options.first.value
|
25
|
+
else
|
26
|
+
nil
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def value=(new)
|
31
|
+
if new != new.to_s and new.respond_to? :first
|
32
|
+
super([new.first])
|
33
|
+
else
|
34
|
+
super([new.to_s])
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def query_value
|
39
|
+
value ? [[name, value]] : nil
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
class Mechanize
|
2
|
+
##
|
3
|
+
# This class manages history for your mechanize object.
|
4
|
+
class History < Array
|
5
|
+
attr_accessor :max_size
|
6
|
+
|
7
|
+
def initialize(max_size = nil)
|
8
|
+
@max_size = max_size
|
9
|
+
@history_index = {}
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize_copy(orig)
|
13
|
+
super
|
14
|
+
@history_index = orig.instance_variable_get(:@history_index).dup
|
15
|
+
end
|
16
|
+
|
17
|
+
def push(page, uri = nil)
|
18
|
+
super(page)
|
19
|
+
@history_index[(uri ? uri : page.uri).to_s] = page
|
20
|
+
if @max_size && self.length > @max_size
|
21
|
+
while self.length > @max_size
|
22
|
+
self.shift
|
23
|
+
end
|
24
|
+
end
|
25
|
+
self
|
26
|
+
end
|
27
|
+
alias :<< :push
|
28
|
+
|
29
|
+
def visited?(url)
|
30
|
+
! visited_page(url).nil?
|
31
|
+
end
|
32
|
+
|
33
|
+
def visited_page(url)
|
34
|
+
@history_index[(url.respond_to?(:uri) ? url.uri : url).to_s]
|
35
|
+
end
|
36
|
+
|
37
|
+
def clear
|
38
|
+
@history_index.clear
|
39
|
+
super
|
40
|
+
end
|
41
|
+
|
42
|
+
def shift
|
43
|
+
return nil if length == 0
|
44
|
+
page = self[0]
|
45
|
+
self[0] = nil
|
46
|
+
super
|
47
|
+
remove_from_index(page)
|
48
|
+
page
|
49
|
+
end
|
50
|
+
|
51
|
+
def pop
|
52
|
+
return nil if length == 0
|
53
|
+
page = super
|
54
|
+
remove_from_index(page)
|
55
|
+
page
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
def remove_from_index(page)
|
60
|
+
@history_index.each do |k,v|
|
61
|
+
@history_index.delete(k) if v == page
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'pp'
|
2
|
+
|
3
|
+
# :stopdoc:
|
4
|
+
class Mechanize
|
5
|
+
def pretty_print(q)
|
6
|
+
q.object_group(self) {
|
7
|
+
q.breakable
|
8
|
+
q.pp cookie_jar
|
9
|
+
q.breakable
|
10
|
+
q.pp current_page
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
14
|
+
class Page
|
15
|
+
def pretty_print(q)
|
16
|
+
q.object_group(self) {
|
17
|
+
q.breakable
|
18
|
+
q.group(1, '{url', '}') {q.breakable; q.pp uri }
|
19
|
+
q.breakable
|
20
|
+
q.group(1, '{meta', '}') {
|
21
|
+
meta.each { |link| q.breakable; q.pp link }
|
22
|
+
}
|
23
|
+
q.breakable
|
24
|
+
q.group(1, '{title', '}') { q.breakable; q.pp title }
|
25
|
+
q.breakable
|
26
|
+
q.group(1, '{iframes', '}') {
|
27
|
+
iframes.each { |link| q.breakable; q.pp link }
|
28
|
+
}
|
29
|
+
q.breakable
|
30
|
+
q.group(1, '{frames', '}') {
|
31
|
+
frames.each { |link| q.breakable; q.pp link }
|
32
|
+
}
|
33
|
+
q.breakable
|
34
|
+
q.group(1, '{links', '}') {
|
35
|
+
links.each { |link| q.breakable; q.pp link }
|
36
|
+
}
|
37
|
+
q.breakable
|
38
|
+
q.group(1, '{forms', '}') {
|
39
|
+
forms.each { |form| q.breakable; q.pp form }
|
40
|
+
}
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
44
|
+
class Link
|
45
|
+
def pretty_print(q)
|
46
|
+
q.object_group(self) {
|
47
|
+
q.breakable; q.pp text
|
48
|
+
q.breakable; q.pp href
|
49
|
+
}
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
class Form
|
55
|
+
def pretty_print(q)
|
56
|
+
q.object_group(self) {
|
57
|
+
q.breakable; q.group(1, '{name', '}') { q.breakable; q.pp name }
|
58
|
+
q.breakable; q.group(1, '{method', '}') { q.breakable; q.pp method }
|
59
|
+
q.breakable; q.group(1, '{action', '}') { q.breakable; q.pp action }
|
60
|
+
q.breakable; q.group(1, '{fields', '}') {
|
61
|
+
fields.each do |field|
|
62
|
+
q.breakable
|
63
|
+
q.pp field
|
64
|
+
end
|
65
|
+
}
|
66
|
+
q.breakable; q.group(1, '{radiobuttons', '}') {
|
67
|
+
radiobuttons.each { |b| q.breakable; q.pp b }
|
68
|
+
}
|
69
|
+
q.breakable; q.group(1, '{checkboxes', '}') {
|
70
|
+
checkboxes.each { |b| q.breakable; q.pp b }
|
71
|
+
}
|
72
|
+
q.breakable; q.group(1, '{file_uploads', '}') {
|
73
|
+
file_uploads.each { |b| q.breakable; q.pp b }
|
74
|
+
}
|
75
|
+
q.breakable; q.group(1, '{buttons', '}') {
|
76
|
+
buttons.each { |b| q.breakable; q.pp b }
|
77
|
+
}
|
78
|
+
}
|
79
|
+
end
|
80
|
+
|
81
|
+
class RadioButton
|
82
|
+
def pretty_print_instance_variables
|
83
|
+
[:@checked, :@name, :@value]
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
# :startdoc:
|