Sha256: cf31348526b01cadd9730ba339869a008ca3433eb27f76c450fa36556a9b0f96
Contents?: true
Size: 1.61 KB
Versions: 2
Compression:
Stored size: 1.61 KB
Contents
require_relative 'options' require_relative 'reek_command' require_relative 'option_interpreter' require_relative '../configuration/app_configuration' module Reek module CLI # # Represents an instance of a Reek application. # This is the entry point for all invocations of Reek from the # command line. # class Application STATUS_SUCCESS = 0 STATUS_ERROR = 1 STATUS_SMELLS = 2 attr_reader :configuration private_attr_accessor :status private_attr_reader :command, :options def initialize(argv) @status = STATUS_SUCCESS @options = configure_options(argv) @configuration = configure_app_configuration(options.config_file) @command = ReekCommand.new(OptionInterpreter.new(options)) end def execute return status if error_occured? command.execute self status end def output(text) print text end def report_success self.status = STATUS_SUCCESS end def report_smells self.status = STATUS_SMELLS end private def error_occured? status == STATUS_ERROR end def configure_options(argv) Options.new(argv).parse rescue OptionParser::InvalidOption => error $stderr.puts "Error: #{error}" exit STATUS_ERROR end def configure_app_configuration(config_file) Configuration::AppConfiguration.from_path(config_file) rescue Reek::Configuration::ConfigFileException => error $stderr.puts "Error: #{error}" exit STATUS_ERROR end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
reek-3.5.0 | lib/reek/cli/application.rb |
reek-3.4.1 | lib/reek/cli/application.rb |