Class: Reek::Application

Inherits:
Object show all
Defined in:
lib/reek/adapters/application.rb

Overview

Represents an instance of a Reek application. This is the entry point for all invocations of Reek from the command line.

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Application

Returns a new instance of Application.



13
14
15
# File 'lib/reek/adapters/application.rb', line 13

def initialize(argv)
  @argv = argv
end

Instance Method Details

#examine_sourcesObject



17
18
19
20
21
22
23
24
25
26
# File 'lib/reek/adapters/application.rb', line 17

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

#executeObject



36
37
38
39
40
41
42
43
44
45
# File 'lib/reek/adapters/application.rb', line 36

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

#reekObject



28
29
30
31
32
33
34
# File 'lib/reek/adapters/application.rb', line 28

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