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(paths_to_files, formatter, threshold, output_path = nil) ⇒ Parser

Returns a new instance of Parser.



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

def initialize(paths_to_files, formatter, threshold, output_path=nil)
  @paths_to_files = paths_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.



6
7
8
# File 'lib/fukuzatsu/parser.rb', line 6

def formatter
  @formatter
end

#output_pathObject (readonly)

Returns the value of attribute output_path.



6
7
8
# File 'lib/fukuzatsu/parser.rb', line 6

def output_path
  @output_path
end

#paths_to_filesObject (readonly)

Returns the value of attribute paths_to_files.



6
7
8
# File 'lib/fukuzatsu/parser.rb', line 6

def paths_to_files
  @paths_to_files
end

#thresholdObject (readonly)

Returns the value of attribute threshold.



6
7
8
# File 'lib/fukuzatsu/parser.rb', line 6

def threshold
  @threshold
end

Instance Method Details

#explainObject



15
16
17
18
# File 'lib/fukuzatsu/parser.rb', line 15

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

#reportObject



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/fukuzatsu/parser.rb', line 20

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
  unless self.formatter.no_stdout?
    explain
    check_complexity
  end
end