Class: BigFiles::BigFiles

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

Overview

Simple tool to find the largest source files in your project.

Instance Method Summary collapse

Constructor Details

#initialize(args, io_class: Kernel, exiter: Kernel, file_with_lines: FileWithLines, source_file_globber: SourceFinder::SourceFileGlobber.new, inspector_class: Inspector, option_parser_class: ::OptionParser, source_finder_option_parser: SourceFinder::OptionParser.new, yaml_class: YAML, bigfiles_option_parser: ::BigFiles::OptionParser .new(option_parser_class: option_parser_class, io_class: io_class, exiter: exiter, source_finder_option_parser: source_finder_option_parser), config_file_parser: ::BigFiles::ConfigFileParser.new(yaml_class: yaml_class), raw_config: config_file_parser.parse_config_files .merge(bigfiles_option_parser.parse_options(args)), config: Config.new(**raw_config)) ⇒ BigFiles

Returns a new instance of BigFiles.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/bigfiles.rb', line 18

def initialize(args,
               io_class: Kernel,
               exiter: Kernel,
               file_with_lines: FileWithLines,
               source_file_globber: SourceFinder::SourceFileGlobber.new,
               inspector_class: Inspector,
               option_parser_class: ::OptionParser,
               source_finder_option_parser: SourceFinder::OptionParser.new,
               yaml_class: YAML,
               bigfiles_option_parser:
                 ::BigFiles::OptionParser
                   .new(option_parser_class: option_parser_class,
                        io_class: io_class,
                        exiter: exiter,
                        source_finder_option_parser:
                          source_finder_option_parser),
               config_file_parser: ::BigFiles::ConfigFileParser.new(yaml_class: yaml_class),
               raw_config: config_file_parser.parse_config_files
                 .merge(bigfiles_option_parser.parse_options(args)),
               config: Config.new(**raw_config))

  @bigfiles_option_parser = bigfiles_option_parser
  @config = config
  @inspector = inspector_class.new(source_file_globber: source_file_globber,
                                   config: config,
                                   file_with_lines: file_with_lines,
                                   io_class: io_class)
end

Instance Method Details

#runObject



47
48
49
50
51
52
53
# File 'lib/bigfiles.rb', line 47

def run
  if @config.help
    @bigfiles_option_parser.usage
  else
    @inspector.find_analyze_and_report_on_files
  end
end