Class: DontRepeatYourself::ProjectReporterBase

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

Direct Known Subclasses

RubyProjectReporter

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ ProjectReporterBase

Returns a new instance of ProjectReporterBase.



15
16
17
18
19
20
21
22
# File 'lib/dont_repeat_yourself/reporter.rb', line 15

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.



13
14
15
# File 'lib/dont_repeat_yourself/reporter.rb', line 13

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.



13
14
15
# File 'lib/dont_repeat_yourself/reporter.rb', line 13

def name
  @name
end

#report_typeObject (readonly)

Returns the value of attribute report_type.



13
14
15
# File 'lib/dont_repeat_yourself/reporter.rb', line 13

def report_type
  @report_type
end

Instance Method Details

#descriptionObject



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

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

#dry?Boolean

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

Returns:

  • (Boolean)


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

def dry?      
  run_simian.duplicate_line_count <= @maximum_number_of_duplicate_lines_i_want_in_my_project        
end

#failure_messageObject



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

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_file(path) ⇒ Object



42
43
44
45
# File 'lib/dont_repeat_yourself/reporter.rb', line 42

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

#patterns_of_directories_to_search_for_duplicate_linesObject



24
25
26
# File 'lib/dont_repeat_yourself/reporter.rb', line 24

def patterns_of_directories_to_search_for_duplicate_lines
  @simian_runner.patterns_of_directories_to_search_for_duplicate_lines
end

#reportObject



47
48
49
# File 'lib/dont_repeat_yourself/reporter.rb', line 47

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

#with_threshold_of_duplicate_lines(threshold) ⇒ Object

Fluent interface methods



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

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