Class: Fukuzatsu::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/fukuzatsu/parser.rb

Constant Summary collapse

DEFAULT_OUTPUT_DIRECTORY =
"doc/fukuzatsu/"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path_to_files, formatter, threshold, output_path = nil) ⇒ Parser

Returns a new instance of Parser.



12
13
14
15
16
17
# File 'lib/fukuzatsu/parser.rb', line 12

def initialize(path_to_files, formatter, threshold, output_path=nil)
  @path_to_files = path_to_files
  @formatter = formatter
  @threshold = threshold
  @output_path = output_path || DEFAULT_OUTPUT_DIRECTORY
end

Instance Attribute Details

#formatterObject (readonly)

Returns the value of attribute formatter.



8
9
10
# File 'lib/fukuzatsu/parser.rb', line 8

def formatter
  @formatter
end

#output_pathObject (readonly)

Returns the value of attribute output_path.



8
9
10
# File 'lib/fukuzatsu/parser.rb', line 8

def output_path
  @output_path
end

#path_to_filesObject (readonly)

Returns the value of attribute path_to_files.



8
9
10
# File 'lib/fukuzatsu/parser.rb', line 8

def path_to_files
  @path_to_files
end

#thresholdObject (readonly)

Returns the value of attribute threshold.



8
9
10
# File 'lib/fukuzatsu/parser.rb', line 8

def threshold
  @threshold
end

Instance Method Details

#explainObject



19
20
21
22
# File 'lib/fukuzatsu/parser.rb', line 19

def explain
  puts "Processed #{summaries.count} file(s)."
  puts "Results written to #{output_path}." if formatter.writes_to_file_system?
end

#reportObject



24
25
26
27
28
29
30
31
32
# File 'lib/fukuzatsu/parser.rb', line 24

def report
  self.formatter.reset_output_directory(output_path)
  self.formatter.index(summaries, output_path)
  summaries.uniq(&:container_name).each do |summary|
    self.formatter.new(summary: summary, base_output_path: self.output_path).export
  end
  explain
  check_complexity
end