Sha256: aebb1b9c4360a06e14ae67b6b6bfd28df85fdb024ae8da563e5e604cd7557bc8

Contents?: true

Size: 1.18 KB

Versions: 89

Compression:

Stored size: 1.18 KB

Contents

require 'stringify-hash'

module Beaker
  module Options

    # A hash that treats Symbol and String keys interchangeably
    # and recursively merges hashes
    class OptionsHash < StringifyHash

      # Determine if type of ObjectHash is pe, defaults to true
      #
      # @example Use this method to test if the :type setting is pe
      #     a['type'] = 'pe'
      #     a.is_pe? == true
      #
      # @return [Boolean]
      def is_pe?
        self[:type] ? self[:type] =~ /pe/ : true
      end

      # Determine the puppet type of the ObjectHash
      #
      # Default is FOSS
      #
      # @example Use this method to test if the :type setting is pe
      #     a['type'] = 'pe'
      #     a.get_type == :pe
      #
      # @return [Symbol] the type given in the options
      def get_type
        case self[:type]
        when /pe/
          :pe
        when /foss/
          :foss
        else
          :foss
        end
      end

      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

    end
  end
end

Version data entries

89 entries across 89 versions & 1 rubygems

Version Path
beaker-4.38.1 lib/beaker/options/options_hash.rb
beaker-4.38.0 lib/beaker/options/options_hash.rb
beaker-4.37.2 lib/beaker/options/options_hash.rb
beaker-4.37.1 lib/beaker/options/options_hash.rb
beaker-4.37.0 lib/beaker/options/options_hash.rb
beaker-4.36.1 lib/beaker/options/options_hash.rb
beaker-4.36.0 lib/beaker/options/options_hash.rb
beaker-4.35.0 lib/beaker/options/options_hash.rb
beaker-4.34.0 lib/beaker/options/options_hash.rb
beaker-4.33.0 lib/beaker/options/options_hash.rb
beaker-4.32.0 lib/beaker/options/options_hash.rb
beaker-4.31.0 lib/beaker/options/options_hash.rb
beaker-4.30.0 lib/beaker/options/options_hash.rb
beaker-4.29.1 lib/beaker/options/options_hash.rb
beaker-4.29.0 lib/beaker/options/options_hash.rb
beaker-4.28.1 lib/beaker/options/options_hash.rb
beaker-4.28.0 lib/beaker/options/options_hash.rb
beaker-4.27.1 lib/beaker/options/options_hash.rb
beaker-4.27.0 lib/beaker/options/options_hash.rb
beaker-4.26.0 lib/beaker/options/options_hash.rb