Class: Autocyclo
Defined Under Namespace
Classes: Rails
Constant Summary
Constants inherited from Auto
Instance Attribute Summary collapse
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#index_file ⇒ Object
Returns the value of attribute index_file.
-
#output_dir ⇒ Object
Returns the value of attribute output_dir.
-
#run_type ⇒ Object
Returns the value of attribute run_type.
-
#warnings ⇒ Object
Returns the value of attribute warnings.
Attributes inherited from Auto
#file_masks, #modified, #output, #sleep, #wants_to_quit, #working_dirs
Class Method Summary collapse
Instance Method Summary collapse
- #errors_and_warnings(doc) ⇒ Object
- #handle_results(stdout) ⇒ Object
-
#initialize(*args) ⇒ Autocyclo
constructor
A new instance of Autocyclo.
- #make_cmd ⇒ Object
Methods inherited from Auto
add_discovery, add_hook, autodiscover, #find_files, #hook, #last_modified_time, #method_missing, #old_method_missing, #reset, run, #run, #run_metric, #wait_for_changes
Constructor Details
#initialize(*args) ⇒ Autocyclo
Returns a new instance of Autocyclo.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/autocyclo.rb', line 21 def initialize(*args) args, = (*args) super(*args) @warning_level = [:token_run] ? 20 : 10 @error_level = [:token_run] ? 30 : 20 @run_type = [:token_run] ? "-t" : "-c" @opts = "-y 0" @output_dir = [:token_run] ? "token" : "cyclo" @index_file = [:token_run] ? "index_token.html" : "index_cyclo.html" @errors, @warnings = [], [] @working_dirs = %w( lib ) hook :initialize end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Auto
Instance Attribute Details
#errors ⇒ Object
Returns the value of attribute errors.
19 20 21 |
# File 'lib/autocyclo.rb', line 19 def errors @errors end |
#index_file ⇒ Object
Returns the value of attribute index_file.
19 20 21 |
# File 'lib/autocyclo.rb', line 19 def index_file @index_file end |
#output_dir ⇒ Object
Returns the value of attribute output_dir.
19 20 21 |
# File 'lib/autocyclo.rb', line 19 def output_dir @output_dir end |
#run_type ⇒ Object
Returns the value of attribute run_type.
19 20 21 |
# File 'lib/autocyclo.rb', line 19 def run_type @run_type end |
#warnings ⇒ Object
Returns the value of attribute warnings.
19 20 21 |
# File 'lib/autocyclo.rb', line 19 def warnings @warnings end |
Class Method Details
.meets_requirements? ⇒ Boolean
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/autocyclo.rb', line 7 def meets_requirements? begin require 'rubygems' require 'Hpricot' require 'fileutils' old_meets_requirements? rescue nil end end |
.old_meets_requirements? ⇒ Object
5 |
# File 'lib/autocyclo.rb', line 5 alias_method :old_meets_requirements?, :meets_requirements? |
Instance Method Details
#errors_and_warnings(doc) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/autocyclo.rb', line 37 def errors_and_warnings(doc) errors, warnings = [], [] complexity_table = doc / :table (complexity_table / :tr).each do |tr| tds = tr / :td unless tds.empty? || tds[2][:class].nil? sep = tds[0].inner_text =~ /::$/ ? "" : "#" if tds[2][:class] == "error" errors << { :id => "#{tds[0].inner_text}#{sep}#{tds[1].inner_text}", :rating => tds[2].inner_text.to_i } elsif tds[2][:class] == "warning" warnings << { :id => "#{tds[0].inner_text}#{sep}#{tds[1].inner_text}", :rating => tds[2].inner_text.to_i } end end end return errors, warnings end |
#handle_results(stdout) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/autocyclo.rb', line 57 def handle_results(stdout) doc = Hpricot(open("#{@output_dir}/#{@index_file}")) @errors, @warnings = errors_and_warnings(doc) @errors.sort_by {|e| e[:rating] } @warnings.sort_by {|w| w[:rating] } hook :erred unless @errors.empty? hook :warned unless @warnings.empty? FileUtils.rm_rf "./#{@output_dir}" end |
#make_cmd ⇒ Object
71 72 73 |
# File 'lib/autocyclo.rb', line 71 def make_cmd "#{saikuro} #{@run_type} -i #{@working_dirs.join(' -i ')} -w #{@warning_level} -e #{@error_level} #{@opts} -f html -o ./#{@output_dir}" end |