testability-driver 0.9.2 → 1.0.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/lib/tdriver/base/behaviour/behaviours/object_behaviour_composition.rb +1 -1
- data/lib/tdriver/base/behaviour/behaviours/object_behaviour_description.rb +11 -7
- data/lib/tdriver/base/behaviour/behaviours/object_composition.rb +8 -0
- data/lib/tdriver/base/behaviour/factory.rb +229 -209
- data/lib/tdriver/base/errors.rb +3 -0
- data/lib/tdriver/base/state_object.rb +11 -20
- data/lib/tdriver/base/sut/controller.rb +4 -4
- data/lib/tdriver/base/sut/factory.rb +205 -170
- data/lib/tdriver/base/sut/generic/behaviours/application.rb +256 -174
- data/lib/tdriver/base/sut/generic/behaviours/find.rb +17 -11
- data/lib/tdriver/base/sut/generic/behaviours/flash_behaviour.rb +57 -66
- data/lib/tdriver/base/sut/generic/behaviours/sut.rb +578 -497
- data/lib/tdriver/base/sut/generic/behaviours/switchbox_behaviour.rb +41 -15
- data/lib/tdriver/base/sut/generic/behaviours/verification.rb +48 -19
- data/lib/tdriver/base/sut/generic/commands/fixture.rb +47 -0
- data/lib/tdriver/base/sut/generic/commands/key_sequence.rb +25 -13
- data/lib/tdriver/base/sut/generic/commands/screen_capture.rb +16 -10
- data/lib/tdriver/base/sut/generic/plugin.rb +9 -3
- data/lib/tdriver/base/sut/sut.rb +41 -33
- data/lib/tdriver/base/test_object/abstract.rb +26 -3
- data/lib/tdriver/base/test_object/adapter.rb +399 -0
- data/lib/tdriver/base/test_object/behaviours/syncronization.rb +56 -14
- data/lib/tdriver/base/test_object/behaviours/test_object.rb +663 -197
- data/lib/tdriver/base/test_object/cache.rb +132 -0
- data/lib/tdriver/base/test_object/factory.rb +677 -426
- data/lib/tdriver/base/test_object/factory_new.rb +202 -0
- data/lib/tdriver/base/test_object/identificator.rb +24 -17
- data/lib/tdriver/base/test_object/loader.rb +9 -3
- data/lib/tdriver/base/test_object/verification.rb +181 -0
- data/lib/tdriver/loader.rb +1 -1
- data/lib/tdriver/report/report.rb +2 -0
- data/lib/tdriver/report/report_api.rb +4 -4
- data/lib/tdriver/report/report_creator.rb +29 -3
- data/lib/tdriver/report/report_data_presentation.rb +7 -3
- data/lib/tdriver/report/report_execution_statistics.rb +80 -21
- data/lib/tdriver/report/report_javascript.rb +192 -0
- data/lib/tdriver/report/report_test_case_run.rb +22 -0
- data/lib/tdriver/report/report_test_run.rb +62 -55
- data/lib/tdriver/report/report_writer.rb +57 -56
- data/lib/tdriver/tdriver.rb +14 -41
- data/lib/tdriver/util/common/error.rb +1 -0
- data/lib/tdriver/util/common/exceptions.rb +12 -0
- data/lib/tdriver/util/common/file.rb +12 -6
- data/lib/tdriver/util/common/gem.rb +2 -1
- data/lib/tdriver/util/common/hash.rb +152 -0
- data/lib/tdriver/util/common/kernel.rb +49 -34
- data/lib/tdriver/util/common/loader.rb +21 -17
- data/lib/tdriver/util/common/numeric.rb +39 -0
- data/lib/tdriver/util/common/object.rb +115 -0
- data/lib/tdriver/util/common/string.rb +55 -2
- data/lib/tdriver/util/dbaccess/dbaccess.rb +194 -161
- data/lib/tdriver/util/dynamic_attribute_filter.rb +6 -0
- data/lib/tdriver/util/hooking.rb +2 -2
- data/lib/tdriver/util/loader.rb +2 -2
- data/lib/tdriver/util/localisation/localisation.rb +277 -18
- data/lib/tdriver/util/logger.rb +142 -13
- data/lib/tdriver/util/parameter/parameter_hash.rb +8 -5
- data/lib/tdriver/util/parameter/parameter_xml.rb +18 -2
- data/lib/tdriver/util/recorder.rb +17 -12
- data/lib/tdriver/util/user_data/user_data.rb +3 -2
- data/lib/tdriver/util/{video_rec.rb → video_utils.rb} +136 -16
- data/lib/tdriver/util/xml/abstraction.rb +7 -0
- data/lib/tdriver/util/xml/attribute.rb +32 -0
- data/lib/tdriver/util/xml/loader.rb +8 -2
- data/lib/tdriver/util/xml/nil_node.rb +95 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/abstraction.rb +46 -7
- data/lib/tdriver/util/xml/parsers/nokogiri/attribute.rb +19 -9
- data/lib/tdriver/util/xml/parsers/nokogiri/document.rb +1 -1
- data/lib/tdriver/util/xml/parsers/nokogiri/element.rb +13 -1
- data/lib/tdriver/util/xml/parsers/nokogiri/loader.rb +6 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/nodeset.rb +27 -15
- data/lib/tdriver/util/xml/parsers/nokogiri/text.rb +57 -0
- data/lib/tdriver/util/xml/text.rb +32 -0
- data/lib/tdriver/util/xml/xml.rb +35 -22
- data/lib/tdriver/version.rb +1 -1
- data/lib/tdriver-devtools/behaviour/xml/rdoc_behaviour_xml_generator.rb +41 -34
- data/lib/tdriver-devtools/doc/generate.rb +31 -6
- data/lib/tdriver-devtools/doc/xslt/template.xsl +46 -25
- data/lib/tdriver-devtools/tests/feature_tests/example/behaviour_example.rb +100 -0
- data/lib/tdriver-devtools/tests/feature_tests/update +1 -1
- data/lib/tdriver.rb +0 -3
- data/xml/behaviours/generic.xml +1 -1
- data/xml/defaults/generic.xml +4 -90
- data/xml/templates/generic.xml +33 -25
- metadata +21 -29
- data/lib/tdriver-devtools/behaviour/xml_generator/example/flick-example.rb +0 -245
- data/lib/tdriver-devtools/behaviour/xml_generator/example/sut.rb +0 -964
- data/lib/tdriver-devtools/behaviour/xml_generator/generate.rb +0 -68
- data/lib/tdriver-devtools/behaviour/xml_generator/lib/custom_rdoc_generator.rb +0 -1865
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.argument.default.template +0 -1
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.argument.template +0 -3
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.argument_type.template +0 -4
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.exception.template +0 -4
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.arguments.template +0 -4
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.deprecated.template +0 -3
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.exceptions.template +0 -3
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.info.template +0 -1
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.returns.template +0 -3
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.tables.template +0 -3
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.template +0 -12
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.returns.template +0 -5
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.table.item.template +0 -1
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.table.row.template +0 -2
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.table.template +0 -7
- data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.template +0 -14
- data/lib/tdriver-devtools/behaviour/xml_generator/update +0 -3
- data/lib/tdriver-devtools/tests/feature_tests/example/flick-example.rb +0 -233
- data/lib/tdriver-devtools/tests/feature_tests/example/impl.rb +0 -194
|
@@ -62,6 +62,40 @@ module MobyUtil
|
|
|
62
62
|
|
|
63
63
|
private
|
|
64
64
|
|
|
65
|
+
# TODO: document me
|
|
66
|
+
def node_object( object )
|
|
67
|
+
|
|
68
|
+
case object
|
|
69
|
+
|
|
70
|
+
when ::Nokogiri::XML::Element
|
|
71
|
+
|
|
72
|
+
element_object( object )
|
|
73
|
+
|
|
74
|
+
when ::Nokogiri::XML::Text
|
|
75
|
+
|
|
76
|
+
text_object( object )
|
|
77
|
+
|
|
78
|
+
when ::Nokogiri::XML::Attr
|
|
79
|
+
|
|
80
|
+
attribute_object( object )
|
|
81
|
+
|
|
82
|
+
when ::NilClass
|
|
83
|
+
|
|
84
|
+
nil_node
|
|
85
|
+
|
|
86
|
+
# do not create wrapper object if already wrapped
|
|
87
|
+
when ::MobyUtil::XML::Element, ::MobyUtil::XML::Nodeset, ::MobyUtil::XML::Text, ::MobyUtil::XML::Attribute, ::MobyUtil::XML::NilNode
|
|
88
|
+
|
|
89
|
+
object
|
|
90
|
+
|
|
91
|
+
else
|
|
92
|
+
|
|
93
|
+
raise NotImplementedError.new( "Object wrapper for node type of #{ object.class } not implemented - Please contact TDriver support" )
|
|
94
|
+
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
end
|
|
98
|
+
|
|
65
99
|
# method to create MobyUtil::XML::Attribute object
|
|
66
100
|
def attribute_object( xml_data )
|
|
67
101
|
|
|
@@ -69,18 +103,24 @@ module MobyUtil
|
|
|
69
103
|
|
|
70
104
|
end
|
|
71
105
|
|
|
72
|
-
# method to create MobyUtil::XML::Element
|
|
106
|
+
# method to create MobyUtil::XML::Element
|
|
73
107
|
def element_object( xml_data )
|
|
74
108
|
|
|
75
|
-
|
|
109
|
+
MobyUtil::XML::Element.new( xml_data, @parser ).extend( Element )
|
|
110
|
+
|
|
111
|
+
end
|
|
76
112
|
|
|
77
|
-
|
|
113
|
+
# method to create MobyUtil::XML::NilNode
|
|
114
|
+
def nil_node
|
|
78
115
|
|
|
79
|
-
|
|
116
|
+
MobyUtil::XML::NilNode.new( nil, @parser )
|
|
117
|
+
|
|
118
|
+
end
|
|
80
119
|
|
|
81
|
-
|
|
120
|
+
# method to create MobyUtil::XML::Text
|
|
121
|
+
def text_object( xml_data )
|
|
82
122
|
|
|
83
|
-
|
|
123
|
+
MobyUtil::XML::Text.new( xml_data, @parser ).extend( Text )
|
|
84
124
|
|
|
85
125
|
end
|
|
86
126
|
|
|
@@ -89,7 +129,6 @@ module MobyUtil
|
|
|
89
129
|
|
|
90
130
|
MobyUtil::XML::Nodeset.new( xml_data, @parser ).extend( Nodeset )
|
|
91
131
|
|
|
92
|
-
|
|
93
132
|
end
|
|
94
133
|
|
|
95
134
|
# TODO: Documentation
|
|
@@ -17,9 +17,6 @@
|
|
|
17
17
|
##
|
|
18
18
|
############################################################################
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
=begin
|
|
22
|
-
|
|
23
20
|
module MobyUtil
|
|
24
21
|
|
|
25
22
|
module XML
|
|
@@ -28,17 +25,31 @@ module MobyUtil
|
|
|
28
25
|
|
|
29
26
|
module Attribute
|
|
30
27
|
|
|
28
|
+
include Abstraction
|
|
29
|
+
|
|
31
30
|
def value
|
|
32
|
-
|
|
31
|
+
|
|
32
|
+
@xml.value
|
|
33
|
+
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def content
|
|
37
|
+
|
|
38
|
+
@xml.content
|
|
39
|
+
|
|
33
40
|
end
|
|
34
41
|
|
|
35
42
|
def name
|
|
36
|
-
|
|
43
|
+
|
|
44
|
+
@xml.name
|
|
45
|
+
|
|
37
46
|
end
|
|
38
47
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
48
|
+
def to_s
|
|
49
|
+
|
|
50
|
+
@xml.value
|
|
51
|
+
|
|
52
|
+
end
|
|
42
53
|
|
|
43
54
|
# enable hooking for performance measurement & debug logging
|
|
44
55
|
MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
|
|
@@ -51,4 +62,3 @@ module MobyUtil
|
|
|
51
62
|
|
|
52
63
|
end # MobyUtil
|
|
53
64
|
|
|
54
|
-
=end
|
|
@@ -25,7 +25,7 @@ module MobyUtil
|
|
|
25
25
|
|
|
26
26
|
module Element # behaviour
|
|
27
27
|
|
|
28
|
-
include Abstraction
|
|
28
|
+
include Abstraction
|
|
29
29
|
|
|
30
30
|
def <=>( object )
|
|
31
31
|
|
|
@@ -113,6 +113,12 @@ module MobyUtil
|
|
|
113
113
|
|
|
114
114
|
end
|
|
115
115
|
|
|
116
|
+
def at_xpath( xpath_query, *args, &block )
|
|
117
|
+
|
|
118
|
+
node_object( @xml.at_xpath( xpath_query, *args, &block ) )
|
|
119
|
+
|
|
120
|
+
end
|
|
121
|
+
|
|
116
122
|
def replace( other )
|
|
117
123
|
|
|
118
124
|
@xml.replace( other.xml )
|
|
@@ -135,6 +141,12 @@ module MobyUtil
|
|
|
135
141
|
|
|
136
142
|
end
|
|
137
143
|
|
|
144
|
+
def parent
|
|
145
|
+
|
|
146
|
+
element_object( @xml.parent )
|
|
147
|
+
|
|
148
|
+
end
|
|
149
|
+
|
|
138
150
|
# enable hooking for performance measurement & debug logging
|
|
139
151
|
MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
|
|
140
152
|
|
|
@@ -35,6 +35,12 @@ require File.expand_path( File.join( File.dirname( __FILE__ ), 'nodeset.rb' ) )
|
|
|
35
35
|
# nokogiri parser wrapper
|
|
36
36
|
require File.expand_path( File.join( File.dirname( __FILE__ ), 'element.rb' ) )
|
|
37
37
|
|
|
38
|
+
# nokogiri parser wrapper
|
|
39
|
+
require File.expand_path( File.join( File.dirname( __FILE__ ), 'text.rb' ) )
|
|
40
|
+
|
|
41
|
+
# nokogiri parser wrapper
|
|
42
|
+
require File.expand_path( File.join( File.dirname( __FILE__ ), 'attribute.rb' ) )
|
|
43
|
+
|
|
38
44
|
# nokogiri parser wrapper
|
|
39
45
|
require File.expand_path( File.join( File.dirname( __FILE__ ), 'builder.rb' ) )
|
|
40
46
|
|
|
@@ -29,27 +29,39 @@ module MobyUtil
|
|
|
29
29
|
|
|
30
30
|
def []( node )
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
node_object( @xml[ node ] )
|
|
33
33
|
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
def first
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
node_object( @xml.first )
|
|
39
39
|
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
def last
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
node_object( @xml.last )
|
|
45
45
|
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
def each( &block )
|
|
49
49
|
|
|
50
|
-
@xml.each{ |
|
|
50
|
+
@xml.each{ | node |
|
|
51
51
|
|
|
52
|
-
yield(
|
|
52
|
+
yield( node_object( node ) )
|
|
53
|
+
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
self
|
|
57
|
+
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def each_with_index( &block )
|
|
61
|
+
|
|
62
|
+
@xml.each_with_index{ | node, index |
|
|
63
|
+
|
|
64
|
+
yield( node_object( node ), index )
|
|
53
65
|
|
|
54
66
|
}
|
|
55
67
|
|
|
@@ -116,9 +128,9 @@ module MobyUtil
|
|
|
116
128
|
|
|
117
129
|
def to_a
|
|
118
130
|
|
|
119
|
-
@xml.collect{ |
|
|
131
|
+
@xml.collect{ | node |
|
|
120
132
|
|
|
121
|
-
|
|
133
|
+
node_object( node )
|
|
122
134
|
|
|
123
135
|
}
|
|
124
136
|
|
|
@@ -126,11 +138,11 @@ module MobyUtil
|
|
|
126
138
|
|
|
127
139
|
def delete( node )
|
|
128
140
|
|
|
129
|
-
@xml.each do |
|
|
141
|
+
@xml.each do | nodeset_node |
|
|
130
142
|
|
|
131
|
-
if ( node.xml.content ==
|
|
143
|
+
if ( node.xml.content == nodeset_node.content )
|
|
132
144
|
|
|
133
|
-
@xml.delete(
|
|
145
|
+
@xml.delete( nodeset_node )
|
|
134
146
|
|
|
135
147
|
break
|
|
136
148
|
|
|
@@ -149,9 +161,9 @@ module MobyUtil
|
|
|
149
161
|
|
|
150
162
|
def _collect( &block )
|
|
151
163
|
|
|
152
|
-
@xml.collect{ |
|
|
164
|
+
@xml.collect{ | node |
|
|
153
165
|
|
|
154
|
-
yield(
|
|
166
|
+
yield( node_object( node ) )
|
|
155
167
|
|
|
156
168
|
}
|
|
157
169
|
|
|
@@ -159,15 +171,15 @@ module MobyUtil
|
|
|
159
171
|
|
|
160
172
|
def _sort( &block )
|
|
161
173
|
|
|
162
|
-
@xml.sort{ |
|
|
174
|
+
@xml.sort{ | node_a, node_b |
|
|
163
175
|
|
|
164
176
|
if block_given?
|
|
165
177
|
|
|
166
|
-
yield(
|
|
178
|
+
yield( node_object( node_a ), node_object( node_b ) )
|
|
167
179
|
|
|
168
180
|
else
|
|
169
181
|
|
|
170
|
-
|
|
182
|
+
node_a <=> node_b
|
|
171
183
|
|
|
172
184
|
end
|
|
173
185
|
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
############################################################################
|
|
2
|
+
##
|
|
3
|
+
## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
4
|
+
## All rights reserved.
|
|
5
|
+
## Contact: Nokia Corporation (testabilitydriver@nokia.com)
|
|
6
|
+
##
|
|
7
|
+
## This file is part of Testability Driver.
|
|
8
|
+
##
|
|
9
|
+
## If you have questions regarding the use of this file, please contact
|
|
10
|
+
## Nokia at testabilitydriver@nokia.com .
|
|
11
|
+
##
|
|
12
|
+
## This library is free software; you can redistribute it and/or
|
|
13
|
+
## modify it under the terms of the GNU Lesser General Public
|
|
14
|
+
## License version 2.1 as published by the Free Software Foundation
|
|
15
|
+
## and appearing in the file LICENSE.LGPL included in the packaging
|
|
16
|
+
## of this file.
|
|
17
|
+
##
|
|
18
|
+
############################################################################
|
|
19
|
+
|
|
20
|
+
module MobyUtil
|
|
21
|
+
|
|
22
|
+
module XML
|
|
23
|
+
|
|
24
|
+
module Nokogiri
|
|
25
|
+
|
|
26
|
+
module Text # behaviour
|
|
27
|
+
|
|
28
|
+
include Abstraction
|
|
29
|
+
|
|
30
|
+
def parent
|
|
31
|
+
|
|
32
|
+
element_object( @xml.parent )
|
|
33
|
+
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def to_s
|
|
37
|
+
|
|
38
|
+
@xml.content
|
|
39
|
+
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def content
|
|
43
|
+
|
|
44
|
+
@xml.content
|
|
45
|
+
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# enable hooking for performance measurement & debug logging
|
|
49
|
+
MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
|
|
50
|
+
|
|
51
|
+
end # Element
|
|
52
|
+
|
|
53
|
+
end # Nokogiri
|
|
54
|
+
|
|
55
|
+
end # XML
|
|
56
|
+
|
|
57
|
+
end # MobyUtil
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
############################################################################
|
|
2
|
+
##
|
|
3
|
+
## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
4
|
+
## All rights reserved.
|
|
5
|
+
## Contact: Nokia Corporation (testabilitydriver@nokia.com)
|
|
6
|
+
##
|
|
7
|
+
## This file is part of Testability Driver.
|
|
8
|
+
##
|
|
9
|
+
## If you have questions regarding the use of this file, please contact
|
|
10
|
+
## Nokia at testabilitydriver@nokia.com .
|
|
11
|
+
##
|
|
12
|
+
## This library is free software; you can redistribute it and/or
|
|
13
|
+
## modify it under the terms of the GNU Lesser General Public
|
|
14
|
+
## License version 2.1 as published by the Free Software Foundation
|
|
15
|
+
## and appearing in the file LICENSE.LGPL included in the packaging
|
|
16
|
+
## of this file.
|
|
17
|
+
##
|
|
18
|
+
############################################################################
|
|
19
|
+
|
|
20
|
+
module MobyUtil
|
|
21
|
+
|
|
22
|
+
module XML
|
|
23
|
+
|
|
24
|
+
class Text
|
|
25
|
+
|
|
26
|
+
include Abstraction
|
|
27
|
+
|
|
28
|
+
end # Text
|
|
29
|
+
|
|
30
|
+
end # XML
|
|
31
|
+
|
|
32
|
+
end # MobyUtil
|
data/lib/tdriver/util/xml/xml.rb
CHANGED
|
@@ -57,8 +57,7 @@ module MobyUtil
|
|
|
57
57
|
# ==> Returns XML document object; default xml parser will be used.
|
|
58
58
|
#
|
|
59
59
|
# == params
|
|
60
|
-
# xml_string:: String containing XML
|
|
61
|
-
# parser:: XML parser class e.g. MobyUtil::XML::Nokogiri
|
|
60
|
+
# xml_string:: String containing XML
|
|
62
61
|
# == return
|
|
63
62
|
# Document:: XML document object
|
|
64
63
|
# == raises
|
|
@@ -66,7 +65,7 @@ module MobyUtil
|
|
|
66
65
|
|
|
67
66
|
begin
|
|
68
67
|
|
|
69
|
-
MobyUtil::XML::Document.new( nil,
|
|
68
|
+
MobyUtil::XML::Document.new( nil, @@parser ).extend( @@parser::Document ).tap{ | document |
|
|
70
69
|
|
|
71
70
|
# parse given string
|
|
72
71
|
document.xml = document.parse( xml_string )
|
|
@@ -75,30 +74,45 @@ module MobyUtil
|
|
|
75
74
|
|
|
76
75
|
rescue Exception => exception
|
|
77
76
|
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
if $TDRIVER_INITIALIZED == true
|
|
78
|
+
|
|
79
|
+
# string for exception message
|
|
80
|
+
dump_location = ""
|
|
80
81
|
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
# check if xml parse error logging is enabled
|
|
83
|
+
if MobyUtil::KernelHelper.to_boolean( MobyUtil::Parameter[ :logging_xml_parse_error_dump ] )
|
|
83
84
|
|
|
84
|
-
|
|
85
|
-
|
|
85
|
+
# generate filename for xml dump
|
|
86
|
+
filename = MobyUtil::KernelHelper.to_boolean( MobyUtil::Parameter[ :logging_xml_parse_error_dump_overwrite ] ) ? 'xml_error_dump.xml' : 'xml_error_dump_%i.xml' % Time.now
|
|
86
87
|
|
|
87
|
-
|
|
88
|
-
|
|
88
|
+
# ... join filename with xml dump output path
|
|
89
|
+
path = File.join( MobyUtil::FileHelper.expand_path( MobyUtil::Parameter[ :logging_xml_parse_error_dump_path ] ), filename )
|
|
89
90
|
|
|
90
|
-
|
|
91
|
-
MobyUtil::FileHelper.mkdir_path( File.dirname( path ) )
|
|
91
|
+
begin
|
|
92
92
|
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
# write xml string to file
|
|
94
|
+
File.open( path, "w" ){ | file | file << xml_string }
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
dump_location = ". Saved to %s" % path
|
|
97
|
+
|
|
98
|
+
rescue
|
|
99
|
+
|
|
100
|
+
dump_location = ". Error while saving to file %s" % path
|
|
101
|
+
|
|
102
|
+
end
|
|
97
103
|
|
|
98
|
-
end
|
|
99
104
|
|
|
100
|
-
|
|
101
|
-
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# raise exception
|
|
108
|
+
Kernel::raise MobyUtil::XML::ParseError.new( "%s (%s)%s" % [ exception.message.gsub("\n", ''), exception.class, dump_location ] )
|
|
109
|
+
|
|
110
|
+
else
|
|
111
|
+
|
|
112
|
+
# raise exception
|
|
113
|
+
Kernel::raise MobyUtil::XML::ParseError.new( "%s (%s)" % [ exception.message.gsub("\n", ''), exception.class ] )
|
|
114
|
+
|
|
115
|
+
end
|
|
102
116
|
|
|
103
117
|
end
|
|
104
118
|
|
|
@@ -110,8 +124,7 @@ module MobyUtil
|
|
|
110
124
|
# ==> Returns XML document object; default xml parser will be used.
|
|
111
125
|
#
|
|
112
126
|
# == params
|
|
113
|
-
# filename:: String containing path and filename of XML file.
|
|
114
|
-
# parser:: XML parser class e.g. MobyUtil::XML::Nokogiri
|
|
127
|
+
# filename:: String containing path and filename of XML file.
|
|
115
128
|
# == return
|
|
116
129
|
# Document:: XML document object
|
|
117
130
|
# == raises
|
|
@@ -121,7 +134,7 @@ module MobyUtil
|
|
|
121
134
|
# raise exception if file not found
|
|
122
135
|
Kernel::raise IOError.new( "File '%s' not found" % filename ) unless File.exist?( filename )
|
|
123
136
|
|
|
124
|
-
self.parse_string( IO.read( filename )
|
|
137
|
+
self.parse_string( IO.read( filename ) )
|
|
125
138
|
|
|
126
139
|
end
|
|
127
140
|
|