drep 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/Manifest.txt +20 -0
- data/PostInstall.txt +6 -0
- data/README.rdoc +93 -0
- data/README.txt +93 -0
- data/Rakefile +44 -0
- data/assets/providers/drep_ml_provider.rb +122 -0
- data/assets/rules/drep_wa_rules.rb +151 -0
- data/assets/templates/drep_tda_template.erb +110 -0
- data/bin/drep +24 -0
- data/lib/drep/alterers/drep_extenders.rb +29 -0
- data/lib/drep/alterers/drep_helpers.rb +221 -0
- data/lib/drep/alterers/drep_validators.rb +117 -0
- data/lib/drep/core/drep_binder.rb +102 -0
- data/lib/drep/core/drep_environment.rb +47 -0
- data/lib/drep/core/drep_executer.rb +199 -0
- data/lib/drep/core/interfaces/drep_runnable.rb +22 -0
- data/lib/drep/drep_cli.rb +267 -0
- data/lib/drep.rb +48 -0
- data//321opying.txt +679 -0
- metadata +117 -0
@@ -0,0 +1,22 @@
|
|
1
|
+
# DRep - Modular Open Software Tester.
|
2
|
+
# Copyright (C) 2009 Dmitrii Toksaitov
|
3
|
+
#
|
4
|
+
# This file is part of DRep.
|
5
|
+
#
|
6
|
+
# DRep is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# DRep is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with DRep. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
|
19
|
+
module DRepRunnable
|
20
|
+
def run()
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,267 @@
|
|
1
|
+
# DRep - Modular Open Software Tester.
|
2
|
+
# Copyright (C) 2009 Dmitrii Toksaitov
|
3
|
+
#
|
4
|
+
# This file is part of DRep.
|
5
|
+
#
|
6
|
+
# DRep is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# DRep is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with DRep. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
|
19
|
+
require 'optparse'
|
20
|
+
require 'ostruct'
|
21
|
+
|
22
|
+
require 'date'
|
23
|
+
|
24
|
+
extend_load_paths __FILE__
|
25
|
+
require 'alterers/drep_helpers'
|
26
|
+
require 'alterers/drep_validators'
|
27
|
+
|
28
|
+
require 'core/interfaces/drep_runnable'
|
29
|
+
|
30
|
+
require 'core/drep_environment'
|
31
|
+
require 'core/drep_executer'
|
32
|
+
|
33
|
+
module DRep
|
34
|
+
|
35
|
+
class DRepCli
|
36
|
+
include DRepRunnable
|
37
|
+
|
38
|
+
DREP_EXEC_OPTIONS =
|
39
|
+
{:provider_flag =>
|
40
|
+
['-p', '--provider PROVIDER[;SOURCE_1[,SOURCE_2]][;RULE_1[,RULE_2]]',
|
41
|
+
'Provider path with sources and rules specifications.'],
|
42
|
+
:template_flag =>
|
43
|
+
['-t', '--template PATH[>OUTPUT_PATH]',
|
44
|
+
'Template in/out path. By default output will be flushed to "STDOUT"'],
|
45
|
+
:version_flag =>
|
46
|
+
['-v', '--version', 'Display version information and exit.'],
|
47
|
+
:help_flag =>
|
48
|
+
['-h', '--help', 'Display this help message and exit.'],
|
49
|
+
:quiet_flag =>
|
50
|
+
['-q', '--quiet', 'Start in quiet mode without any CLI messages.'],
|
51
|
+
:verbose_flag =>
|
52
|
+
['-V', '--verbose', 'Start in verbose mode (ignored in quiet mode).'],
|
53
|
+
:debug_flag =>
|
54
|
+
['-d', '--debug', 'Start in debug mode.']}
|
55
|
+
|
56
|
+
attr_reader :env
|
57
|
+
|
58
|
+
attr_reader :options
|
59
|
+
|
60
|
+
attr_reader :parser
|
61
|
+
|
62
|
+
def initialize(stdin = STDIN,
|
63
|
+
stdout = STDOUT,
|
64
|
+
stderr = STDERR, arguments = [])
|
65
|
+
@options = OpenStruct.new()
|
66
|
+
|
67
|
+
begin
|
68
|
+
env_options = [stdin, stdout, stderr, @options]
|
69
|
+
@env = DRepEnvironment.new(*env_options)
|
70
|
+
rescue Exception => e
|
71
|
+
unless @stderr.nil?
|
72
|
+
@stderr.puts("#{UNIX_NAME}: initialization failed: #{e.message}")
|
73
|
+
end
|
74
|
+
exit(1)
|
75
|
+
end
|
76
|
+
|
77
|
+
@options.arguments = arguments.nil? ? [] : arguments
|
78
|
+
|
79
|
+
@options.verbose = false
|
80
|
+
@options.quiet = false
|
81
|
+
@options.debug = false
|
82
|
+
|
83
|
+
@options.output = @stdout
|
84
|
+
|
85
|
+
@options.show_version = false
|
86
|
+
@options.show_help = false
|
87
|
+
|
88
|
+
@options.providers = []
|
89
|
+
@options.templates = []
|
90
|
+
|
91
|
+
@parser = OptionParser.new()
|
92
|
+
end
|
93
|
+
|
94
|
+
def run()
|
95
|
+
if options_parsed?()
|
96
|
+
begin
|
97
|
+
if @options.verbose
|
98
|
+
welcome_message = "#{FULL_NAME} has started"
|
99
|
+
msg("#{welcome_message}: #{DateTime.now}.")
|
100
|
+
end
|
101
|
+
|
102
|
+
perform_tasks()
|
103
|
+
|
104
|
+
if @options.verbose
|
105
|
+
end_message = "#{FULL_NAME} has finished all tasks"
|
106
|
+
msg("#{end_message}: #{DateTime.now}.")
|
107
|
+
end
|
108
|
+
rescue Exception => e
|
109
|
+
err("Execution failed: #{e.message}")
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
private
|
115
|
+
def options_parsed?()
|
116
|
+
result = true
|
117
|
+
|
118
|
+
begin
|
119
|
+
add_parser_arg(:version_flag) { @options.show_version = true }
|
120
|
+
add_parser_arg(:help_flag) { @options.show_help = true }
|
121
|
+
|
122
|
+
add_parser_arg(:verbose_flag) do
|
123
|
+
@options.verbose = true if !@options.quiet
|
124
|
+
end
|
125
|
+
add_parser_arg(:quiet_flag) do
|
126
|
+
@options.quiet = true
|
127
|
+
@options.verbose = false
|
128
|
+
end
|
129
|
+
add_parser_arg(:debug_flag) do
|
130
|
+
@options.debug = true
|
131
|
+
end
|
132
|
+
|
133
|
+
add_parser_arg(:provider_flag) do |provider_def|
|
134
|
+
add_provider(provider_def)
|
135
|
+
end
|
136
|
+
add_parser_arg(:template_flag) do |template_def|
|
137
|
+
add_template(template_def)
|
138
|
+
end
|
139
|
+
|
140
|
+
parser.parse!(@options.arguments)
|
141
|
+
|
142
|
+
rescue Exception => e
|
143
|
+
err("Argument parsing failed: #{e.message}")
|
144
|
+
result = false
|
145
|
+
end
|
146
|
+
|
147
|
+
return result
|
148
|
+
end
|
149
|
+
|
150
|
+
def add_parser_arg(arg_key, &block)
|
151
|
+
valid @parser do
|
152
|
+
if arg_key.is_a?(Symbol)
|
153
|
+
arg_def = DREP_EXEC_OPTIONS[arg_key]
|
154
|
+
else
|
155
|
+
arg_def = nil
|
156
|
+
end
|
157
|
+
if valid?(arg_def)
|
158
|
+
@parser.on(arg_def[0], arg_def[1], arg_def[2], &block)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
def perform_tasks()
|
164
|
+
if @options.show_version
|
165
|
+
output_version()
|
166
|
+
elsif @options.show_help
|
167
|
+
output_help()
|
168
|
+
else
|
169
|
+
begin
|
170
|
+
args = [@env, @options.providers, @options.templates]
|
171
|
+
DRepExecuter.new(*args).run()
|
172
|
+
rescue Exception => e
|
173
|
+
err("Report population failed: #{e.message}")
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
def output_help()
|
179
|
+
output_options()
|
180
|
+
end
|
181
|
+
|
182
|
+
def output_version()
|
183
|
+
msg("#{FULL_NAME} version #{VERSION}")
|
184
|
+
msg(COPYRIGHT)
|
185
|
+
end
|
186
|
+
|
187
|
+
def output_options()
|
188
|
+
msg("Available options: \n\n")
|
189
|
+
msg("Usage: #{UNIX_NAME} {[option] [parameter]}")
|
190
|
+
|
191
|
+
DREP_EXEC_OPTIONS.each do |name, options|
|
192
|
+
msg("\n\t#{options[2]}\n\t\t#{options[0]}, #{options[1]}")
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
def add_provider(provider_def)
|
197
|
+
if provider_def.is_a?(String)
|
198
|
+
provider_specs = {}
|
199
|
+
|
200
|
+
parts = provider_def.split(';')
|
201
|
+
valid parts do
|
202
|
+
provider_path = parts[0]
|
203
|
+
sources_list = parts[1]
|
204
|
+
rules_list = parts[2]
|
205
|
+
|
206
|
+
unless provider_path.nil?
|
207
|
+
provider_specs[:path] = provider_path
|
208
|
+
else
|
209
|
+
raise("Provider path is not specified")
|
210
|
+
end
|
211
|
+
|
212
|
+
provider_specs[:sources] = [] + parse_args(sources_list)
|
213
|
+
provider_specs[:rules] = [] + parse_args(rules_list)
|
214
|
+
end
|
215
|
+
|
216
|
+
unless provider_specs.empty?
|
217
|
+
@options.providers << provider_specs
|
218
|
+
end
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
def parse_args(args_list)
|
223
|
+
result = []
|
224
|
+
|
225
|
+
unless args_list.nil?
|
226
|
+
args = args_list.split(',')
|
227
|
+
|
228
|
+
valid args do
|
229
|
+
args.each do |arg|
|
230
|
+
result << arg unless arg.nil?
|
231
|
+
end
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
return result
|
236
|
+
end
|
237
|
+
|
238
|
+
def add_template(template_def)
|
239
|
+
if template_def.is_a?(String)
|
240
|
+
template_specs = {}
|
241
|
+
|
242
|
+
parts = template_def.split('>')
|
243
|
+
valid parts do
|
244
|
+
template_path = parts[0]
|
245
|
+
output_path = parts[1]
|
246
|
+
|
247
|
+
unless template_path.nil?
|
248
|
+
template_specs[:path] = template_path
|
249
|
+
else
|
250
|
+
raise("Template path is not specified")
|
251
|
+
end
|
252
|
+
|
253
|
+
unless output_path.nil?
|
254
|
+
template_specs[:output] = output_path
|
255
|
+
else
|
256
|
+
template_specs[:output] = @stdout
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
unless template_specs.empty?
|
261
|
+
@options.templates << template_specs
|
262
|
+
end
|
263
|
+
end
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
end
|
data/lib/drep.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# DRep - Modular Open Software Tester.
|
2
|
+
# Copyright (C) 2009 Dmitrii Toksaitov
|
3
|
+
#
|
4
|
+
# This file is part of DRep.
|
5
|
+
#
|
6
|
+
# DRep is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# DRep is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with DRep. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
|
19
|
+
require File.dirname(__FILE__) + '/drep/alterers/drep_extenders'
|
20
|
+
|
21
|
+
extend_load_paths __FILE__
|
22
|
+
require 'drep/drep_cli'
|
23
|
+
|
24
|
+
module DRep
|
25
|
+
# Name of the system
|
26
|
+
FULL_NAME = 'Dango Report'
|
27
|
+
|
28
|
+
# Unix name of the system
|
29
|
+
UNIX_NAME = 'drep'
|
30
|
+
|
31
|
+
# System version (rational version policy)
|
32
|
+
VERSION = '0.3.3'
|
33
|
+
|
34
|
+
# Full name of the author
|
35
|
+
AUTHOR = 'Toksaitov Dmitrii Alexandrovich'
|
36
|
+
|
37
|
+
# Support e-mail
|
38
|
+
EMAIL = "#{UNIX_NAME}.support@85.17.184.9"
|
39
|
+
|
40
|
+
# Official website of the system
|
41
|
+
URL = "http://85.17.184.9/#{UNIX_NAME}"
|
42
|
+
|
43
|
+
# Copyright
|
44
|
+
COPYRIGHT = "Copyright (C) 2009 #{AUTHOR}"
|
45
|
+
|
46
|
+
# Main CLI Loader
|
47
|
+
EXEC = DRepCli
|
48
|
+
end
|