Sha256: 8e5a2b951b2a1ede852c89fa15bc92b4b16f46b8938f72bddbb6736e580c0159

Contents?: true

Size: 813 Bytes

Versions: 5

Compression:

Stored size: 813 Bytes

Contents

require_relative 'analyzer'
require_relative 'calculator'

module SandiMeter
  class FileScanner
    def initialize(log_errors = false)
      @log_errors = log_errors
      @calculator = SandiMeter::Calculator.new
    end

    def scan(path)
      if File.directory?(path)
        scan_dir(path)
      else
        scan_file(path)
      end

      @calculator.calculate!
    end

    private
    def scan_dir(path)
      Dir["#{path}/**/*.rb"].each do |file|
        scan_file(file)
      end
    end

    def scan_file(path)
      begin
        analyzer = SandiMeter::Analyzer.new
        data = analyzer.analyze(path)
        @calculator.push(data)
      rescue Exception => e
        if @log_errors
          puts "Checkout #{path} for:"
          puts "\t#{e.message}"
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
sandi_meter-0.0.6 lib/sandi_meter/file_scanner.rb
sandi_meter-0.0.5 lib/sandi_meter/file_scanner.rb
sandi_meter-0.0.4 lib/sandi_meter/file_scanner.rb
sandi_meter-0.0.3 lib/sandi_meter/file_scanner.rb
sandi_meter-0.0.2 lib/sandi_meter/file_scanner.rb