cutedriver-driver 2.0.0.20210120164037
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.
- checksums.yaml +7 -0
- data/README.md +16 -0
- data/bin/start_app_perf +200 -0
- data/bin/tdriver-devtools +3 -0
- data/config/sut_parameters.rb +52 -0
- data/config/sut_setup.rb +32 -0
- data/config/sut_teardown.rb +32 -0
- data/config/tdriver_custom_error_recovery.rb +83 -0
- data/ext/extconf.rb +70 -0
- data/ext/native_extensions.c +315 -0
- data/lib/matti.rb +25 -0
- data/lib/tdriver-devtools/behaviour/old/xml/example/flick-example.rb +120 -0
- data/lib/tdriver-devtools/behaviour/old/xml/example/impl.rb_invalid +194 -0
- data/lib/tdriver-devtools/behaviour/old/xml/generate_behaviour_xml.rb +95 -0
- data/lib/tdriver-devtools/behaviour/old/xml/lib/tdriver_generator.rb +722 -0
- data/lib/tdriver-devtools/behaviour/old/xml/qdoc_generator.rb +321 -0
- data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.method.template +43 -0
- data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.module.template +54 -0
- data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.argument.template +7 -0
- data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.argument_type.template +7 -0
- data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.exception.template +5 -0
- data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.howto.line.template +2 -0
- data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.howto.template +5 -0
- data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.method.template +23 -0
- data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.template +14 -0
- data/lib/tdriver-devtools/behaviour/old/xml/update +3 -0
- data/lib/tdriver-devtools/behaviour/xml/generate.rb +88 -0
- data/lib/tdriver-devtools/behaviour/xml/rdoc_behaviour_xml_generator.rb +1945 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.argument.default.template +1 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.argument.template +3 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.argument_type.template +4 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.exception.template +4 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.arguments.template +4 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.deprecated.template +3 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.exceptions.template +3 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.info.template +1 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.returns.template +3 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.tables.template +3 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.template +12 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.returns.template +5 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.table.item.template +1 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.table.row.template +2 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.table.template +8 -0
- data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.template +14 -0
- data/lib/tdriver-devtools/doc/behaviour_xml/QtExampleGestureBehaviour.xml +138 -0
- data/lib/tdriver-devtools/doc/behaviour_xml/created.rid +1 -0
- data/lib/tdriver-devtools/doc/behaviour_xml/tdriver.hash +1 -0
- data/lib/tdriver-devtools/doc/feature_xml/qt_widget_hold.feature.xml +9 -0
- data/lib/tdriver-devtools/doc/feature_xml/qt_widget_tap.feature.xml +9 -0
- data/lib/tdriver-devtools/doc/generate.rb +917 -0
- data/lib/tdriver-devtools/doc/update +1 -0
- data/lib/tdriver-devtools/doc/xslt/html.rb +7 -0
- data/lib/tdriver-devtools/doc/xslt/template.xsl +2170 -0
- data/lib/tdriver-devtools/doc/xslt/update +3 -0
- data/lib/tdriver-devtools/plugin/placeholder.txt +1 -0
- data/lib/tdriver-devtools/tdriver-devtools.rb +404 -0
- data/lib/tdriver-devtools/tests/feature_tests/example/behaviour_example.rb +100 -0
- data/lib/tdriver-devtools/tests/feature_tests/generate.rb +82 -0
- data/lib/tdriver-devtools/tests/feature_tests/lib/custom_rdoc_generator.rb +468 -0
- data/lib/tdriver-devtools/tests/feature_tests/templates/feature_attribute.template +5 -0
- data/lib/tdriver-devtools/tests/feature_tests/templates/feature_method.template +5 -0
- data/lib/tdriver-devtools/tests/feature_tests/templates/scenario_attribute.template +5 -0
- data/lib/tdriver-devtools/tests/feature_tests/templates/scenario_method.template +5 -0
- data/lib/tdriver-devtools/tests/feature_tests/update +3 -0
- data/lib/tdriver.rb +23 -0
- data/lib/tdriver/base/behaviour/abstract.rb +29 -0
- data/lib/tdriver/base/behaviour/behaviours/object_abstract.rb +107 -0
- data/lib/tdriver/base/behaviour/behaviours/object_behaviour_composition.rb +99 -0
- data/lib/tdriver/base/behaviour/behaviours/object_behaviour_description.rb +278 -0
- data/lib/tdriver/base/behaviour/behaviours/object_composition.rb +119 -0
- data/lib/tdriver/base/behaviour/factory.rb +495 -0
- data/lib/tdriver/base/behaviour/loader.rb +46 -0
- data/lib/tdriver/base/command_data/command_data.rb +51 -0
- data/lib/tdriver/base/command_data/loader.rb +29 -0
- data/lib/tdriver/base/controller/abstraction.rb +56 -0
- data/lib/tdriver/base/controller/loader.rb +21 -0
- data/lib/tdriver/base/errors.rb +134 -0
- data/lib/tdriver/base/loader.rb +47 -0
- data/lib/tdriver/base/state_object.rb +373 -0
- data/lib/tdriver/base/sut/adapter.rb +54 -0
- data/lib/tdriver/base/sut/controller.rb +151 -0
- data/lib/tdriver/base/sut/factory.rb +339 -0
- data/lib/tdriver/base/sut/generic/behaviours/agent.rb +77 -0
- data/lib/tdriver/base/sut/generic/behaviours/application.rb +427 -0
- data/lib/tdriver/base/sut/generic/behaviours/controller.rb +67 -0
- data/lib/tdriver/base/sut/generic/behaviours/find.rb +107 -0
- data/lib/tdriver/base/sut/generic/behaviours/flash_behaviour.rb +337 -0
- data/lib/tdriver/base/sut/generic/behaviours/sut.rb +1888 -0
- data/lib/tdriver/base/sut/generic/behaviours/switchbox_behaviour.rb +210 -0
- data/lib/tdriver/base/sut/generic/behaviours/verification.rb +222 -0
- data/lib/tdriver/base/sut/generic/commands/agent.rb +43 -0
- data/lib/tdriver/base/sut/generic/commands/application.rb +274 -0
- data/lib/tdriver/base/sut/generic/commands/fixture.rb +47 -0
- data/lib/tdriver/base/sut/generic/commands/key_sequence.rb +94 -0
- data/lib/tdriver/base/sut/generic/commands/screen_capture.rb +64 -0
- data/lib/tdriver/base/sut/generic/plugin.rb +97 -0
- data/lib/tdriver/base/sut/loader.rb +35 -0
- data/lib/tdriver/base/sut/sut.rb +98 -0
- data/lib/tdriver/base/test_object/abstract.rb +208 -0
- data/lib/tdriver/base/test_object/adapter.rb +740 -0
- data/lib/tdriver/base/test_object/behaviours/syncronization.rb +144 -0
- data/lib/tdriver/base/test_object/behaviours/test_object.rb +1047 -0
- data/lib/tdriver/base/test_object/cache.rb +134 -0
- data/lib/tdriver/base/test_object/factory.rb +684 -0
- data/lib/tdriver/base/test_object/loader.rb +51 -0
- data/lib/tdriver/base/test_object/verification.rb +178 -0
- data/lib/tdriver/base/test_object/xml/abstraction.rb +63 -0
- data/lib/tdriver/base/test_object/xml/adapter.rb +773 -0
- data/lib/tdriver/env.rb +21 -0
- data/lib/tdriver/loader.rb +57 -0
- data/lib/tdriver/matti.rb +35 -0
- data/lib/tdriver/report/error_recovery/tdriver_custom_error_recovery.rb +83 -0
- data/lib/tdriver/report/error_recovery/tdriver_error_recovery.rb +168 -0
- data/lib/tdriver/report/error_recovery/tdriver_error_recovery_settings.rb +106 -0
- data/lib/tdriver/report/report.rb +61 -0
- data/lib/tdriver/report/report_api.rb +348 -0
- data/lib/tdriver/report/report_combine.rb +86 -0
- data/lib/tdriver/report/report_crash_file_capture.rb +178 -0
- data/lib/tdriver/report/report_creator.rb +665 -0
- data/lib/tdriver/report/report_cucumber.rb +158 -0
- data/lib/tdriver/report/report_cucumber_listener.rb +184 -0
- data/lib/tdriver/report/report_cucumber_reporter.rb +181 -0
- data/lib/tdriver/report/report_data_presentation.rb +156 -0
- data/lib/tdriver/report/report_data_table.rb +64 -0
- data/lib/tdriver/report/report_execution_statistics.rb +400 -0
- data/lib/tdriver/report/report_file_capture.rb +159 -0
- data/lib/tdriver/report/report_graph_generator.rb +59 -0
- data/lib/tdriver/report/report_grouping.rb +541 -0
- data/lib/tdriver/report/report_javascript.rb +199 -0
- data/lib/tdriver/report/report_junit_xml.rb +147 -0
- data/lib/tdriver/report/report_rspec.rb +108 -0
- data/lib/tdriver/report/report_test_case_run.rb +725 -0
- data/lib/tdriver/report/report_test_run.rb +1476 -0
- data/lib/tdriver/report/report_test_unit.rb +223 -0
- data/lib/tdriver/report/report_writer.rb +1621 -0
- data/lib/tdriver/tdriver.rb +209 -0
- data/lib/tdriver/util/agent/loader.rb +22 -0
- data/lib/tdriver/util/agent/service.rb +107 -0
- data/lib/tdriver/util/common/array.rb +39 -0
- data/lib/tdriver/util/common/boolean.rb +48 -0
- data/lib/tdriver/util/common/crc16.rb +149 -0
- data/lib/tdriver/util/common/environment.rb +154 -0
- data/lib/tdriver/util/common/error.rb +40 -0
- data/lib/tdriver/util/common/exception.rb +53 -0
- data/lib/tdriver/util/common/exceptions.rb +12 -0
- data/lib/tdriver/util/common/file.rb +328 -0
- data/lib/tdriver/util/common/gem.rb +109 -0
- data/lib/tdriver/util/common/hash.rb +288 -0
- data/lib/tdriver/util/common/kernel.rb +253 -0
- data/lib/tdriver/util/common/loader.rb +47 -0
- data/lib/tdriver/util/common/numeric.rb +159 -0
- data/lib/tdriver/util/common/object.rb +159 -0
- data/lib/tdriver/util/common/retryable.rb +179 -0
- data/lib/tdriver/util/common/stackable.rb +185 -0
- data/lib/tdriver/util/common/string.rb +174 -0
- data/lib/tdriver/util/database/access.rb +240 -0
- data/lib/tdriver/util/database/connection.rb +44 -0
- data/lib/tdriver/util/database/error.rb +34 -0
- data/lib/tdriver/util/database/loader.rb +28 -0
- data/lib/tdriver/util/filters/attribute_filter.rb +121 -0
- data/lib/tdriver/util/filters/loader.rb +29 -0
- data/lib/tdriver/util/fixture/loader.rb +22 -0
- data/lib/tdriver/util/fixture/service.rb +211 -0
- data/lib/tdriver/util/hooking/hooking.rb +477 -0
- data/lib/tdriver/util/keymap/keymap.rb +81 -0
- data/lib/tdriver/util/loader.rb +80 -0
- data/lib/tdriver/util/localisation/error.rb +31 -0
- data/lib/tdriver/util/localisation/loader.rb +25 -0
- data/lib/tdriver/util/localisation/localisation.rb +762 -0
- data/lib/tdriver/util/logger/loader.rb +22 -0
- data/lib/tdriver/util/logger/logger.rb +591 -0
- data/lib/tdriver/util/operator_data/error.rb +29 -0
- data/lib/tdriver/util/operator_data/loader.rb +27 -0
- data/lib/tdriver/util/operator_data/operator_data.rb +93 -0
- data/lib/tdriver/util/other/config.rb +221 -0
- data/lib/tdriver/util/parameter/error.rb +48 -0
- data/lib/tdriver/util/parameter/loader.rb +25 -0
- data/lib/tdriver/util/parameter/parameter.rb +1161 -0
- data/lib/tdriver/util/plugin/abstract.rb +61 -0
- data/lib/tdriver/util/plugin/error.rb +0 -0
- data/lib/tdriver/util/plugin/loader.rb +28 -0
- data/lib/tdriver/util/plugin/service.rb +319 -0
- data/lib/tdriver/util/recorder/loader.rb +25 -0
- data/lib/tdriver/util/recorder/recorder.rb +72 -0
- data/lib/tdriver/util/recorder/scripter.rb +294 -0
- data/lib/tdriver/util/statistics/statistics.rb +89 -0
- data/lib/tdriver/util/user_data/error.rb +28 -0
- data/lib/tdriver/util/user_data/loader.rb +25 -0
- data/lib/tdriver/util/user_data/user_data.rb +104 -0
- data/lib/tdriver/util/video/camera.rb +67 -0
- data/lib/tdriver/util/video/camera_linux.rb +153 -0
- data/lib/tdriver/util/video/camera_windows.rb +174 -0
- data/lib/tdriver/util/video/loader.rb +31 -0
- data/lib/tdriver/util/video/video_utils.rb +139 -0
- data/lib/tdriver/util/xml/abstraction.rb +117 -0
- data/lib/tdriver/util/xml/attribute.rb +32 -0
- data/lib/tdriver/util/xml/builder.rb +53 -0
- data/lib/tdriver/util/xml/comment.rb +32 -0
- data/lib/tdriver/util/xml/document.rb +32 -0
- data/lib/tdriver/util/xml/element.rb +32 -0
- data/lib/tdriver/util/xml/error.rb +46 -0
- data/lib/tdriver/util/xml/loader.rb +62 -0
- data/lib/tdriver/util/xml/nil_node.rb +95 -0
- data/lib/tdriver/util/xml/nodeset.rb +32 -0
- data/lib/tdriver/util/xml/parsers/libxml/libxml.rb +140 -0
- data/lib/tdriver/util/xml/parsers/loader.rb +21 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/abstraction.rb +167 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/attribute.rb +66 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/builder.rb +64 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/comment.rb +39 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/document.rb +66 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/element.rb +39 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/loader.rb +58 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/node.rb +212 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/nodeset.rb +237 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/text.rb +39 -0
- data/lib/tdriver/util/xml/text.rb +32 -0
- data/lib/tdriver/util/xml/xml.rb +332 -0
- data/lib/tdriver/verify/verify.rb +2398 -0
- data/lib/tdriver/version.rb +21 -0
- data/xml/behaviours/generic.xml +530 -0
- data/xml/defaults/generic.xml +11 -0
- data/xml/defaults/sut_generic.xml +8 -0
- data/xml/parameters/tdriver_parameters.xml +23 -0
- data/xml/templates/generic.xml +292 -0
- metadata +324 -0
@@ -0,0 +1,194 @@
|
|
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
|
+
# generated behaviour implementation
|
21
|
+
module MobyBehaviour
|
22
|
+
|
23
|
+
# == description
|
24
|
+
# This module contains example implementation containing tags for documentation generation
|
25
|
+
#
|
26
|
+
# == behaviour
|
27
|
+
# QtExampleBehaviour
|
28
|
+
#
|
29
|
+
# == requires
|
30
|
+
# testability-driver-sut-qt-plugin
|
31
|
+
#
|
32
|
+
# == input_type
|
33
|
+
# *
|
34
|
+
#
|
35
|
+
# == sut_type
|
36
|
+
# qt
|
37
|
+
#
|
38
|
+
# == sut_version
|
39
|
+
# *
|
40
|
+
#
|
41
|
+
# == objects
|
42
|
+
# *;sut
|
43
|
+
#
|
44
|
+
module Example
|
45
|
+
|
46
|
+
include MobyBehaviour::Behaviour
|
47
|
+
|
48
|
+
private # construction
|
49
|
+
|
50
|
+
# this method will be called once module is extended to test object
|
51
|
+
def self.extended( object )
|
52
|
+
|
53
|
+
object.instance_exec{
|
54
|
+
|
55
|
+
# default settings (optional)
|
56
|
+
initialize_behaviour_settings
|
57
|
+
|
58
|
+
}
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
# this method will be called once behaviour is extended to test object
|
63
|
+
def initialize_behaviour_settings
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
public # behaviours
|
68
|
+
|
69
|
+
# TODO: jotain
|
70
|
+
# this line won't be documented
|
71
|
+
#
|
72
|
+
# == description
|
73
|
+
# Cause a drag operation on the screen. Basically the same as flick or gesture but done slowly.
|
74
|
+
#
|
75
|
+
# == arguments
|
76
|
+
# direction
|
77
|
+
# description: Angle of direction of the drag. Supported range is from 0 to 360
|
78
|
+
# example: 180
|
79
|
+
# default:
|
80
|
+
#
|
81
|
+
# direction
|
82
|
+
# type: Symbol
|
83
|
+
# description: Symbol of direction of the drag. See Valid drag direction symbols table for valid values.
|
84
|
+
# example: :Right
|
85
|
+
# default: :Left
|
86
|
+
#
|
87
|
+
# distance
|
88
|
+
# type: Integer
|
89
|
+
# description: Distance in pixels of the drag motion
|
90
|
+
# example: 10
|
91
|
+
# default:
|
92
|
+
#
|
93
|
+
# button
|
94
|
+
# type: Symbol
|
95
|
+
# description: Symbol of button used for drag. See Valid drag button symbols table for valid values.
|
96
|
+
# example: :Left
|
97
|
+
# default: :Left
|
98
|
+
#
|
99
|
+
# == returns
|
100
|
+
# MobyBase::TestObject
|
101
|
+
# description: Target test object
|
102
|
+
# example:
|
103
|
+
#
|
104
|
+
# MobyBase::TestObject2
|
105
|
+
# description: Target test object2
|
106
|
+
# example: example2
|
107
|
+
#
|
108
|
+
# == exceptions
|
109
|
+
# MobyBase::TestObjectNotFoundError
|
110
|
+
# description: If a graphics item is not visible on screen
|
111
|
+
# lisäää descriptionia
|
112
|
+
#
|
113
|
+
# ArgumentError
|
114
|
+
# description: If an invalid direction or button is given
|
115
|
+
#
|
116
|
+
# == example
|
117
|
+
# # Drag QGraphicsItem with tooltip 'node1' down 50 pixels
|
118
|
+
# @sut.application.GraphWidget.QGraphicsItem(:tooltip => 'node1').drag(:Down, 50)
|
119
|
+
#
|
120
|
+
# # Drag 'test_object' up 200 pixels
|
121
|
+
# @test_object = @sut.application.GraphWidget.QGraphicsItem(:tooltip => 'node1')
|
122
|
+
# @test_object.drag(:Up, 200)
|
123
|
+
#
|
124
|
+
# == see
|
125
|
+
# flick, gesture
|
126
|
+
def drag( direction, distance, button = :Left )
|
127
|
+
|
128
|
+
# implementation
|
129
|
+
|
130
|
+
end
|
131
|
+
=begin
|
132
|
+
# documentation for the method
|
133
|
+
def []=( value )
|
134
|
+
|
135
|
+
# implementation
|
136
|
+
|
137
|
+
end
|
138
|
+
|
139
|
+
# documentation for the method
|
140
|
+
def []( value )
|
141
|
+
|
142
|
+
# implementation
|
143
|
+
|
144
|
+
end
|
145
|
+
|
146
|
+
# documentation for the method
|
147
|
+
def d
|
148
|
+
|
149
|
+
# implementation
|
150
|
+
|
151
|
+
end
|
152
|
+
|
153
|
+
# documentation for the method
|
154
|
+
def <=>( other )
|
155
|
+
|
156
|
+
# implementation
|
157
|
+
|
158
|
+
end
|
159
|
+
|
160
|
+
# documentation for the method
|
161
|
+
def e()
|
162
|
+
|
163
|
+
# implementation
|
164
|
+
|
165
|
+
end
|
166
|
+
|
167
|
+
# documentation for the method
|
168
|
+
def f!()
|
169
|
+
|
170
|
+
# implementation
|
171
|
+
|
172
|
+
end
|
173
|
+
|
174
|
+
# documentation for the method
|
175
|
+
def g?()
|
176
|
+
|
177
|
+
# implementation
|
178
|
+
|
179
|
+
end
|
180
|
+
|
181
|
+
# documentation for the method
|
182
|
+
def x# dada
|
183
|
+
|
184
|
+
# implementation
|
185
|
+
|
186
|
+
end
|
187
|
+
=end
|
188
|
+
attr_accessor :xxz
|
189
|
+
|
190
|
+
attr_reader :yys
|
191
|
+
|
192
|
+
end # Example
|
193
|
+
|
194
|
+
end # MobyBehaviour
|
@@ -0,0 +1,95 @@
|
|
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
|
+
#!/usr/bin/env ruby
|
20
|
+
require 'rdoc/rdoc'
|
21
|
+
|
22
|
+
# delete doc
|
23
|
+
#`rm -rf doc`
|
24
|
+
|
25
|
+
module RDoc
|
26
|
+
|
27
|
+
=begin
|
28
|
+
class Stats
|
29
|
+
|
30
|
+
alias old_print print
|
31
|
+
|
32
|
+
def print(*args)
|
33
|
+
|
34
|
+
puts "---------------"
|
35
|
+
|
36
|
+
old_print
|
37
|
+
|
38
|
+
puts ""
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
=end
|
44
|
+
|
45
|
+
class RDoc
|
46
|
+
|
47
|
+
# install custom generator to RDoc
|
48
|
+
def install_generator( name, filename )
|
49
|
+
|
50
|
+
GENERATORS[ name.to_s.downcase ] = Generator.new(
|
51
|
+
filename,
|
52
|
+
"#{ name.to_s }Generator".intern,
|
53
|
+
name.to_s.downcase
|
54
|
+
)
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
if ARGV.count == 0
|
63
|
+
|
64
|
+
puts "\nUsage: #{ $0 } filename.rb\n\n"
|
65
|
+
exit
|
66
|
+
|
67
|
+
else
|
68
|
+
|
69
|
+
ARGV.each{ | filename |
|
70
|
+
|
71
|
+
abort("\nUnable to create behaviours XML due to implementation file %s not found\n\n" % [ filename ] ) unless File.exist?( File.expand_path( filename ) )
|
72
|
+
|
73
|
+
}
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
begin
|
78
|
+
|
79
|
+
RDoc::RDoc.new.tap{ | rdoc |
|
80
|
+
|
81
|
+
rdoc.install_generator( 'TDriver', File.expand_path( File.join( File.dirname( __FILE__ ), 'lib/tdriver_generator.rb' ) ) )
|
82
|
+
|
83
|
+
#rdoc.document( ['--inline-source', '--quiet', '--fmt', 'tdriver'] + ARGV )
|
84
|
+
rdoc.document( ['--inline-source', '--fmt', 'tdriver'] + ARGV )
|
85
|
+
|
86
|
+
}
|
87
|
+
|
88
|
+
rescue RDoc::RDocError => e
|
89
|
+
|
90
|
+
$stderr.puts e.message
|
91
|
+
|
92
|
+
exit( 1 )
|
93
|
+
|
94
|
+
end
|
95
|
+
|
@@ -0,0 +1,722 @@
|
|
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 Generators
|
21
|
+
|
22
|
+
abort("") unless defined?( RDoc )
|
23
|
+
|
24
|
+
class TDriverGenerator
|
25
|
+
|
26
|
+
TYPE = {
|
27
|
+
|
28
|
+
:file => 1,
|
29
|
+
:class => 2,
|
30
|
+
:module => 3
|
31
|
+
|
32
|
+
}
|
33
|
+
|
34
|
+
VISIBILITY = {
|
35
|
+
|
36
|
+
:public => 1,
|
37
|
+
:private => 2,
|
38
|
+
:protected => 3
|
39
|
+
|
40
|
+
}
|
41
|
+
|
42
|
+
PROCESS_METHODS = {
|
43
|
+
|
44
|
+
:method_list => :process_method,
|
45
|
+
:aliases => :process_alias,
|
46
|
+
:constants => :process_constant,
|
47
|
+
:requires => :process_require,
|
48
|
+
:includes => :process_include,
|
49
|
+
:attributes => :process_attribute
|
50
|
+
|
51
|
+
}
|
52
|
+
|
53
|
+
def TDriverGenerator.for( options )
|
54
|
+
|
55
|
+
new( options )
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
def initialize( options ) #:not-new:
|
60
|
+
|
61
|
+
@options = options
|
62
|
+
|
63
|
+
@current_behaviour = nil
|
64
|
+
|
65
|
+
@behaviours = {}
|
66
|
+
|
67
|
+
# set up a hash to keep track of all the classes/modules we have processed
|
68
|
+
@already_processed = {}
|
69
|
+
|
70
|
+
@module_template = template( "templates/behaviour.module" )
|
71
|
+
@method_template = template( "templates/behaviour.method" )
|
72
|
+
|
73
|
+
@xml_behaviour_template = template( "templates/behaviour.xml" )
|
74
|
+
@xml_method_template = template( "templates/behaviour.xml.method" )
|
75
|
+
@xml_argument_template = template( "templates/behaviour.xml.argument" )
|
76
|
+
@xml_argument_type_template = template( "templates/behaviour.xml.argument_type" )
|
77
|
+
@xml_exception_template = template( "templates/behaviour.xml.exception" )
|
78
|
+
@xml_howto_template = template( "templates/behaviour.xml.howto" )
|
79
|
+
@xml_howto_line_template = template( "templates/behaviour.xml.howto.line" )
|
80
|
+
|
81
|
+
|
82
|
+
# set up a hash to keep track of all of the objects to be output
|
83
|
+
@output = {
|
84
|
+
:files => [],
|
85
|
+
:classes => [],
|
86
|
+
:modules => [],
|
87
|
+
:attributes => [],
|
88
|
+
:methods => [],
|
89
|
+
:aliases => [],
|
90
|
+
:constants => [],
|
91
|
+
:requires => [],
|
92
|
+
:includes => []
|
93
|
+
}
|
94
|
+
end
|
95
|
+
|
96
|
+
# Rdoc passes in TopLevel objects from the code_objects.rb tree (all files)
|
97
|
+
def generate( files )
|
98
|
+
|
99
|
+
# Each object passed in is a file, process it
|
100
|
+
files.each { | file |
|
101
|
+
|
102
|
+
process_file( file )
|
103
|
+
|
104
|
+
}
|
105
|
+
|
106
|
+
end
|
107
|
+
|
108
|
+
private
|
109
|
+
|
110
|
+
def process_comment( comment )
|
111
|
+
|
112
|
+
hash = { :nodoc => [] }
|
113
|
+
|
114
|
+
section = :nodoc # hash.keys.first
|
115
|
+
|
116
|
+
comment.lines.each{ | line |
|
117
|
+
|
118
|
+
# remove line feed
|
119
|
+
line.gsub!( /\n/, '' )
|
120
|
+
|
121
|
+
#match = nil
|
122
|
+
|
123
|
+
#if /^\s*#[ ]*(.*)$/.match( line )
|
124
|
+
if /^\s*#\s(.*)$/.match( line )
|
125
|
+
|
126
|
+
match = $1
|
127
|
+
|
128
|
+
if /^==\s{1,}(.*)\s*$/.match( match )
|
129
|
+
|
130
|
+
section = $1.gsub( /\s/, '_' ).to_sym
|
131
|
+
|
132
|
+
hash[ section ] = []
|
133
|
+
|
134
|
+
next
|
135
|
+
|
136
|
+
end
|
137
|
+
|
138
|
+
end
|
139
|
+
|
140
|
+
hash[ section ] << match.rstrip unless section.nil? || match.nil? || match.empty?
|
141
|
+
|
142
|
+
}
|
143
|
+
|
144
|
+
hash
|
145
|
+
|
146
|
+
end
|
147
|
+
|
148
|
+
def parse_to_sections( array )
|
149
|
+
|
150
|
+
result = []
|
151
|
+
|
152
|
+
tag = nil
|
153
|
+
|
154
|
+
array.each{ | line |
|
155
|
+
|
156
|
+
if /^\w/.match( line )
|
157
|
+
|
158
|
+
result << { :section => line }
|
159
|
+
|
160
|
+
tag = nil
|
161
|
+
|
162
|
+
end
|
163
|
+
|
164
|
+
if /^\s/.match( line )
|
165
|
+
|
166
|
+
raise RuntimeError.new( "No section defined for '%s' in method '%s'" % [ line, $current_method ] ) if result.last.nil?
|
167
|
+
|
168
|
+
#if /^\s{1}(\w+)\s*(.*)$/.match( line )
|
169
|
+
if /^\s+(\w+):\s*(.*)$/.match( line )
|
170
|
+
|
171
|
+
tag = $1
|
172
|
+
|
173
|
+
value = $2.strip
|
174
|
+
|
175
|
+
elsif /^\s+(.*)$/.match( line )
|
176
|
+
|
177
|
+
raise RuntimeError.new( "No tag defined for '%s' in method '%s'" % [ line, $current_method ] ) unless tag
|
178
|
+
|
179
|
+
value = $1.strip
|
180
|
+
|
181
|
+
end
|
182
|
+
|
183
|
+
# store empty array to tag key if none already exists
|
184
|
+
( result.last[ tag.to_sym ] ||= [] ).tap{ | values |
|
185
|
+
|
186
|
+
values.concat( [ value ] )
|
187
|
+
|
188
|
+
}
|
189
|
+
|
190
|
+
end
|
191
|
+
}
|
192
|
+
|
193
|
+
result
|
194
|
+
|
195
|
+
end
|
196
|
+
=begin
|
197
|
+
def parse_to_sections_debug( array )
|
198
|
+
|
199
|
+
result = []
|
200
|
+
|
201
|
+
tag = nil
|
202
|
+
|
203
|
+
array.each{ | line |
|
204
|
+
|
205
|
+
if /^\w/.match( line )
|
206
|
+
|
207
|
+
result << { :section => line }
|
208
|
+
|
209
|
+
tag = nil
|
210
|
+
|
211
|
+
end
|
212
|
+
|
213
|
+
if /^\s/.match( line )
|
214
|
+
|
215
|
+
raise RuntimeError.new( "No section defined for '%s'" % [ line ] ) if result.last.nil?
|
216
|
+
|
217
|
+
puts "S1: " << line.inspect
|
218
|
+
#if /^\s{1}(\w+)\s*(.*)$/.match( line )
|
219
|
+
if /^\s+(\w+):\s*(.*)$/.match( line )
|
220
|
+
|
221
|
+
puts "S1-a: " << line.inspect
|
222
|
+
tag = $1
|
223
|
+
|
224
|
+
value = $2.strip
|
225
|
+
|
226
|
+
elsif /^\s+(.*)$/.match( line )
|
227
|
+
|
228
|
+
puts "S1-b: " << line.inspect
|
229
|
+
raise RuntimeError.new( "No tag defined for '%s'" % [ line ] ) unless tag
|
230
|
+
|
231
|
+
value = $1.strip
|
232
|
+
|
233
|
+
end
|
234
|
+
|
235
|
+
puts "V: " << value.inspect
|
236
|
+
|
237
|
+
# store empty array to tag key if none already exists
|
238
|
+
( result.last[ tag.to_sym ] ||= [] ).tap{ | values |
|
239
|
+
|
240
|
+
values.concat( [ value ] )
|
241
|
+
|
242
|
+
}
|
243
|
+
|
244
|
+
end
|
245
|
+
}
|
246
|
+
|
247
|
+
puts "R: " << result.inspect
|
248
|
+
|
249
|
+
result
|
250
|
+
|
251
|
+
end
|
252
|
+
=end
|
253
|
+
def process_header_comment( module_header )
|
254
|
+
|
255
|
+
# process data
|
256
|
+
module_header.each_pair{ | key, value |
|
257
|
+
|
258
|
+
case key
|
259
|
+
|
260
|
+
when :behaviour, :description, :nodoc
|
261
|
+
# do nothing
|
262
|
+
|
263
|
+
when :objects, :sut_type, :sut_version, :input_type, :requires
|
264
|
+
|
265
|
+
module_header[ key ] = value.to_s.split(";")
|
266
|
+
|
267
|
+
else
|
268
|
+
|
269
|
+
puts "Unknown module header tag: %s" % key
|
270
|
+
|
271
|
+
end
|
272
|
+
|
273
|
+
}
|
274
|
+
|
275
|
+
end
|
276
|
+
|
277
|
+
def process_method_comment( method )
|
278
|
+
|
279
|
+
#p array
|
280
|
+
|
281
|
+
#p array.class
|
282
|
+
|
283
|
+
#array.each{ | method |
|
284
|
+
|
285
|
+
#p method
|
286
|
+
|
287
|
+
method.each_pair{ | key, value |
|
288
|
+
|
289
|
+
#p key, value
|
290
|
+
|
291
|
+
#next
|
292
|
+
|
293
|
+
case key
|
294
|
+
|
295
|
+
when :nodoc, :method_name
|
296
|
+
|
297
|
+
# do nothing
|
298
|
+
method[ key ] = value.to_s.strip
|
299
|
+
|
300
|
+
when :example, :description, :info
|
301
|
+
|
302
|
+
method[ key ] = value.join('\n')
|
303
|
+
|
304
|
+
when :see
|
305
|
+
method[ key ] = value.to_s.gsub(/\s+/, "").split(",")
|
306
|
+
|
307
|
+
when :returns, :exceptions, :howto
|
308
|
+
|
309
|
+
method[ key ] = parse_to_sections( value )
|
310
|
+
|
311
|
+
when :arguments
|
312
|
+
|
313
|
+
method[ key ] = parse_arguments( value )
|
314
|
+
|
315
|
+
else
|
316
|
+
|
317
|
+
puts "Unknown method header tag: %s" % key
|
318
|
+
|
319
|
+
end
|
320
|
+
|
321
|
+
}
|
322
|
+
|
323
|
+
#}
|
324
|
+
|
325
|
+
method
|
326
|
+
#array
|
327
|
+
|
328
|
+
end
|
329
|
+
|
330
|
+
def parse_arguments( arguments )
|
331
|
+
|
332
|
+
args = {}
|
333
|
+
|
334
|
+
result = []
|
335
|
+
last_key = nil
|
336
|
+
|
337
|
+
tag = nil
|
338
|
+
|
339
|
+
arguments.each{ | line |
|
340
|
+
|
341
|
+
if /^\w/.match( line )
|
342
|
+
|
343
|
+
if !last_key.nil?
|
344
|
+
|
345
|
+
args[ last_key ] = parse_to_sections( args[ last_key ] )
|
346
|
+
|
347
|
+
end
|
348
|
+
|
349
|
+
last_key = line.strip.to_sym
|
350
|
+
args[ last_key ] = []
|
351
|
+
|
352
|
+
tag = nil
|
353
|
+
|
354
|
+
end
|
355
|
+
|
356
|
+
|
357
|
+
if /^\s/.match( line )
|
358
|
+
|
359
|
+
if /^\s+(\w+):\s*(.*)$/.match( line )
|
360
|
+
|
361
|
+
args[ last_key ] << line
|
362
|
+
|
363
|
+
elsif /^\s+(.*)$/.match( line )
|
364
|
+
|
365
|
+
args[ last_key ] << line.strip
|
366
|
+
|
367
|
+
end
|
368
|
+
|
369
|
+
end
|
370
|
+
|
371
|
+
}
|
372
|
+
|
373
|
+
if !last_key.nil?
|
374
|
+
|
375
|
+
args[ last_key ] = parse_to_sections( args[ last_key ] )
|
376
|
+
|
377
|
+
end
|
378
|
+
|
379
|
+
args
|
380
|
+
|
381
|
+
end
|
382
|
+
|
383
|
+
def apply_macros( template_string, macros )
|
384
|
+
|
385
|
+
template_string.clone.tap{ | template |
|
386
|
+
|
387
|
+
macros.each{ | hash |
|
388
|
+
|
389
|
+
h = hash[ :value ]
|
390
|
+
|
391
|
+
h = h.first if h.kind_of?( Array )
|
392
|
+
|
393
|
+
h ||= ""
|
394
|
+
|
395
|
+
template.gsub!( hash[ :key ], h )
|
396
|
+
|
397
|
+
}
|
398
|
+
|
399
|
+
}
|
400
|
+
|
401
|
+
end
|
402
|
+
|
403
|
+
def encode_string( string )
|
404
|
+
|
405
|
+
result = "%s" % string
|
406
|
+
|
407
|
+
result.gsub!( '&', '&')
|
408
|
+
result.gsub!( '<', '<')
|
409
|
+
result.gsub!( '>', '>')
|
410
|
+
|
411
|
+
result
|
412
|
+
|
413
|
+
end
|
414
|
+
|
415
|
+
def behaviour_methods_arguments( arguments )
|
416
|
+
|
417
|
+
#puts "ARG-in: " << arguments.inspect
|
418
|
+
|
419
|
+
arg_out = ""
|
420
|
+
if !arguments.empty?
|
421
|
+
arguments.each_pair do | arg_key, arg_value |
|
422
|
+
arg_out += apply_macros(
|
423
|
+
@xml_argument_template,
|
424
|
+
[
|
425
|
+
{ :key => '$ARGUMENT_NAME', :value => encode_string( arg_key.to_s ) },
|
426
|
+
{ :key => '$METHOD_ARGUMENT_TYPES', :value => behaviour_methods_argument_types( arg_value ) }
|
427
|
+
]
|
428
|
+
)
|
429
|
+
end
|
430
|
+
end
|
431
|
+
|
432
|
+
arg_out
|
433
|
+
|
434
|
+
end
|
435
|
+
|
436
|
+
def behaviour_methods_argument_types( types )
|
437
|
+
|
438
|
+
( types || [] ).collect{ | type |
|
439
|
+
|
440
|
+
apply_macros(
|
441
|
+
@xml_argument_type_template,
|
442
|
+
[
|
443
|
+
{ :key => '$ARGUMENT_TYPE', :value => encode_string( type[ :section ].first ) },
|
444
|
+
{ :key => '$ARGUMENT_DESCRIPTION', :value => encode_string( type[ :description ].join( '\n' ) ) },
|
445
|
+
{ :key => '$ARGUMENT_EXAMPLE', :value => encode_string( type[ :example ].first ) },
|
446
|
+
{ :key => '$ARGUMENT_DEFAULT', :value => encode_string( type[ :default ].first ) }
|
447
|
+
|
448
|
+
]
|
449
|
+
|
450
|
+
)
|
451
|
+
|
452
|
+
}.join()
|
453
|
+
|
454
|
+
end
|
455
|
+
|
456
|
+
def behaviour_methods_exceptions( exceptions )
|
457
|
+
|
458
|
+
( exceptions || [] ).collect{ | exception |
|
459
|
+
|
460
|
+
apply_macros(
|
461
|
+
@xml_exception_template,
|
462
|
+
[
|
463
|
+
{ :key => '$EXCEPTION_NAME', :value => encode_string( exception[ :section ] ) },
|
464
|
+
{ :key => '$EXCEPTION_DESCRIPTION', :value => encode_string( exception[ :description ].join('\n') ) }
|
465
|
+
|
466
|
+
]
|
467
|
+
)
|
468
|
+
}.join
|
469
|
+
|
470
|
+
end
|
471
|
+
|
472
|
+
def behaviour_methods_howtos( howtos )
|
473
|
+
|
474
|
+
( howtos || [] ).collect{ | howto |
|
475
|
+
|
476
|
+
apply_macros(
|
477
|
+
@xml_howto_template,
|
478
|
+
[
|
479
|
+
{ :key => '$HOWTO_DESCRIPTION', :value => encode_string( howto[ :description ] ) },
|
480
|
+
{ :key => '$HOWTO_CODE', :value => behaviour_methods_howto_lines( howto[ :code ] ) }
|
481
|
+
|
482
|
+
]
|
483
|
+
)
|
484
|
+
}.join
|
485
|
+
|
486
|
+
end
|
487
|
+
|
488
|
+
def behaviour_methods_howto_lines( code_lines )
|
489
|
+
|
490
|
+
( code_lines || [] ).collect{ | code_line |
|
491
|
+
|
492
|
+
apply_macros(
|
493
|
+
@xml_howto_line_template,
|
494
|
+
[
|
495
|
+
{ :key => '$HOWTO_LINE', :value => encode_string( code_line ) }
|
496
|
+
]
|
497
|
+
)
|
498
|
+
}.join
|
499
|
+
|
500
|
+
end
|
501
|
+
|
502
|
+
def behaviour_methods( methods )
|
503
|
+
|
504
|
+
methods.collect{ | method |
|
505
|
+
|
506
|
+
apply_macros(
|
507
|
+
@xml_method_template,
|
508
|
+
[
|
509
|
+
{ :key => '$METHOD_NAME', :value => encode_string( method[ :method_name ] ) },
|
510
|
+
{ :key => '$METHOD_DESCRIPTION', :value => encode_string( method[ :description ] ) },
|
511
|
+
{ :key => '$METHOD_EXAMPLE', :value => encode_string( method[ :example ] ) },
|
512
|
+
{ :key => '$METHOD_ARGUMENTS', :value => behaviour_methods_arguments( method[ :arguments ] ) },
|
513
|
+
{ :key => '$METHOD_EXCEPTIONS', :value => behaviour_methods_exceptions( method[ :exceptions ] ) },
|
514
|
+
{ :key => '$METHOD_HOWTOS', :value => behaviour_methods_howtos( method[ :howto ] ) },
|
515
|
+
{ :key => '$METHOD_INFO', :value => encode_string( method[ :info ] ) }
|
516
|
+
]
|
517
|
+
)
|
518
|
+
|
519
|
+
}.join
|
520
|
+
|
521
|
+
end
|
522
|
+
|
523
|
+
def generate_behaviour( module_header, methods )
|
524
|
+
|
525
|
+
unless module_header[ :module ].to_s == "MobyBehaviour"
|
526
|
+
|
527
|
+
xml = apply_macros(
|
528
|
+
@xml_behaviour_template,
|
529
|
+
[
|
530
|
+
{ :key => '$REQUIRED_PLUGIN', :value => module_header[ :requires ] || [].join( ";" ) },
|
531
|
+
{ :key => '$BEHAVIOUR_NAME', :value => module_header[ :behaviour ] || [].first },
|
532
|
+
{ :key => '$OBJECT_TYPE', :value => module_header[ :objects ] || [].join( ";" ) },
|
533
|
+
{ :key => '$SUT_TYPE', :value => module_header[ :sut_type ] || [].join( ";" ) },
|
534
|
+
{ :key => '$INPUT_TYPE', :value => module_header[ :input_type ] || [].join( ";" ) },
|
535
|
+
{ :key => '$VERSION', :value => module_header[ :sut_version ] || [].join( ";" ) },
|
536
|
+
{ :key => '$MODULE_NAME', :value => module_header[ :module ] },
|
537
|
+
{ :key => '$BEHAVIOUR_METHODS', :value => behaviour_methods( methods ) }
|
538
|
+
]
|
539
|
+
|
540
|
+
).gsub( /\n\n\n/, "\n\n" ) unless module_header[ :module ].to_s == "MobyBehaviour"
|
541
|
+
|
542
|
+
unless module_header[ :behaviour ].to_s.empty?
|
543
|
+
|
544
|
+
File.open( "%s.xml" % module_header[ :behaviour ], 'w'){ | file | file << xml }
|
545
|
+
|
546
|
+
puts xml
|
547
|
+
|
548
|
+
end
|
549
|
+
|
550
|
+
|
551
|
+
end
|
552
|
+
|
553
|
+
end
|
554
|
+
|
555
|
+
def process_object( file )
|
556
|
+
|
557
|
+
PROCESS_METHODS.each_pair{ | list, method |
|
558
|
+
|
559
|
+
file.send( list ).each{ | child | send( method, child ) }
|
560
|
+
|
561
|
+
}
|
562
|
+
|
563
|
+
end
|
564
|
+
|
565
|
+
# process a file from the code_object.rb tree
|
566
|
+
def process_file( file )
|
567
|
+
|
568
|
+
@current_behaviour = nil
|
569
|
+
|
570
|
+
@behaviours = {}
|
571
|
+
|
572
|
+
@output[ :files ] << file
|
573
|
+
|
574
|
+
#puts "#{file.comment}"
|
575
|
+
|
576
|
+
# Process all of the objects that this file contains
|
577
|
+
process_object( file )
|
578
|
+
|
579
|
+
# Recursively process contained subclasses and modules
|
580
|
+
file.each_classmodule do | child |
|
581
|
+
|
582
|
+
process_class_or_module( child )
|
583
|
+
|
584
|
+
end
|
585
|
+
|
586
|
+
@behaviours.each_pair{ | key, value |
|
587
|
+
|
588
|
+
generate_behaviour value[ :header ], value[ :methods ]
|
589
|
+
|
590
|
+
}
|
591
|
+
|
592
|
+
end
|
593
|
+
|
594
|
+
def template( filename )
|
595
|
+
|
596
|
+
open( File.join( File.dirname( File.expand_path( __FILE__ ) ), "..", "%s.template" % filename ) ).read
|
597
|
+
|
598
|
+
end
|
599
|
+
|
600
|
+
# Process classes and modiles
|
601
|
+
def process_class_or_module( obj )
|
602
|
+
|
603
|
+
type = obj.is_module? ? ( :modules ) : ( :classes )
|
604
|
+
|
605
|
+
if( !@already_processed.has_key?( obj.full_name ) ) then
|
606
|
+
|
607
|
+
@output[ type ].push( obj )
|
608
|
+
|
609
|
+
@already_processed[ obj.full_name ] = true
|
610
|
+
|
611
|
+
header = process_comment( obj.comment )
|
612
|
+
|
613
|
+
process_header_comment( header )
|
614
|
+
|
615
|
+
header[ :module ] = obj.full_name
|
616
|
+
|
617
|
+
@behaviours[ ( @current_behaviour = obj.full_name ) ] = {
|
618
|
+
|
619
|
+
:header => header,
|
620
|
+
|
621
|
+
:methods => []
|
622
|
+
|
623
|
+
}
|
624
|
+
|
625
|
+
# Process all of the objects that this class or module contains
|
626
|
+
process_object( obj ) if obj.full_name =~ /^MobyBehaviour::/
|
627
|
+
|
628
|
+
end
|
629
|
+
|
630
|
+
#id = @already_processed[ obj.full_name ]
|
631
|
+
# Recursively process contained subclasses and modules
|
632
|
+
|
633
|
+
obj.each_classmodule do | child |
|
634
|
+
|
635
|
+
process_class_or_module( child )
|
636
|
+
|
637
|
+
end
|
638
|
+
|
639
|
+
end
|
640
|
+
|
641
|
+
def process_method( obj )
|
642
|
+
|
643
|
+
#obj.source_code = get_source_code( obj )
|
644
|
+
|
645
|
+
if ( obj.visibility == :public )
|
646
|
+
|
647
|
+
$current_method = obj.name.to_str
|
648
|
+
|
649
|
+
comment = process_comment( obj.comment || "" )
|
650
|
+
|
651
|
+
process_method_comment( comment )
|
652
|
+
|
653
|
+
comment[ :method_name ] = obj.name.to_str
|
654
|
+
|
655
|
+
@behaviours[ @current_behaviour ][ :methods ] << comment
|
656
|
+
|
657
|
+
#puts "\n%s (%s)" % [ obj.name, obj.visibility ] #{obj.param_seq}"
|
658
|
+
|
659
|
+
#puts "#{obj.source_code}" # Source code, unformatted
|
660
|
+
#puts "====================================="
|
661
|
+
|
662
|
+
end
|
663
|
+
|
664
|
+
@output[ :methods ] << obj
|
665
|
+
|
666
|
+
end
|
667
|
+
|
668
|
+
def process_alias( obj )
|
669
|
+
|
670
|
+
@output[ :aliases ] << obj
|
671
|
+
|
672
|
+
end
|
673
|
+
|
674
|
+
def process_constant( obj )
|
675
|
+
|
676
|
+
@output[ :constants ] << obj
|
677
|
+
|
678
|
+
end
|
679
|
+
|
680
|
+
def process_attribute( obj )
|
681
|
+
|
682
|
+
#puts "\n%s (%s, %s)" % [ obj.name, obj.visibility, obj.rw ] #{obj.param_seq}"
|
683
|
+
#p process_comment( obj.comment || "" )
|
684
|
+
|
685
|
+
@output[ :attributes ] << obj
|
686
|
+
|
687
|
+
end
|
688
|
+
|
689
|
+
def process_require( obj )
|
690
|
+
|
691
|
+
@output[ :requires ] << obj
|
692
|
+
|
693
|
+
end
|
694
|
+
|
695
|
+
def process_include( obj )
|
696
|
+
|
697
|
+
@output[ :includes ] << obj
|
698
|
+
|
699
|
+
end
|
700
|
+
|
701
|
+
# get the source code
|
702
|
+
def get_source_code( method )
|
703
|
+
|
704
|
+
method.token_stream.collect{ | token |
|
705
|
+
|
706
|
+
token ? token.text : ""
|
707
|
+
|
708
|
+
}.join
|
709
|
+
|
710
|
+
end
|
711
|
+
|
712
|
+
end
|
713
|
+
|
714
|
+
# dynamically add a source code attribute to the base oject of code_objects.rb
|
715
|
+
class RDoc::AnyMethod
|
716
|
+
|
717
|
+
attr_accessor :source_code
|
718
|
+
|
719
|
+
end
|
720
|
+
|
721
|
+
end
|
722
|
+
|