Class: SaikuroRunner
- Inherits:
-
Object
- Object
- SaikuroRunner
- Includes:
- ResultIndexGenerator
- Defined in:
- lib/saikuro.rb
Overview
A runner to call from Ruby code Perfect for the inpromptue Rake task.
Instance Method Summary collapse
- #files_in_dirs(code_dirs) ⇒ Object
-
#run(*args) ⇒ Object
:call-seq: run(*args) Either runs the Saikuro analyzer over a configuration hash (see run_with_config) Or runs with standard options (in which case you need to pass files and output_dir, see run_with_standard_options).
-
#run_with_config(options) ⇒ Object
:call-seq: run(options) Runs the Saikuro analyzer over a configuration hash, which takes those arguments: - output_directory Where the analysis will be written out - filter_cyclo - warn_cyclo - error_cyclo.
-
#run_with_standard_options(files, output_dir, formater = "html") ⇒ Object
:call-seq: run(files, output_dir, formater) Runs the Saikuro analyzer over the files, and persists the information in output_dir.
Methods included from ResultIndexGenerator
#list_analyzed_files, #print_summary_table_rows, #summarize_errors_and_warnings, #write_cyclo_index, #write_index, #write_token_index
Instance Method Details
#files_in_dirs(code_dirs) ⇒ Object
1278 1279 1280 1281 |
# File 'lib/saikuro.rb', line 1278 def files_in_dirs(code_dirs) code_dirs = [code_dirs].flatten code_dirs.collect {|dir| File.directory?(dir) ? Dir["#{dir}/**/*.rb"] : dir}.flatten end |
#run(*args) ⇒ Object
:call-seq:
run(*args)
Either runs the Saikuro analyzer over a configuration hash (see run_with_config) Or runs with standard options (in which case you need to pass files and output_dir, see run_with_standard_options)
1207 1208 1209 1210 1211 1212 1213 |
# File 'lib/saikuro.rb', line 1207 def run(*args) if args.size == 1 run_with_config(*args) else (*args) end end |
#run_with_config(options) ⇒ Object
:call-seq:
run()
Runs the Saikuro analyzer over a configuration hash, which takes those arguments:
-
output_directory
Where the analysis will be written out
-
filter_cyclo
-
warn_cyclo
-
error_cyclo
-
filter_token
-
warn_token
-
error_token
-
formater
text or html. By default html.
-
code_dirs
The directories containing code to look into.
1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 |
# File 'lib/saikuro.rb', line 1243 def run_with_config() rm_rf [:output_directory] state_filter = Filter.new(5) token_filter = Filter.new(10, 25, 50) state_filter.limit = [:filter_cyclo] if [:filter_cyclo] state_filter.warn = [:warn_cyclo] if [:warn_cyclo] state_filter.error = [:error_cyclo] if [:error_cyclo] token_filter.limit = [:filter_token] if [:filter_token] token_filter.warn = [:warn_token] if [:warn_token] token_filter.error = [:error_token] if [:error_token] formater = [:formater] || "html" if formater =~ /html/i state_formater = StateHTMLComplexityFormater.new(STDOUT,state_filter) token_count_formater = HTMLTokenCounterFormater.new(STDOUT,token_filter) else state_formater = ParseStateFormater.new(STDOUT,state_filter) token_count_formater = TokenCounterFormater.new(STDOUT,token_filter) end idx_states, idx_tokens = Saikuro.analyze( files_in_dirs([:code_dirs]), state_formater, token_count_formater, [:output_directory] ) write_cyclo_index(idx_states, [:output_directory]) write_token_index(idx_tokens, [:output_directory]) end |
#run_with_standard_options(files, output_dir, formater = "html") ⇒ Object
:call-seq:
run(files, output_dir, formater)
Runs the Saikuro analyzer over the files, and persists the information in output_dir
1220 1221 1222 |
# File 'lib/saikuro.rb', line 1220 def (files, output_dir, formater = "html") run({:formater => formater, :output_directory => output_dir, :code_dirs => files}) end |