Class: Entruby::App

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ App

Returns a new instance of App.



131
132
133
134
135
136
137
138
# File 'lib/entruby.rb', line 131

def initialize(argv)
  if argv.size < 2
    puts "USAGE: $ entruby <source directory> <doxygen xml directory>"
    exit 1
  end

  @source_dir, @xml_dir, @output_dir = argv[0], argv[1], Dir.pwd
end

Instance Attribute Details

#output_dirObject (readonly)

Returns the value of attribute output_dir.



129
130
131
# File 'lib/entruby.rb', line 129

def output_dir
  @output_dir
end

Instance Method Details

#functionsArray<Doxyparser::Function>

Returns:



141
142
143
144
145
146
147
148
149
150
# File 'lib/entruby.rb', line 141

def functions
  source_file_paths = []
  Find.find(@source_dir) do |path|
    source_file_paths << File.basename(path).gsub('_', '__') if path =~ /.*\.c$/
  end
  source_file_paths.reduce([]) do |functions, file|
    hfile = Doxyparser::parse_file(file, @xml_dir)
    functions + hfile.functions
  end
end

#functions_reportObject



152
153
154
155
156
# File 'lib/entruby.rb', line 152

def functions_report
  all_functions = functions
  report = all_functions.map { |func| func.report(all_functions) }
  report.sort_by! { |row| row[:metric] }.reverse!
end

#overview(couplings) ⇒ Object



158
159
160
# File 'lib/entruby.rb', line 158

def overview(couplings)
  Overview.new(couplings).report
end

#reportObject



162
163
164
165
# File 'lib/entruby.rb', line 162

def report
  couplings = functions_report
  {overview: overview(couplings), functions: couplings}
end