Class: Entruby::App
- Inherits:
-
Object
- Object
- Entruby::App
- Defined in:
- lib/entruby.rb
Instance Attribute Summary collapse
-
#output_dir ⇒ Object
readonly
Returns the value of attribute output_dir.
Instance Method Summary collapse
- #functions ⇒ Array<Doxyparser::Function>
- #functions_report ⇒ Object
-
#initialize(argv) ⇒ App
constructor
A new instance of App.
- #overview(couplings) ⇒ Object
- #report ⇒ Object
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_dir ⇒ Object (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
#functions ⇒ Array<Doxyparser::Function>
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_report ⇒ Object
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 |
#report ⇒ Object
162 163 164 165 |
# File 'lib/entruby.rb', line 162 def report couplings = functions_report {overview: overview(couplings), functions: couplings} end |