mechanize 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of mechanize might be problematic. Click here for more details.
- data/lib/mechanize.rb +20 -3
- metadata +2 -2
data/lib/mechanize.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
# set cookies (I might be wrong), does not automatically redirect and has
|
7
7
|
# problems with some html documents.
|
8
8
|
|
9
|
-
Version = "0.3.
|
9
|
+
Version = "0.3.1"
|
10
10
|
|
11
11
|
# required due to the missing get_fields method in Ruby 1.8.2
|
12
12
|
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), "mechanize", "net-overrides")
|
@@ -62,6 +62,10 @@ class Button
|
|
62
62
|
@name, @value = name, value
|
63
63
|
end
|
64
64
|
|
65
|
+
def add_to_query(query)
|
66
|
+
query[@name] = @value || "" if @name
|
67
|
+
end
|
68
|
+
|
65
69
|
# Returns an array of Button objects
|
66
70
|
def self.extract_all_from(root_node)
|
67
71
|
buttons = []
|
@@ -75,6 +79,18 @@ class Button
|
|
75
79
|
end
|
76
80
|
end
|
77
81
|
|
82
|
+
class ImageButton < Button
|
83
|
+
attr_accessor :x, :y
|
84
|
+
|
85
|
+
def add_to_query(query)
|
86
|
+
if @name
|
87
|
+
query[@name] = @value || ""
|
88
|
+
query[@name+".x"] = (@x || "0").to_s
|
89
|
+
query[@name+".y"] = (@y || "0").to_s
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
78
94
|
class RadioButton
|
79
95
|
attr_accessor :name, :value, :checked
|
80
96
|
|
@@ -210,6 +226,8 @@ class GlobalForm
|
|
210
226
|
@file_uploads << FileUpload.new(node.attributes['name'], node.attributes['value'])
|
211
227
|
when 'submit'
|
212
228
|
@buttons << Button.new(node.attributes['name'], node.attributes['value'])
|
229
|
+
when 'image'
|
230
|
+
@buttons << ImageButton.new(node.attributes['name'], node.attributes['value'])
|
213
231
|
end
|
214
232
|
when 'textarea'
|
215
233
|
@fields << Field.new(node.attributes['name'], node.all_text)
|
@@ -391,8 +409,7 @@ class Mechanize
|
|
391
409
|
|
392
410
|
def submit(form, button=nil)
|
393
411
|
query = form.build_query
|
394
|
-
|
395
|
-
query[button.name] = button.value || "" if button and button.name
|
412
|
+
button.add_to_query(query) if button
|
396
413
|
|
397
414
|
uri = to_absolute_uri(form.action)
|
398
415
|
case form.method.upcase
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: mechanize
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.3.
|
7
|
-
date: 2005-
|
6
|
+
version: 0.3.1
|
7
|
+
date: 2005-08-01 00:00:00 +02:00
|
8
8
|
summary: Automated web-browsing.
|
9
9
|
require_paths:
|
10
10
|
- lib
|