Module: Berkshelf::Mixin::Config::ClassMethods
- Defined in:
- lib/berkshelf/mixin/config.rb
Instance Attribute Summary collapse
- #default_location(path) ⇒ String? readonly
Instance Method Summary collapse
-
#default_option(option, value) ⇒ Object
Class method for defining a default option.
-
#default_options ⇒ Hash
A list of all the default options set by this class.
-
#from_file(filepath) ⇒ Object
Load a Chef configuration from the given path.
-
#load ⇒ Object
Load the contents of the most probable Chef config.
-
#platform_specific_path(path) ⇒ String
Converts a path to a path usable for your current platform.
Instance Attribute Details
Instance Method Details
#default_option(option, value) ⇒ Object
Class method for defining a default option.
31 32 33 |
# File 'lib/berkshelf/mixin/config.rb', line 31 def default_option(option, value) [option.to_sym] = value end |
#default_options ⇒ Hash
A list of all the default options set by this class.
38 39 40 |
# File 'lib/berkshelf/mixin/config.rb', line 38 def @default_options ||= {} end |
#from_file(filepath) ⇒ Object
Load a Chef configuration from the given path.
13 14 15 16 17 |
# File 'lib/berkshelf/mixin/config.rb', line 13 def from_file(filepath) self.new(filepath) rescue Errno::ENOENT => e raise Berkshelf::ConfigNotFound.new(self.class.name, filepath) end |
#load ⇒ Object
Load the contents of the most probable Chef config. See #location for more information on how this logic is decided.
21 22 23 |
# File 'lib/berkshelf/mixin/config.rb', line 21 def load self.new(location) end |
#platform_specific_path(path) ⇒ String
Converts a path to a path usable for your current platform
58 59 60 61 62 63 64 65 |
# File 'lib/berkshelf/mixin/config.rb', line 58 def platform_specific_path(path) if RUBY_PLATFORM =~ /mswin|mingw|windows/ system_drive = ENV['SYSTEMDRIVE'] ? ENV['SYSTEMDRIVE'] : "" path = win_slashify File.join(system_drive, path.split('/')[2..-1]) end path end |