Class: Nugrant::Config
- Inherits:
-
Object
- Object
- Nugrant::Config
- Defined in:
- lib/nugrant/config.rb
Constant Summary collapse
- DEFAULT_PARAMS_FILENAME =
".vagrantuser"
- DEFAULT_PARAMS_FILETYPE =
"yml"
Instance Attribute Summary collapse
-
#params_filename ⇒ Object
Returns the value of attribute params_filename.
-
#params_filetype ⇒ Object
Returns the value of attribute params_filetype.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Config
constructor
A new instance of Config.
- #project_params_path ⇒ Object
- #system_params_path ⇒ Object
- #user_params_path ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Config
Returns a new instance of Config.
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/nugrant/config.rb', line 27 def initialize( = {}) .delete_if { |key, value| value == nil } @params_filename = .fetch(:params_filename, DEFAULT_PARAMS_FILENAME) @params_filetype = .fetch(:params_filetype, DEFAULT_PARAMS_FILETYPE) @project_params_path = .fetch(:project_params_path, nil) @user_params_path = .fetch(:user_params_path, nil) @system_params_path = .fetch(:system_params_path, nil) end |
Instance Attribute Details
#params_filename ⇒ Object
Returns the value of attribute params_filename.
8 9 10 |
# File 'lib/nugrant/config.rb', line 8 def params_filename @params_filename end |
#params_filetype ⇒ Object
Returns the value of attribute params_filetype.
9 10 11 |
# File 'lib/nugrant/config.rb', line 9 def params_filetype @params_filetype end |
Class Method Details
.on_windows? ⇒ Boolean
23 24 25 |
# File 'lib/nugrant/config.rb', line 23 def self.on_windows?() (RbConfig::CONFIG['host_os'].downcase =~ /mswin|mingw|cygwin/) != nil end |
.system_base_path ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/nugrant/config.rb', line 15 def self.system_base_path() if Config.on_windows? return File.(ENV['PROGRAMDATA'] || ENV['ALLUSERSPROFILE']) end "/etc" end |
.user_base_path ⇒ Object
11 12 13 |
# File 'lib/nugrant/config.rb', line 11 def self.user_base_path() File.("~") end |
Instance Method Details
#project_params_path ⇒ Object
38 39 40 |
# File 'lib/nugrant/config.rb', line 38 def project_params_path() File.(@project_params_path || "./#{@params_filename}") end |
#system_params_path ⇒ Object
46 47 48 |
# File 'lib/nugrant/config.rb', line 46 def system_params_path() File.(@system_params_path || "#{Config.system_base_path()}/#{@params_filename}") end |
#user_params_path ⇒ Object
42 43 44 |
# File 'lib/nugrant/config.rb', line 42 def user_params_path() File.(@user_params_path || "#{Config.user_base_path()}/#{@params_filename}") end |