Sha256: 48315ac1bcc1532fce6b6d5e0437a3eaf78bc58f5942ed0ad55fa2fa062f355d

Contents?: true

Size: 1.43 KB

Versions: 1

Compression:

Stored size: 1.43 KB

Contents

module Outliers
  module CLI
    class Process
      def process
        @options = {}

        option_parser.parse!

        Outliers.config_path @options[:directory]

        @logger = Outliers.logger
        @run    = Run.new

        begin
          @run.credentials = Credentials.load_from_file "#{ENV['HOME']}/.outliers.yml"
          @run.process_evaluations_in_config_folder
        rescue Outliers::Exceptions::Base => e
          @logger.error e.message
          exit 1
        end

        passed = @run.passed.count
        failed = @run.failed.count

        @logger.info "Evaluations completed."

        @run.failed.each do |f|
          @logger.info "Evaluation '#{f.evaluation}' verification '#{f.verification}' of '#{f.resource}' failed."
          @logger.debug "Failing resource IDs '#{f.failing_resources.map{|r| r.id}.join(', ')}'"
        end

        @logger.info "(#{failed} evaluations failed, #{passed} evaluations passed.)"

        exit 1 unless failed.zero?
      end

      def command_name
        'process'
      end

      def command_summary
        'Process evaluations in config folder.'
      end

      private

      def option_parser
        OptionParser.new do |opts|
          opts.banner = "Usage: outliers process [options]"

          opts.on("-d", "--directory [DIRECTORY]", "Directory containing evaluations to load.") do |o|
            @options[:directory] = o
          end
        end
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
outliers-0.2.0 lib/outliers/cli/process.rb