Provides the DSL for platform-dependent switch logic, such as value_for_platform.
Given a list of platforms, returns true if the current recipe is being run on a node with that platform, false otherwise.
args |
A list of platforms. Each platform can be in string or symbol format. |
true |
If the current platform is in the list |
false |
If the current platform is not in the list |
# File lib/chef/dsl/platform_introspection.rb, line 119 def platform?(*args) has_platform = false args.flatten.each do |platform| has_platform = true if platform.to_s == node[:platform] end has_platform end
Given a list of platform families, returns true if the current recipe is being run on a node within that platform family, false otherwise.
args |
A list of platform families. Each platform family can be in string or symbol format. |
true |
if the current node platform family is in the list. |
false |
if the current node platform family is not in the list. |
# File lib/chef/dsl/platform_introspection.rb, line 205 def platform_family?(*args) args.flatten.any? do |platform_family| platform_family.to_s == node[:platform_family] end end
Given a hash similar to the one we use for Platforms, select a value from the hash. Supports per platform defaults, along with a single base default. Arrays may be passed as hash keys and will be expanded.
platform_hash |
A platform-style hash. |
value |
Whatever the most specific value of the hash is. |
# File lib/chef/dsl/platform_introspection.rb, line 106 def value_for_platform(platform_hash) PlatformDependentValue.new(platform_hash).value_for_node(node) end
Given a hash mapping platform families to values, select a value from the hash. Supports a single base default if platform family is not in the map. Arrays may be passed as hash keys and will be expanded
platform_family_hash |
A hash in the form { platform_family_name => value } |
value |
Whatever the most specific value of the hash is. |
# File lib/chef/dsl/platform_introspection.rb, line 192 def value_for_platform_family(platform_family_hash) PlatformFamilyDependentValue.new(platform_family_hash).value_for_node(node) end
Generated with the Darkfish Rdoc Generator 2.