Class: Berkshelf::Config
- Inherits:
-
Chozo::Config::JSON
- Object
- Chozo::Config::JSON
- Berkshelf::Config
- Defined in:
- lib/berkshelf/config.rb
Overview
Constant Summary collapse
- FILENAME =
"config.json".freeze
Class Method Summary collapse
-
.file ⇒ String?
The contents of the file.
-
.instance ⇒ Config
Instantiate and return or just return the currently instantiated Berkshelf configuration.
- .path ⇒ String
- .path=(new_path) ⇒ Object
-
.reload ⇒ Config
Reload the currently instantiated Berkshelf configuration.
Instance Method Summary collapse
-
#initialize(path = self.class.path, options = {}) ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize(path = self.class.path, options = {}) ⇒ Config
Returns a new instance of Config.
50 51 52 |
# File 'lib/berkshelf/config.rb', line 50 def initialize(path = self.class.path, = {}) super(path, ) end |
Class Method Details
.file ⇒ String?
Returns the contents of the file.
22 23 24 |
# File 'lib/berkshelf/config.rb', line 22 def file File.read(path) if File.exists?(path) end |
.instance ⇒ Config
Instantiate and return or just return the currently instantiated Berkshelf configuration
30 31 32 33 34 35 36 |
# File 'lib/berkshelf/config.rb', line 30 def instance @instance ||= if file from_json file else new end end |
.path ⇒ String
11 12 13 |
# File 'lib/berkshelf/config.rb', line 11 def path @path || File.join(Berkshelf.berkshelf_path, FILENAME) end |
.path=(new_path) ⇒ Object
16 17 18 |
# File 'lib/berkshelf/config.rb', line 16 def path=(new_path) @path = File.(new_path) end |
.reload ⇒ Config
Reload the currently instantiated Berkshelf configuration
41 42 43 44 |
# File 'lib/berkshelf/config.rb', line 41 def reload @instance = nil self.instance end |