Sha256: 2c33228ad0493113254664edd97dc7263f4283c3f5e3bba9d183f9d48d211659

Contents?: true

Size: 1.11 KB

Versions: 16

Compression:

Stored size: 1.11 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].include?('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
        else
          :foss
        end
      end

      def dump_to_file(output_file)
        dirname = File.dirname(output_file)
        FileUtils.mkdir_p(dirname) unless File.directory?(dirname)
        File.write(output_file, dump)
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
beaker-6.4.1 lib/beaker/options/options_hash.rb
beaker-6.4.0 lib/beaker/options/options_hash.rb
beaker-6.3.0 lib/beaker/options/options_hash.rb
beaker-6.2.0 lib/beaker/options/options_hash.rb
beaker-6.1.0 lib/beaker/options/options_hash.rb
beaker-5.8.1 lib/beaker/options/options_hash.rb
beaker-5.8.0 lib/beaker/options/options_hash.rb
beaker-5.7.0 lib/beaker/options/options_hash.rb
beaker-5.6.0 lib/beaker/options/options_hash.rb
beaker-5.5.0 lib/beaker/options/options_hash.rb
beaker-5.4.0 lib/beaker/options/options_hash.rb
beaker-5.3.1 lib/beaker/options/options_hash.rb
beaker-5.3.0 lib/beaker/options/options_hash.rb
beaker-5.2.0 lib/beaker/options/options_hash.rb
beaker-5.1.0 lib/beaker/options/options_hash.rb
beaker-5.0.0 lib/beaker/options/options_hash.rb