lib/bigfiles.rb in bigfiles-0.1.0 vs lib/bigfiles.rb in bigfiles-0.1.1

- old
+ new

@@ -1,27 +1,24 @@ require 'optparse' -require_relative 'bigfiles/source_code_finder' require_relative 'bigfiles/file_with_lines' +require 'source_finder/source_file_globber' -# XXX: Take out source_file_globber.rb from quality into its own gem -# and start building on that. - # Simple tool to find the largest source files in your project. module BigFiles # Simple tool to find the largest source files in your project. class BigFiles def initialize(args, io: Kernel, exiter: Kernel, file_with_lines: FileWithLines, - source_file_finder: SourceCodeFinder.new, + source_file_globber: SourceFinder::SourceFileGlobber.new, option_parser_class: OptionParser) @io = io @exiter = exiter @file_with_lines = file_with_lines - @source_file_finder = source_file_finder + @source_file_globber = source_file_globber @option_parser_class = option_parser_class @options = parse_options(args) end def parse_options(args) @@ -31,10 +28,11 @@ @option_parser = opts end.parse!(args) options end + # XXX: Move to using SourceFinder for this DEFAULT_GLOB = '{app,lib,test,spec,feature}/**/*.{rb,swift,cpp,c,java,py}' def glob @options[:glob] || DEFAULT_GLOB @@ -77,10 +75,12 @@ @io.puts @option_parser @exiter.exit 1 end def find_analyze_and_report_on_files - file_list = @source_file_finder.find(glob, exclude_glob) + @source_file_globber.source_files_glob = glob + @source_file_globber.source_files_exclude_glob = exclude_glob + file_list = @source_file_globber.source_files files_with_lines = file_list.map do |filename| @file_with_lines.new(filename) end files_with_lines.sort.reverse[0..2].each do |file| @io.puts "#{file.num_lines}: #{file.filename}"