mechanize 0.1.0 → 0.1.1
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/lib/mechanize.rb +1 -1
- data/lib/mechanize/parsing.rb +7 -1
- data/test/test_parsing.rb +24 -0
- metadata +6 -4
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.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")
|
data/lib/mechanize/parsing.rb
CHANGED
@@ -5,6 +5,12 @@
|
|
5
5
|
|
6
6
|
require 'rexml/rexml'
|
7
7
|
|
8
|
+
class REXML::Text
|
9
|
+
def collect_text_recursively
|
10
|
+
value()
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
8
14
|
module REXML::Node
|
9
15
|
|
10
16
|
# Visit all subnodes of +self+ recursively
|
@@ -52,7 +58,7 @@ module REXML::Node
|
|
52
58
|
# <i><b>abc</b>def</i>
|
53
59
|
|
54
60
|
def collect_text_recursively
|
55
|
-
|
61
|
+
map {|n| n.collect_text_recursively}
|
56
62
|
end
|
57
63
|
|
58
64
|
# Returns all text of all subnodes (recursivly), merged into one string.
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'rexml/document'
|
3
|
+
require '../lib/mechanize/parsing'
|
4
|
+
|
5
|
+
class TestParsing < Test::Unit::TestCase
|
6
|
+
def test_collect_text_recursively
|
7
|
+
assert_equal [["abc"], "def"], root_for("<i><b>abc</b>def</i>").collect_text_recursively
|
8
|
+
|
9
|
+
assert_equal ["asdf", ["abc"], "def"], root_for("<i>asdf<b>abc</b>def</i>").collect_text_recursively
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def root_for(str)
|
15
|
+
REXML::Document.new(str).root
|
16
|
+
end
|
17
|
+
=begin
|
18
|
+
def document_for(str)
|
19
|
+
parser = HTMLTree::XMLParser.new
|
20
|
+
parser.feed(str)
|
21
|
+
parser.document
|
22
|
+
end
|
23
|
+
=end
|
24
|
+
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: mechanize
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.1.
|
7
|
-
date: 2005-
|
6
|
+
version: 0.1.1
|
7
|
+
date: 2005-02-17
|
8
8
|
summary: Automated web-browsing.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -27,11 +27,12 @@ platform: ruby
|
|
27
27
|
authors:
|
28
28
|
- Michael Neumann
|
29
29
|
files:
|
30
|
-
-
|
30
|
+
- test
|
31
31
|
- lib
|
32
|
+
- examples
|
32
33
|
- mechanize.gemspec
|
33
34
|
- README
|
34
|
-
-
|
35
|
+
- test/test_parsing.rb
|
35
36
|
- lib/mechanize
|
36
37
|
- lib/mechanize.rb
|
37
38
|
- lib/mechanize/net-overrides
|
@@ -40,6 +41,7 @@ files:
|
|
40
41
|
- lib/mechanize/net-overrides/net/protocol.rb
|
41
42
|
- lib/mechanize/net-overrides/net/http.rb
|
42
43
|
- lib/mechanize/net-overrides/net/https.rb
|
44
|
+
- examples/rubyforge.rb
|
43
45
|
test_files: []
|
44
46
|
rdoc_options: []
|
45
47
|
extra_rdoc_files: []
|