Class: Cheftacular::Error

Inherits:
Object
  • Object
show all
Defined in:
lib/cheftacular/error.rb

Instance Method Summary collapse

Constructor Details

#initialize(options, config) ⇒ Error

Returns a new instance of Error.



4
5
6
# File 'lib/cheftacular/error.rb', line 4

def initialize options, config
  @options, @config  = options, config
end

Instance Method Details

#exception_output(message, exception = nil, exit_on_call = true, suppress_error_output = false) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/cheftacular/error.rb', line 23

def exception_output message, exception=nil, exit_on_call=true, suppress_error_output=false
  puts "#{ message }\n"

  puts("Error message: #{ exception }\n#{ exception.backtrace.join("\n") }") if !exception.nil? && !suppress_error_output

  exit if exit_on_call
end

#is_valid_node_name_option?(strict_env = false) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/cheftacular/error.rb', line 8

def is_valid_node_name_option? strict_env=false
  raise "Too few arguments, please supply a node name" if @options['node_name'].nil?

  nodes = @config['getter'].get_true_node_objects(true)

  exclusion_args  = [{ if: { not_node: @options["node_name"] } }]
  exclusion_args << { if: { not_env: @options['env'] } } if strict_env

  nodes = @config['parser'].exclude_nodes( nodes, exclusion_args, true )

  raise "Node not found for node name: #{ @options['node_name'] }" if nodes.empty?

  nodes
end