Class: DontRepeatYourself::SimianRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/dont_repeat_yourself/simian_runner.rb

Overview

Constant Summary collapse

DEFAULT_THRESHOLD =
3
SIMIAN_LOGFILE_NAME =
"simian_log.yaml"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSimianRunner

Returns a new instance of SimianRunner.



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/dont_repeat_yourself/simian_runner.rb', line 19

def initialize()
  @threshold = DEFAULT_THRESHOLD
  @patterns_of_directories_to_search_for_duplicate_lines, @patterns_of_directories_to_exclude_for_duplicate_lines = [], []
  @formatter_option = "-formatter=yaml"
  
  # extension is .txt because the selenium_on_rails project had a problem with jar files that could be
  # downloaded from the rubygems repository
  # In order to prevent this kind of problem, I decided to use another suffix as they did ...
  @simian_jar_path = File.join(File.dirname(__FILE__), '..', 'jars', 'simian-2.2.22.jar.txt')
  
  @executable = "java -jar #{@simian_jar_path}".freeze
        
end

Instance Attribute Details

#basedirObject

Returns the value of attribute basedir.



8
9
10
# File 'lib/dont_repeat_yourself/simian_runner.rb', line 8

def basedir
  @basedir
end

#executableObject (readonly)

Returns the value of attribute executable.



8
9
10
# File 'lib/dont_repeat_yourself/simian_runner.rb', line 8

def executable
  @executable
end

#formatter_optionObject (readonly)

Returns the value of attribute formatter_option.



8
9
10
# File 'lib/dont_repeat_yourself/simian_runner.rb', line 8

def formatter_option
  @formatter_option
end

#patterns_of_directories_to_search_for_duplicate_linesObject (readonly)

Returns the value of attribute patterns_of_directories_to_search_for_duplicate_lines.



8
9
10
# File 'lib/dont_repeat_yourself/simian_runner.rb', line 8

def patterns_of_directories_to_search_for_duplicate_lines
  @patterns_of_directories_to_search_for_duplicate_lines
end

#simian_jar_pathObject (readonly)

Returns the value of attribute simian_jar_path.



8
9
10
# File 'lib/dont_repeat_yourself/simian_runner.rb', line 8

def simian_jar_path
  @simian_jar_path
end

#simian_log_fileObject (readonly)

Returns the value of attribute simian_log_file.



8
9
10
# File 'lib/dont_repeat_yourself/simian_runner.rb', line 8

def simian_log_file
  @simian_log_file
end

#thresholdObject

Returns the value of attribute threshold.



8
9
10
# File 'lib/dont_repeat_yourself/simian_runner.rb', line 8

def threshold
  @threshold
end

Instance Method Details

#add_html_directory_to_search_for_duplicate_lines(path) ⇒ Object



51
52
53
54
# File 'lib/dont_repeat_yourself/simian_runner.rb', line 51

def add_html_directory_to_search_for_duplicate_lines(path)
  valid_directory_path(path)
  @patterns_of_directories_to_search_for_duplicate_lines << (path + "/**/*.*html")
end

#add_ruby_directory_to_search_for_duplicate_lines(path) ⇒ Object



45
46
47
48
49
# File 'lib/dont_repeat_yourself/simian_runner.rb', line 45

def add_ruby_directory_to_search_for_duplicate_lines(path)
  valid_directory_path(path)
  @patterns_of_directories_to_search_for_duplicate_lines << (path + "/*.rb")
  @patterns_of_directories_to_search_for_duplicate_lines << (path + "/**/*.rb")
end

#ignoring_file(path) ⇒ Object



56
57
58
59
# File 'lib/dont_repeat_yourself/simian_runner.rb', line 56

def ignoring_file(path)
  valid_file_path(path)
  @patterns_of_directories_to_exclude_for_duplicate_lines << "/" + path
end

#runObject



61
62
63
64
65
66
# File 'lib/dont_repeat_yourself/simian_runner.rb', line 61

def run      
  run_java
  results_yaml = YAML.load(simian_output_with_header_removed)
  delete_simian_log_file
  results_yaml
end