Sha256: 873fb44927d46cfcab3b3edb1a63e501b78ed6daa824311ebac578f7d27b7d29

Contents?: true

Size: 1.1 KB

Versions: 8

Compression:

Stored size: 1.1 KB

Contents

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

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)
      @argv = argv
    end

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

    def reek
      examine_sources
      # SMELL:
      # This should use the actual type of report selected by the user's options
      puts Report.new(@sniffer.sniffers).full_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

8 entries across 8 versions & 2 rubygems

Version Path
kevinrutherford-reek-1.1.3.11 lib/reek/adapters/application.rb
kevinrutherford-reek-1.1.3.12 lib/reek/adapters/application.rb
kevinrutherford-reek-1.1.3.13 lib/reek/adapters/application.rb
kevinrutherford-reek-1.1.3.14 lib/reek/adapters/application.rb
kevinrutherford-reek-1.1.3.15 lib/reek/adapters/application.rb
kevinrutherford-reek-1.1.3.16 lib/reek/adapters/application.rb
kevinrutherford-reek-1.2.0 lib/reek/adapters/application.rb
reek-1.2.0 lib/reek/adapters/application.rb