Class: RubyCritic::Cli::Application

Inherits:
Object
  • Object
show all
Defined in:
lib/rubycritic/cli/application.rb

Constant Summary collapse

STATUS_SUCCESS =
0
STATUS_ERROR =
1

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Application

Returns a new instance of Application.


14
15
16
# File 'lib/rubycritic/cli/application.rb', line 14

def initialize(argv)
  @options = Options.new(argv)
end

Instance Method Details

#executeObject


18
19
20
21
22
23
24
25
26
27
# File 'lib/rubycritic/cli/application.rb', line 18

def execute
  parsed_options = @options.parse.to_h

  reporter = RubyCritic::CommandFactory.create(parsed_options).execute
  print(reporter.status_message)
  reporter.status
rescue OptionParser::InvalidOption => error
  warn "Error: #{error}"
  STATUS_ERROR
end

29
30
31
# File 'lib/rubycritic/cli/application.rb', line 29

def print(message)
  $stdout.puts message
end