scrubyt 0.2.8 → 0.3.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.
- data/CHANGELOG +32 -2
- data/Rakefile +25 -20
- data/lib/scrubyt.rb +24 -5
- data/lib/scrubyt/core/navigation/fetch_action.rb +76 -42
- data/lib/scrubyt/core/navigation/navigation_actions.rb +24 -6
- data/lib/scrubyt/core/scraping/filters/base_filter.rb +5 -5
- data/lib/scrubyt/core/scraping/filters/detail_page_filter.rb +2 -2
- data/lib/scrubyt/core/scraping/filters/download_filter.rb +2 -1
- data/lib/scrubyt/core/scraping/filters/html_subtree_filter.rb +7 -2
- data/lib/scrubyt/core/scraping/filters/tree_filter.rb +37 -12
- data/lib/scrubyt/core/scraping/pattern.rb +82 -90
- data/lib/scrubyt/core/scraping/pre_filter_document.rb +2 -1
- data/lib/scrubyt/core/shared/evaluation_context.rb +14 -37
- data/lib/scrubyt/core/shared/extractor.rb +55 -54
- data/lib/scrubyt/logging.rb +16 -0
- data/lib/scrubyt/output/export.rb +1 -1
- data/lib/scrubyt/output/post_processor.rb +6 -5
- data/lib/scrubyt/output/result.rb +1 -0
- data/lib/scrubyt/output/result_dumper.rb +4 -3
- data/lib/scrubyt/output/result_node.rb +73 -0
- data/lib/scrubyt/output/scrubyt_result.rb +28 -0
- data/lib/scrubyt/utils/ruby_extensions.rb +8 -0
- data/lib/scrubyt/utils/simple_example_lookup.rb +14 -1
- data/lib/scrubyt/utils/xpathutils.rb +11 -0
- metadata +7 -12
- data/test/unittests/constraint_test.rb +0 -107
- data/test/unittests/extractor_test.rb +0 -91
- data/test/unittests/filter_test.rb +0 -79
- data/test/unittests/input/constraint_test.html +0 -55
- data/test/unittests/input/test.html +0 -39
- data/test/unittests/pattern_test.rb +0 -27
- data/test/unittests/simple_example_lookup_test.rb +0 -68
- data/test/unittests/xpathutils_test.rb +0 -152
@@ -0,0 +1,28 @@
|
|
1
|
+
module Scrubyt
|
2
|
+
class ScrubytResult < ResultNode
|
3
|
+
attr_accessor :root_pattern
|
4
|
+
|
5
|
+
def export(arg1, output_file_name=nil, extractor_result_file_name=nil)
|
6
|
+
# require 'scrubyt/output/export_old'; Scrubyt::ExportOld.export(arg1, self, output_file_name, extractor_result_file_name) ; return
|
7
|
+
if File.exists? arg1
|
8
|
+
old_export(arg1, output_file_name, extractor_result_file_name)
|
9
|
+
else
|
10
|
+
new_export(arg1, output_file_name, extractor_result_file_name)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def show_stats
|
15
|
+
#Implement me...
|
16
|
+
end
|
17
|
+
|
18
|
+
def old_export(input_file, output_file_name=nil, extractor_result_file_name=nil)
|
19
|
+
contents = open(input_file).read
|
20
|
+
wrapper_name = contents.scan(/\s+(.+)\s+=.*Extractor\.define.*/)[0][0]
|
21
|
+
Scrubyt::Export.export(@root_pattern, wrapper_name, output_file_name, extractor_result_file_name)
|
22
|
+
end
|
23
|
+
|
24
|
+
def new_export(wrapper_name, output_file_name=nil, extractor_result_file_name=nil)
|
25
|
+
Scrubyt::Export.export(@root_pattern, wrapper_name, output_file_name, extractor_result_file_name)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -59,6 +59,14 @@ module Math
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
+
#just some hack here to allow current examples' syntax:
|
63
|
+
#table_data.to_xml.write(open('result.xml', 'w'), 1)
|
64
|
+
class String
|
65
|
+
def write(stringio, add_indent=0)
|
66
|
+
stringio.write((self.split("\n").collect { |line| (' ' * add_indent) + line }).join("\n"))
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
62
70
|
class Array
|
63
71
|
def to_sexp
|
64
72
|
[:array, *to_sexp_array]
|
@@ -16,8 +16,21 @@ module Scrubyt
|
|
16
16
|
#In this case, <a>'s text is considered to be "Bon nuit, monsieur"
|
17
17
|
def self.find_node_from_text(doc, text, next_link=false, index = 0)
|
18
18
|
text.gsub!('»', '»')
|
19
|
+
#Process immediate attribute extraction (like "go to google.com[@href]")
|
20
|
+
if text =~ /.+\/@.+$/
|
21
|
+
text = text.scan(/^(.+?)\/@.+$/)[0][0]
|
22
|
+
elsif text =~ /.+\[\d+\]$/
|
23
|
+
res = text.scan(/(.+)\[(\d+)\]$/)
|
24
|
+
text = res[0][0]
|
25
|
+
index = res[0][1].to_i
|
26
|
+
elsif text =~ /.+\[.+\]$/
|
27
|
+
final_element_name = text.scan(/^(.+?)\[/)[0][0]
|
28
|
+
text = text.scan(/\[(.+?)\]/)[0][0]
|
29
|
+
end
|
19
30
|
text = Regexp.escape(text) if text.is_a? String
|
20
|
-
SharedUtils.traverse_for_match(doc
|
31
|
+
result = SharedUtils.traverse_for_match(doc,/^#{text}$/)[index]
|
32
|
+
result = XPathUtils.traverse_up_until_name(result,final_element_name) if final_element_name
|
33
|
+
result
|
21
34
|
end
|
22
35
|
end #End of class SimpleExampleLookup
|
23
36
|
end #End of module Scrubyt
|
@@ -94,6 +94,11 @@ module Scrubyt
|
|
94
94
|
#most typically the user will need the 0th - but if this is not the
|
95
95
|
#case, there is the possibility to override this
|
96
96
|
def self.find_image(doc, example, index=0)
|
97
|
+
if example =~ /\.(jpg|png|gif|jpeg)(\[\d+\])$/
|
98
|
+
res = example.scan(/(.+)\[(\d+)\]$/)
|
99
|
+
example = res[0][0]
|
100
|
+
index = res[0][1].to_i
|
101
|
+
end
|
97
102
|
(doc/"//img[@src='#{example}']")[index]
|
98
103
|
end
|
99
104
|
|
@@ -136,6 +141,12 @@ module Scrubyt
|
|
136
141
|
"/" + original_child_xpath_parts[i..-1].join('/')
|
137
142
|
end
|
138
143
|
|
144
|
+
def self.to_full_XPath(doc, xpath, generalize)
|
145
|
+
elem = doc/xpath
|
146
|
+
elem = elem.map[0] if elem.is_a? Hpricot::Elements
|
147
|
+
XPathUtils.generate_XPath(elem, nil, generalize)
|
148
|
+
end
|
149
|
+
|
139
150
|
private
|
140
151
|
#Find the index of the child inside the parent
|
141
152
|
#For example:
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: scrubyt
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2007-
|
6
|
+
version: 0.3.0
|
7
|
+
date: 2007-05-28 00:00:00 +02:00
|
8
8
|
summary: A powerful Web-scraping framework
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -34,10 +34,13 @@ files:
|
|
34
34
|
- CHANGELOG
|
35
35
|
- Rakefile
|
36
36
|
- lib/scrubyt.rb
|
37
|
+
- lib/scrubyt/logging.rb
|
37
38
|
- lib/scrubyt/output/result_dumper.rb
|
38
39
|
- lib/scrubyt/output/result.rb
|
39
40
|
- lib/scrubyt/output/export.rb
|
40
41
|
- lib/scrubyt/output/post_processor.rb
|
42
|
+
- lib/scrubyt/output/result_node.rb
|
43
|
+
- lib/scrubyt/output/scrubyt_result.rb
|
41
44
|
- lib/scrubyt/utils/compound_example_lookup.rb
|
42
45
|
- lib/scrubyt/utils/simple_example_lookup.rb
|
43
46
|
- lib/scrubyt/utils/ruby_extensions.rb
|
@@ -61,16 +64,8 @@ files:
|
|
61
64
|
- lib/scrubyt/core/shared/u_r_i_builder.rb
|
62
65
|
- lib/scrubyt/core/shared/extractor.rb
|
63
66
|
- lib/scrubyt/core/shared/evaluation_context.rb
|
64
|
-
test_files:
|
65
|
-
|
66
|
-
- test/unittests/constraint_test.rb
|
67
|
-
- test/unittests/filter_test.rb
|
68
|
-
- test/unittests/xpathutils_test.rb
|
69
|
-
- test/unittests/extractor_test.rb
|
70
|
-
- test/unittests/pattern_test.rb
|
71
|
-
- test/unittests/simple_example_lookup_test.rb
|
72
|
-
- test/unittests/input/test.html
|
73
|
-
- test/unittests/input/constraint_test.html
|
67
|
+
test_files: []
|
68
|
+
|
74
69
|
rdoc_options: []
|
75
70
|
|
76
71
|
extra_rdoc_files: []
|
@@ -1,107 +0,0 @@
|
|
1
|
-
require 'scrubyt'
|
2
|
-
require 'test/unit'
|
3
|
-
|
4
|
-
class ConstraintTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
def test_presence_of_attribute_constraints
|
7
|
-
data = Scrubyt::Extractor.define do
|
8
|
-
fetch File.join(File.dirname(__FILE__), "input/constraint_test.html")
|
9
|
-
|
10
|
-
(shape 'ruby_diamond').ensure_presence_of_attribute('color' => 'red').
|
11
|
-
ensure_absence_of_attribute('fill' => 'small_circles')
|
12
|
-
end
|
13
|
-
|
14
|
-
assert_equal(data.children[0].constraints[0].type,
|
15
|
-
Scrubyt::Constraint::CONSTRAINT_TYPE_ENSURE_PRESENCE_OF_ATTRIBUTE)
|
16
|
-
assert_equal(data.children[0].constraints[1].type,
|
17
|
-
Scrubyt::Constraint::CONSTRAINT_TYPE_ENSURE_ABSENCE_OF_ATTRIBUTE)
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_presence_of_ancestor_node_constraints
|
21
|
-
data = Scrubyt::Extractor.define do
|
22
|
-
fetch File.join(File.dirname(__FILE__), "input/constraint_test.html")
|
23
|
-
|
24
|
-
(shape 'funky_rectangle').ensure_presence_of_ancestor_node(:contains, 'name' => 'crispy_ham').
|
25
|
-
ensure_absence_of_ancestor_node(:intersects_with, 'name' => 'spaghetti_ice')
|
26
|
-
end
|
27
|
-
|
28
|
-
assert_equal(data.children[0].constraints[0].type,
|
29
|
-
Scrubyt::Constraint::CONSTRAINT_TYPE_ENSURE_PRESENCE_OF_ANCESTOR_NODE)
|
30
|
-
assert_equal(data.children[0].constraints[1].type,
|
31
|
-
Scrubyt::Constraint::CONSTRAINT_TYPE_ENSURE_ABSENCE_OF_ANCESTOR_NODE)
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_ancestor_node_constraints
|
35
|
-
data0 = Scrubyt::Extractor.define do
|
36
|
-
fetch File.join(File.dirname(__FILE__), "input/constraint_test.html")
|
37
|
-
|
38
|
-
(shape 'funky_rectangle').ensure_presence_of_ancestor_node(:contains, 'name' => 'crispy_ham')
|
39
|
-
end
|
40
|
-
|
41
|
-
data1 = Scrubyt::Extractor.define do
|
42
|
-
fetch File.join(File.dirname(__FILE__), "input/constraint_test.html")
|
43
|
-
|
44
|
-
(shape 'funky_rectangle').ensure_presence_of_ancestor_node(:intersects_with, 'name' => 'spaghetti_ice')
|
45
|
-
end
|
46
|
-
|
47
|
-
data2 = Scrubyt::Extractor.define do
|
48
|
-
fetch File.join(File.dirname(__FILE__), "input/constraint_test.html")
|
49
|
-
|
50
|
-
(shape 'ruby_diamond').ensure_presence_of_ancestor_node(:contains, 'name' => 'crispy_ham').
|
51
|
-
ensure_absence_of_ancestor_node(:intersects_with, 'name' => 'spaghetti_ice')
|
52
|
-
end
|
53
|
-
|
54
|
-
data3 = Scrubyt::Extractor.define do
|
55
|
-
fetch File.join(File.dirname(__FILE__), "input/constraint_test.html")
|
56
|
-
|
57
|
-
shape 'line'#.ensure_presence_of_ancestor_node(:contains, 'name' => 'fungus_ooze').
|
58
|
-
# ensure_presence_of_ancestor_node(:intersects_with, 'object' => 'funky_lemon')
|
59
|
-
end
|
60
|
-
|
61
|
-
p data3.to_xml.to_s
|
62
|
-
exit
|
63
|
-
|
64
|
-
|
65
|
-
data4 = Scrubyt::Extractor.define do
|
66
|
-
fetch File.join(File.dirname(__FILE__), "input/constraint_test.html")
|
67
|
-
|
68
|
-
(shape 'ruby_diamond').ensure_presence_of_ancestor_node(:contains, 'name' => 'chunky_bacon').
|
69
|
-
ensure_absence_of_attribute 'thickness' => '2'
|
70
|
-
end
|
71
|
-
|
72
|
-
assert_equal(data0.to_xml.to_s, "<root><shape>blue_circle</shape><shape>splatted_ellipse</shape></root>")
|
73
|
-
assert_equal(data1.to_xml.to_s, "<root><shape>splatted_ellipse</shape></root>")
|
74
|
-
assert_equal(data2.to_xml.to_s, "<root><shape>blue_circle</shape></root>")
|
75
|
-
assert_equal(data3.to_xml.to_s, "<root><shape>big_rectangle</shape></root>")
|
76
|
-
assert_equal(data4.to_xml.to_s, "<root><shape>ruby_diamond</shape></root>")
|
77
|
-
end
|
78
|
-
|
79
|
-
def test_attribute_constraints
|
80
|
-
data0 = Scrubyt::Extractor.define do
|
81
|
-
fetch File.join(File.dirname(__FILE__), "input/constraint_test.html")
|
82
|
-
|
83
|
-
(shape 'ruby_diamond').ensure_presence_of_attribute 'color' => 'red'
|
84
|
-
end
|
85
|
-
|
86
|
-
data1 = Scrubyt::Extractor.define do
|
87
|
-
fetch File.join(File.dirname(__FILE__), "input/constraint_test.html")
|
88
|
-
|
89
|
-
(shape 'ruby_diamond').ensure_presence_of_attribute 'color' => 'red', 'size' => '10x20'
|
90
|
-
end
|
91
|
-
|
92
|
-
data2 = Scrubyt::Extractor.define do
|
93
|
-
fetch File.join(File.dirname(__FILE__), "input/constraint_test.html")
|
94
|
-
(shape 'ruby_diamond').ensure_presence_of_attribute 'color' => 'red', 'size' => nil
|
95
|
-
end
|
96
|
-
|
97
|
-
data3 = Scrubyt::Extractor.define do
|
98
|
-
fetch File.join(File.dirname(__FILE__), "input/constraint_test.html")
|
99
|
-
(shape 'ruby_diamond').ensure_presence_of_attribute 'thickness' => nil
|
100
|
-
end
|
101
|
-
|
102
|
-
assert_equal(data0.to_xml.to_s, "<root><shape>funky_rectangle</shape><shape>blue_circle</shape><shape>shiny_diamond</shape><shape>clunky_ellipse</shape><shape>twinky_line</shape></root>")
|
103
|
-
assert_equal(data1.to_xml.to_s, "<root><shape>shiny_diamond</shape><shape>clunky_ellipse</shape></root>")
|
104
|
-
assert_equal(data2.to_xml.to_s, "<root><shape>funky_rectangle</shape><shape>blue_circle</shape><shape>shiny_diamond</shape><shape>clunky_ellipse</shape></root>")
|
105
|
-
assert_equal(data3.to_xml.to_s, "<root><shape>twinky_line</shape><shape>line</shape><shape>chunky_line</shape></root>")
|
106
|
-
end
|
107
|
-
end
|
@@ -1,91 +0,0 @@
|
|
1
|
-
require 'scrubyt'
|
2
|
-
require 'test/unit'
|
3
|
-
|
4
|
-
class ExtractorTest < Test::Unit::TestCase
|
5
|
-
def test_create_one_pattern
|
6
|
-
pattern = Scrubyt::Extractor.define do
|
7
|
-
fetch File.join(File.dirname(__FILE__), "input/test.html")
|
8
|
-
pattern "1"
|
9
|
-
end
|
10
|
-
assert_instance_of(Scrubyt::Pattern, pattern)
|
11
|
-
|
12
|
-
assert_equal(pattern.name, "root")
|
13
|
-
assert_equal(pattern.children[0].name, 'pattern')
|
14
|
-
assert_equal(pattern.type, :root)
|
15
|
-
assert_equal(pattern.output_type, :model)
|
16
|
-
|
17
|
-
assert_equal(pattern.generalize, false)
|
18
|
-
assert_equal(pattern.children[0].generalize, true)
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_create_child_pattern
|
22
|
-
pattern = Scrubyt::Extractor.define do
|
23
|
-
fetch File.join(File.dirname(__FILE__), "input/test.html")
|
24
|
-
parent { child "2" }
|
25
|
-
end
|
26
|
-
|
27
|
-
assert_equal(pattern.name, "root")
|
28
|
-
assert_equal(pattern.type, :root)
|
29
|
-
assert_equal(pattern.output_type, :model)
|
30
|
-
|
31
|
-
assert_equal(pattern.children[0].name, "parent")
|
32
|
-
assert_equal(pattern.children[0].type, :tree)
|
33
|
-
assert_equal(pattern.children[0].output_type, :model)
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_create_more_children
|
37
|
-
pattern = Scrubyt::Extractor.define do
|
38
|
-
fetch File.join(File.dirname(__FILE__), "input/test.html")
|
39
|
-
parent do
|
40
|
-
child1 '1'
|
41
|
-
child2 '2'
|
42
|
-
child3 '3'
|
43
|
-
child4 '4'
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
assert_equal(pattern.children[0].children.size, 4)
|
48
|
-
|
49
|
-
i = 0
|
50
|
-
3.times do
|
51
|
-
assert_equal(pattern.children[0].children[i].parent,
|
52
|
-
pattern.children[0].children[i+=1].parent)
|
53
|
-
assert_equal(pattern.children[0].children[i].children, [])
|
54
|
-
end
|
55
|
-
assert_equal(pattern.children[0].children[3].parent, pattern.children[0])
|
56
|
-
assert_equal(pattern.children[0].children[3].parent.parent, pattern)
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_create_hierarchy
|
60
|
-
tree = Scrubyt::Extractor.define do
|
61
|
-
fetch File.join(File.dirname(__FILE__), "input/test.html")
|
62
|
-
a { b { c { d { e "1" } } } }
|
63
|
-
end
|
64
|
-
|
65
|
-
assert_equal(tree.name,"root")
|
66
|
-
assert_equal(tree.children[0].name,"a")
|
67
|
-
assert_equal(tree.children[0].children[0].name,"b")
|
68
|
-
assert_equal(tree.children[0].children[0].children[0].name,"c")
|
69
|
-
assert_equal(tree.children[0].children[0].children[0].children[0].name,"d")
|
70
|
-
end
|
71
|
-
|
72
|
-
|
73
|
-
def test_empty_filter
|
74
|
-
tree = Scrubyt::Extractor.define do
|
75
|
-
fetch File.join(File.dirname(__FILE__), "input/test.html")
|
76
|
-
a do
|
77
|
-
b '1'
|
78
|
-
c '2'
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
assert_not_nil(tree.filters[0])
|
83
|
-
assert_nil(tree.example)
|
84
|
-
assert_not_nil(tree.children[0].filters[0])
|
85
|
-
assert_nil(tree.children[0].example)
|
86
|
-
assert_not_nil(tree.children[0].children[0].filters[0])
|
87
|
-
assert_equal(tree.children[0].children[0].filters[0].example,'1')
|
88
|
-
assert_not_nil(tree.children[0].children[1].filters[0])
|
89
|
-
assert_equal(tree.children[0].children[1].filters[0].example,'2')
|
90
|
-
end
|
91
|
-
end
|
@@ -1,79 +0,0 @@
|
|
1
|
-
#require File.join(File.dirname(__FILE__), '../..', 'lib', 'filter')
|
2
|
-
require 'scrubyt'
|
3
|
-
require 'test/unit'
|
4
|
-
|
5
|
-
class FilterTest < Test::Unit::TestCase
|
6
|
-
def test_determine_example_type
|
7
|
-
#Test children example
|
8
|
-
assert_equal(Scrubyt::BaseFilter.determine_example_type(nil),
|
9
|
-
Scrubyt::BaseFilter::EXAMPLE_TYPE_CHILDREN)
|
10
|
-
#Test image example
|
11
|
-
assert_equal(Scrubyt::BaseFilter.determine_example_type('scrubyt.png'),
|
12
|
-
Scrubyt::BaseFilter::EXAMPLE_TYPE_IMAGE)
|
13
|
-
assert_equal(Scrubyt::BaseFilter.determine_example_type('scrubyt.gif'),
|
14
|
-
Scrubyt::BaseFilter::EXAMPLE_TYPE_IMAGE)
|
15
|
-
assert_equal(Scrubyt::BaseFilter.determine_example_type('scrubyt.jpg'),
|
16
|
-
Scrubyt::BaseFilter::EXAMPLE_TYPE_IMAGE)
|
17
|
-
assert_equal(Scrubyt::BaseFilter.determine_example_type('scrubyt.jpeg'),
|
18
|
-
Scrubyt::BaseFilter::EXAMPLE_TYPE_IMAGE)
|
19
|
-
assert_not_equal(Scrubyt::BaseFilter.determine_example_type('scrubyt.zip'),
|
20
|
-
Scrubyt::BaseFilter::EXAMPLE_TYPE_IMAGE)
|
21
|
-
assert_not_equal(Scrubyt::BaseFilter.determine_example_type('scrubyt.pif'),
|
22
|
-
Scrubyt::BaseFilter::EXAMPLE_TYPE_IMAGE)
|
23
|
-
#Test XPaths
|
24
|
-
assert_equal(Scrubyt::BaseFilter.determine_example_type('/p/img'),
|
25
|
-
Scrubyt::BaseFilter::EXAMPLE_TYPE_XPATH)
|
26
|
-
assert_equal(Scrubyt::BaseFilter.determine_example_type('/p/h3'),
|
27
|
-
Scrubyt::BaseFilter::EXAMPLE_TYPE_XPATH)
|
28
|
-
assert_equal(Scrubyt::BaseFilter.determine_example_type('/p/h3/a/h2'),
|
29
|
-
Scrubyt::BaseFilter::EXAMPLE_TYPE_XPATH)
|
30
|
-
assert_equal(Scrubyt::BaseFilter.determine_example_type('/h2'),
|
31
|
-
Scrubyt::BaseFilter::EXAMPLE_TYPE_XPATH)
|
32
|
-
assert_equal(Scrubyt::BaseFilter.determine_example_type('/h1/h3'),
|
33
|
-
Scrubyt::BaseFilter::EXAMPLE_TYPE_XPATH)
|
34
|
-
assert_equal(Scrubyt::BaseFilter.determine_example_type('/p'),
|
35
|
-
Scrubyt::BaseFilter::EXAMPLE_TYPE_XPATH)
|
36
|
-
assert_equal(Scrubyt::BaseFilter.determine_example_type('//p'),
|
37
|
-
Scrubyt::BaseFilter::EXAMPLE_TYPE_XPATH)
|
38
|
-
assert_equal(Scrubyt::BaseFilter.determine_example_type('/p//img'),
|
39
|
-
Scrubyt::BaseFilter::EXAMPLE_TYPE_XPATH)
|
40
|
-
assert_equal(Scrubyt::BaseFilter.determine_example_type('//p//img'),
|
41
|
-
Scrubyt::BaseFilter::EXAMPLE_TYPE_XPATH)
|
42
|
-
assert_equal(Scrubyt::BaseFilter.determine_example_type('/p[0]/img'),
|
43
|
-
Scrubyt::BaseFilter::EXAMPLE_TYPE_XPATH)
|
44
|
-
assert_equal(Scrubyt::BaseFilter.determine_example_type('/p[0]'),
|
45
|
-
Scrubyt::BaseFilter::EXAMPLE_TYPE_XPATH)
|
46
|
-
assert_equal(Scrubyt::BaseFilter.determine_example_type('//p[1]'),
|
47
|
-
Scrubyt::BaseFilter::EXAMPLE_TYPE_XPATH)
|
48
|
-
assert_equal(Scrubyt::BaseFilter.determine_example_type('/p[1]//img[2]'),
|
49
|
-
Scrubyt::BaseFilter::EXAMPLE_TYPE_XPATH)
|
50
|
-
assert_equal(Scrubyt::BaseFilter.determine_example_type('//p[1]//img'),
|
51
|
-
Scrubyt::BaseFilter::EXAMPLE_TYPE_XPATH)
|
52
|
-
assert_equal(Scrubyt::BaseFilter.determine_example_type('/table/tr/td//span/b'),
|
53
|
-
Scrubyt::BaseFilter::EXAMPLE_TYPE_XPATH)
|
54
|
-
assert_equal(Scrubyt::BaseFilter.determine_example_type('/table[0]//tr/td[1]/span[2]/b'),
|
55
|
-
Scrubyt::BaseFilter::EXAMPLE_TYPE_XPATH)
|
56
|
-
assert_not_equal(Scrubyt::BaseFilter.determine_example_type('table[0]//tr/td[1]/span[2]/b'),
|
57
|
-
Scrubyt::BaseFilter::EXAMPLE_TYPE_XPATH)
|
58
|
-
assert_not_equal(Scrubyt::BaseFilter.determine_example_type('/table[a]//tr/td[1]/span[2]/b'),
|
59
|
-
Scrubyt::BaseFilter::EXAMPLE_TYPE_XPATH)
|
60
|
-
assert_not_equal(Scrubyt::BaseFilter.determine_example_type('/tab2le[a]//tr/td[1]/span[2]/b'),
|
61
|
-
Scrubyt::BaseFilter::EXAMPLE_TYPE_XPATH)
|
62
|
-
assert_not_equal(Scrubyt::BaseFilter.determine_example_type('/table[a]///tr/td[1]/span[2]/b'),
|
63
|
-
Scrubyt::BaseFilter::EXAMPLE_TYPE_XPATH)
|
64
|
-
#Test string example
|
65
|
-
assert_equal(Scrubyt::BaseFilter.determine_example_type('Hello, world!'),
|
66
|
-
Scrubyt::BaseFilter::EXAMPLE_TYPE_STRING)
|
67
|
-
assert_equal(Scrubyt::BaseFilter.determine_example_type('$1022'),
|
68
|
-
Scrubyt::BaseFilter::EXAMPLE_TYPE_STRING)
|
69
|
-
assert_equal(Scrubyt::BaseFilter.determine_example_type('CANON'),
|
70
|
-
Scrubyt::BaseFilter::EXAMPLE_TYPE_STRING)
|
71
|
-
assert_equal(Scrubyt::BaseFilter.determine_example_type('This is a string'),
|
72
|
-
Scrubyt::BaseFilter::EXAMPLE_TYPE_STRING)
|
73
|
-
assert_equal(Scrubyt::BaseFilter.determine_example_type('45'),
|
74
|
-
Scrubyt::BaseFilter::EXAMPLE_TYPE_STRING)
|
75
|
-
assert_equal(Scrubyt::BaseFilter.determine_example_type('td'),
|
76
|
-
Scrubyt::BaseFilter::EXAMPLE_TYPE_STRING)
|
77
|
-
|
78
|
-
end
|
79
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
<shapes>
|
2
|
-
|
3
|
-
<!-- red shapes -->
|
4
|
-
<shape color='red' size='10x10' fill='none'>funky_rectangle<contains name='stuff' color='blue'/></shape>
|
5
|
-
<shape color='red' size='20x10' fill='small_circles'>blue_circle
|
6
|
-
<contains name='crispy_ham' color='blue'/>
|
7
|
-
<intersects_with object='banana'/>
|
8
|
-
</shape>
|
9
|
-
<shape color='red' size='10x20' fill='big_boxes'>
|
10
|
-
shiny_diamond
|
11
|
-
<intersects_with object='chunky_bacon'/>
|
12
|
-
</shape>
|
13
|
-
<shape color='red' size='10x20'>clunky_ellipse
|
14
|
-
<contains name='sliced_orange' color='blue'/>
|
15
|
-
<intersects_with object='nintendo_wii'/>
|
16
|
-
</shape>
|
17
|
-
<shape color='red' thickness='2'>twinky_line</shape>
|
18
|
-
|
19
|
-
<!-- green shapes -->
|
20
|
-
<shape color='green' size='18x5' fill='big_boxes'>boxy_rectangle
|
21
|
-
<contains name='banana_fluff' color='blue'/>
|
22
|
-
<intersects_with object='bacon_fudge'/>
|
23
|
-
</shape>
|
24
|
-
<shape color='green' size='20x10' fill='chunky_bacon'>whammed_circle
|
25
|
-
<contains name='big_ham' color='blue'/>
|
26
|
-
<intersects_with object='crispy_ham'/>
|
27
|
-
</shape>
|
28
|
-
<shape color='green' size='30x15' fill='chunky_bacon'>
|
29
|
-
spherical_diamond
|
30
|
-
<intersects_with object='crispy_orange'/>
|
31
|
-
</shape>
|
32
|
-
<shape color='green' size='20x30' fill='none'>avocado_ellipse
|
33
|
-
<contains name='avocado_fudge' color='blue'/>
|
34
|
-
</shape>
|
35
|
-
<shape color='green' thickness='2'>line</shape>
|
36
|
-
|
37
|
-
<!-- green shapes -->
|
38
|
-
<shape color='blue' size='120x10' fill='small_circles'>big_rectangle
|
39
|
-
<contains name='fungus_ooze' color='blue'/>
|
40
|
-
<intersects_with object='funky_lemon'/>
|
41
|
-
</shape>
|
42
|
-
<shape color='blue' size='50x20' fill='small_circles'>crazy_circle
|
43
|
-
<contains name='nut_shake' color='blue'/>
|
44
|
-
<intersects_with object='crazy_nut'/>
|
45
|
-
</shape>
|
46
|
-
<shape color='blue' size='30x30' fill='big_boxes'>ruby_diamond<contains name='chunky_bacon' color='blue'/></shape>
|
47
|
-
<shape color='blue' size='5x12' fill='chunky_bacon'>splatted_ellipse
|
48
|
-
<contains name='crispy_ham' color='blue'/>
|
49
|
-
<intersects_with name='spaghetti_ice' color='blue'/>
|
50
|
-
</shape>
|
51
|
-
<shape color='blue' thickness='2'>chunky_line
|
52
|
-
<contains name='chunky_bacon' color='blue'/>
|
53
|
-
</shape>
|
54
|
-
|
55
|
-
</shapes>
|