Sha256: b281660a4e6d082dd2d2d2d0715101e7a5815431d23b03f3600746024fc439c6

Contents?: true

Size: 1022 Bytes

Versions: 2

Compression:

Stored size: 1022 Bytes

Contents

require 'reek/adapters/command_line'
require 'reek/adapters/source'
require 'reek/adapters/core_extras'

module Reek
  #
  # Represents an instance of a Reek application.
  # This is the entry point for all invocations of Reek from the
  # command line.
  #
  class Application
    def initialize(argv)
      @options = Options.new(argv)
    end

    def examine_sources
      # SMELL: Greedy Method
      # Options.parse executes the -v and -h commands and throws a SystemExit
      args = @options.parse
      if args.length > 0
        @sniffer = args.sniff
      else
        @sniffer = Reek::Sniffer.new($stdin.to_reek_source('$stdin'))
      end
    end

    def reek
      examine_sources
      puts @options.create_report(@sniffer.sniffers).report
      return @sniffer.smelly? ? 2 : 0
    end

    def execute
      begin
        return reek
      rescue SystemExit => ex
        return ex.status
      rescue Exception => error
        $stderr.puts "Error: #{error}"
        return 1
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
reek-1.2.2 lib/reek/adapters/application.rb
reek-1.2.1 lib/reek/adapters/application.rb