Sha256: dcd2239add4d4d50676f45f7191ecd92f32e2ab96fc4aabf844518c6bc38f25f

Contents?: true

Size: 956 Bytes

Versions: 1

Compression:

Stored size: 956 Bytes

Contents

# frozen_string_literal: true

module Remocon
  module Command
    class Validate
      include Remocon::InterpreterHelper

      def initialize(opts)
        @opts = opts

        @conditions_filepath = @opts[:conditions]
        @parameters_filepath = @opts[:parameters]

        @cmd_opts = { validate_only: true }
      end

      def run
        validate_options

        if parameter_errors.empty? && condition_errors.empty?
          STDOUT.puts 'No error was found.'
        else
          (parameter_errors + condition_errors).each do |e|
            STDERR.puts "#{e.class} #{e.message}"
            STDERR.puts e.backtrace.join("\n")
          end
        end
      end

      private

      def validate_options
        raise ValidationError, 'A condition file must exist' unless File.exist?(@conditions_filepath)
        raise ValidationError, 'A parameter file must exist' unless File.exist?(@parameters_filepath)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
remocon-0.1.0 lib/remocon/command/validate_command.rb