Class: Beaker::Options::OptionsHash

Inherits:
StringifyHash
  • Object
show all
Defined in:
lib/beaker/options/options_hash.rb

Overview

A hash that treats Symbol and String keys interchangeably and recursively merges hashes

Instance Method Summary collapse

Instance Method Details

#dump_to_file(output_file) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/beaker/options/options_hash.rb', line 41

def dump_to_file(output_file)
  dirname = File.dirname(output_file)
  unless File.directory?(dirname)
    FileUtils.mkdir_p(dirname)
  end
  File.open(output_file, 'w+') { |f| f.write(dump)  }
end

#get_typeSymbol

Determine the puppet type of the ObjectHash

Default is FOSS

Examples:

Use this method to test if the :type setting is pe

a['type'] = 'pe'
a.get_type == :pe

Returns:

  • (Symbol)

    the type given in the options



30
31
32
33
34
35
36
37
38
39
# File 'lib/beaker/options/options_hash.rb', line 30

def get_type
  case self[:type]
  when /pe/
    :pe
  when /foss/
    :foss
  else
    :foss
  end
end

#is_pe?Boolean

Determine if type of ObjectHash is pe, defaults to true

Examples:

Use this method to test if the :type setting is pe

a['type'] = 'pe'
a.is_pe? == true

Returns:

  • (Boolean)


17
18
19
# File 'lib/beaker/options/options_hash.rb', line 17

def is_pe?
  self[:type] ? self[:type] =~ /pe/ : true
end