Class: McCabe::CLI
- Inherits:
-
Object
- Object
- McCabe::CLI
- Defined in:
- lib/mccabe/cli.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{ threshold: 4, quiet: false, sort: false, }
Class Method Summary collapse
-
.display_results(file_results) ⇒ Object
Print out the results of a file to the console.
-
.get_all_files(patterns) ⇒ Object
Get all files recursively.
Instance Method Summary collapse
Class Method Details
.display_results(file_results) ⇒ Object
Print out the results of a file to the console.
14 15 16 |
# File 'lib/mccabe/cli.rb', line 14 def self.display_results(file_results) file_results.each { |method_info| puts method_info.to_s } end |
.get_all_files(patterns) ⇒ Object
Get all files recursively.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/mccabe/cli.rb', line 19 def self.get_all_files(patterns) files = [] patterns.each do |pattern| files |= if File.directory? pattern sub_patterns = (Dir.entries(pattern) - ['.', '..']).map { |sub_pat| "#{pattern}/#{sub_pat}" } get_all_files(sub_patterns) else Dir[pattern] end end files.select { |file| file.end_with? '.rb' } end |
Instance Method Details
#parse!(argv) ⇒ Object
34 35 36 37 |
# File 'lib/mccabe/cli.rb', line 34 def parse!(argv) option_parser.parse! argv DEFAULT_OPTIONS.merge end |