Class: AutomateIt::PlatformManager::Struct
- Inherits:
-
BaseDriver
- Object
- Common
- AutomateIt::Plugin::Base
- AutomateIt::Plugin::Driver
- BaseDriver
- AutomateIt::PlatformManager::Struct
- Defined in:
- lib/automateit/platform_manager/struct.rb
Overview
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.
Constant Summary
Constants inherited from AutomateIt::Plugin::Driver
AutomateIt::Plugin::Driver::BASE_DRIVER_NAME
Constants included from Constants
Constants::HELPERS_DIR, Constants::INSTALL_DIR, Constants::PERROR, Constants::PEXEC, Constants::PNOTE, Constants::WARNING_BOILERPLATE
Instance Attribute Summary collapse
-
#key_aliases ⇒ Object
Hash mapping of keys that have many common names, e.g., “release” and “version”.
Attributes inherited from AutomateIt::Plugin::Driver
Attributes inherited from Common
Instance Method Summary collapse
-
#query(search) ⇒ Object
See PlatformManager#query.
-
#setup(opts = {}) ⇒ Object
Options: * :struct – The hash to use for queries.
-
#single_vendor? ⇒ Boolean
See PlatformManager#single_vendor?.
-
#suitability(method, *args) ⇒ Object
:nodoc:.
-
#tags ⇒ Object
See PlatformManager#tags.
Methods inherited from AutomateIt::Plugin::Driver
abstract_driver, #available?, base_driver, base_driver?, depends_on, inherited, manager_token
Methods inherited from AutomateIt::Plugin::Base
Methods inherited from Common
#initialize, #log, #nitpick, #noop, #noop=, #noop?, #preview, #preview=, #preview?, #preview_for, #superuser?, #writing, #writing=, #writing?
Constructor Details
This class inherits a constructor from AutomateIt::Common
Instance Attribute Details
#key_aliases ⇒ Object
Hash mapping of keys that have many common names, e.g., “release” and “version”
10 11 12 |
# File 'lib/automateit/platform_manager/struct.rb', line 10 def key_aliases @key_aliases end |
Instance Method Details
#query(search) ⇒ Object
See PlatformManager#query
36 37 38 39 40 41 42 43 |
# 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 |
#setup(opts = {}) ⇒ Object
Options:
-
:struct – The hash to use for queries.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# 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 |
#single_vendor? ⇒ Boolean
See PlatformManager#single_vendor?
60 61 62 |
# File 'lib/automateit/platform_manager/struct.rb', line 60 def single_vendor? return false end |
#suitability(method, *args) ⇒ Object
:nodoc:
12 13 14 |
# File 'lib/automateit/platform_manager/struct.rb', line 12 def suitability(method, *args) # :nodoc: return 1 end |
#tags ⇒ Object
See PlatformManager#tags
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/automateit/platform_manager/struct.rb', line 65 def 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 |