Sha256: 8522eb8236acf69977f42b67914859a316e1e30171093f799328dd0181c1c8bd

Contents?: true

Size: 710 Bytes

Versions: 4

Compression:

Stored size: 710 Bytes

Contents

module Vagabond
  class VagabondError < StandardError
    class << self
      attr_accessor :exit_code
    end
    def exit_code
      self.class.exit_code
    end
  end
  
  class VagabondError
    %w(
        reserved_name invalid_name invalid_base_template
        invalid_action invalid_template kitchen_missing_yml
        kitchen_no_cookbook_args kitchen_too_many_args
        kitchen_invalid_platform missing_node_name cluster_invalid
        kitchen_test_failed host_provision_failed spec_failed
    ).each_with_index do |klass_name, i|
      klass = klass_name.split('_').map(&:capitalize).join
      self.class_eval("class #{klass} < VagabondError; self.exit_code = #{i + 1}; end")
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vagabond-0.2.8 lib/vagabond/errors.rb
vagabond-0.2.6 lib/vagabond/errors.rb
vagabond-0.2.4 lib/vagabond/errors.rb
vagabond-0.2.2 lib/vagabond/errors.rb