Sha256: b2e6583aa1d9626f11adb85f7a2f8d388957bc70fa981667ea69a11ca5041511

Contents?: true

Size: 859 Bytes

Versions: 5

Compression:

Stored size: 859 Bytes

Contents

module Pelusa
  # The cli is a class responsible of handling all the command line interface
  # logic.
  #
  class Cli
    def initialize(args=ARGV)
      @args = args
    end

    def run
      _files = files
      if _files.empty?
        warn "\n  No files specified -- PROCESS ALL THE FILES!\n"
        _files = Dir["**/*.rb"]
      end

      reporters = Pelusa.run(_files)

      reporters.first.class.print_banner unless reporters.empty?

      exit_code = 0
      reporters.each do |reporter|
        reporter.report
        exit_code = 1 unless reporter.successful?
      end
      exit_code
    end

    def files
      if glob = @args.detect { |arg| arg =~ /\*/ }
        return Dir[glob]
      end
      _files = @args.select { |arg| arg =~ /\.rb/ }
      _files = Dir[Pelusa.configuration.sources] if _files.empty?
      _files
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pelusa-0.2.4 lib/pelusa/cli.rb
pelusa-0.2.3 lib/pelusa/cli.rb
pelusa-0.2.2 lib/pelusa/cli.rb
pelusa-0.2.1 lib/pelusa/cli.rb
pelusa-0.2.0 lib/pelusa/cli.rb