Class AutomateIt::PlatformManager::Struct
In: lib/automateit/platform_manager/struct.rb
Parent: AutomateIt::PlatformManager::BaseDriver

PlatformManager::Struct

A simple PlatformManager driver that queries a hash for results. Although not useful on its own, it‘s inherited by other drivers that provide platform-specific methods to query the system.

Methods

query   setup   single_vendor?   tags  

Attributes

key_aliases  [RW]  Hash mapping of keys that have many common names, e.g., "release" and "version"

Public Instance methods

See PlatformManager#query

[Source]

# File lib/automateit/platform_manager/struct.rb, line 36
  def query(search)
    result = ""
    for key in search.to_s.split(/#/)
      result << "_" unless result.empty?
      result << _query_key(key)
    end
    result
  end

Options:

  • :struct — The hash to use for queries.

[Source]

# File lib/automateit/platform_manager/struct.rb, line 18
  def setup(opts={})
    super(opts)

    @@struct_cache ||= {}

    if opts[:struct]
      @struct = opts[:struct]
    else
      @struct ||= {}
    end

    # Generate bi-directional map
    @key_aliases ||= @@key_aliases ||= {
      :version => :release,
    }.inject({}){|s,v| s[v[0]] = v[1]; s[v[1]] = v[0]; s}
  end

See PlatformManager#single_vendor?

[Source]

# File lib/automateit/platform_manager/struct.rb, line 60
  def single_vendor?
    return false
  end

See PlatformManager#tags

[Source]

# File lib/automateit/platform_manager/struct.rb, line 65
  def tags
    results = []
    for key in %w(os arch distro os#arch)
      results << query(key) rescue IndexError
    end

    release_query = \
      if single_vendor?
        "os#release"     # E.g. windows_xp
      else
        "distro#release" # E.g. ubuntu_6.06
      end
    results << query(release_query) rescue IndexError
    return results
  end

[Validate]