mechanize 0.1.2 → 0.1.3
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 +2 -2
- data/lib/mechanize/parsing.rb +12 -2
- 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.1.
|
9
|
+
Version = "0.1.3"
|
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")
|
@@ -112,7 +112,7 @@ class GlobalForm
|
|
112
112
|
@elements_node.each_recursive {|node|
|
113
113
|
case node.name.downcase
|
114
114
|
when 'input'
|
115
|
-
case node.attributes['type'].downcase
|
115
|
+
case (node.attributes['type'] || '').downcase
|
116
116
|
when 'text', 'password', 'hidden', 'checkbox'
|
117
117
|
@fields << Field.new(node.attributes['name'], node.attributes['value'])
|
118
118
|
when 'file'
|
data/lib/mechanize/parsing.rb
CHANGED
@@ -11,6 +11,12 @@ class REXML::Text
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
+
class REXML::Comment
|
15
|
+
def collect_text_recursively
|
16
|
+
[]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
14
20
|
module REXML::Node
|
15
21
|
|
16
22
|
# Visit all subnodes of +self+ recursively
|
@@ -131,11 +137,15 @@ end
|
|
131
137
|
# ]
|
132
138
|
#
|
133
139
|
|
134
|
-
def extract_from_table(root_node, headers)
|
140
|
+
def extract_from_table(root_node, headers, header_tags = %w(td th))
|
135
141
|
|
136
142
|
# extract and collect all header nodes
|
137
143
|
|
138
|
-
header_nodes = headers.collect { |header|
|
144
|
+
header_nodes = headers.collect { |header|
|
145
|
+
root_node.find_first_recursive {|node|
|
146
|
+
header_tags.include?(node.name.downcase) and header === node.all_text
|
147
|
+
}
|
148
|
+
}
|
139
149
|
|
140
150
|
raise "some headers not found" if header_nodes.compact.size < headers.size
|
141
151
|
|