Class: DontRepeatYourself::ProjectReporterBase

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ ProjectReporterBase

Returns a new instance of ProjectReporterBase.



22
23
24
25
26
27
28
29
# File 'lib/dont_repeat_yourself/reporter.rb', line 22

def initialize(name)
  @name = name
  @simian_runner = DontRepeatYourself::SimianRunner.new      
  
  # Default values
  @maximum_number_of_duplicate_lines_i_want_in_my_project = 0
  @report_type = DontRepeatYourself::DEFAULT_REPORT
end

Instance Attribute Details

#maximum_number_of_duplicate_lines_i_want_in_my_projectObject (readonly)

Returns the value of attribute maximum_number_of_duplicate_lines_i_want_in_my_project.



20
21
22
# File 'lib/dont_repeat_yourself/reporter.rb', line 20

def maximum_number_of_duplicate_lines_i_want_in_my_project
  @maximum_number_of_duplicate_lines_i_want_in_my_project
end

#nameObject (readonly)

Returns the value of attribute name.



20
21
22
# File 'lib/dont_repeat_yourself/reporter.rb', line 20

def name
  @name
end

#report_typeObject (readonly)

Returns the value of attribute report_type.



20
21
22
# File 'lib/dont_repeat_yourself/reporter.rb', line 20

def report_type
  @report_type
end

Instance Method Details

#basedirObject



59
60
61
# File 'lib/dont_repeat_yourself/reporter.rb', line 59

def basedir
  @simian_runner.basedir
end

#descriptionObject



72
73
74
# File 'lib/dont_repeat_yourself/reporter.rb', line 72

def description
  "DRY\n" << "  - with a threshold of #{@simian_runner.threshold} duplicate lines"
end

#failure_messageObject



76
77
78
79
# File 'lib/dont_repeat_yourself/reporter.rb', line 76

def failure_message      
  "expected #{@name} to have less or equal #{@maximum_number_of_duplicate_lines_i_want_in_my_project} duplicate lines :\n
     DRY Report:\n#{report}\n"
end

#ignoring_the_directory(path) ⇒ Object



54
55
56
57
# File 'lib/dont_repeat_yourself/reporter.rb', line 54

def ignoring_the_directory(path)
  @simian_runner.ignore_directory(path)
  self
end

#ignoring_the_file(path) ⇒ Object



49
50
51
52
# File 'lib/dont_repeat_yourself/reporter.rb', line 49

def ignoring_the_file(path)
  @simian_runner.ignore_file(path)
  self
end

#is_dry?Boolean

TODO Not very readable: you have to read the code of run_simian to understand

Returns:

  • (Boolean)


68
69
70
# File 'lib/dont_repeat_yourself/reporter.rb', line 68

def is_dry?
  run_simian.duplicate_line_count <= @maximum_number_of_duplicate_lines_i_want_in_my_project        
end

#patterns_of_directories_to_search_for_duplicate_linesObject



31
32
33
# File 'lib/dont_repeat_yourself/reporter.rb', line 31

def patterns_of_directories_to_search_for_duplicate_lines
  @simian_runner.patterns_of_directories_to_search_for_duplicate_lines
end

#reportObject



63
64
65
# File 'lib/dont_repeat_yourself/reporter.rb', line 63

def report
  DontRepeatYourself::FormatterFactory.create_report(@report_type, run_simian)
end

#with_threshold_of_duplicate_lines(threshold) ⇒ Object

Fluent interface methods



36
37
38
39
# File 'lib/dont_repeat_yourself/reporter.rb', line 36

def with_threshold_of_duplicate_lines(threshold)
  @simian_runner.threshold = threshold        
  return self
end