Class: Berkshelf::Config
- Inherits:
-
Buff::Config::JSON
- Object
- Buff::Config::JSON
- Berkshelf::Config
- Defined in:
- lib/berkshelf/config.rb
Class Method Summary collapse
-
.file ⇒ String?
The contents of the file.
-
.instance ⇒ Config
Instantiate and return or just return the currently instantiated Berkshelf configuration.
- .local_location ⇒ String
- .path ⇒ String
-
.reload ⇒ Config
Reload the currently instantiated Berkshelf configuration.
- .set_config(config) ⇒ Object
- .set_path(new_path) ⇒ Object
- .store_location ⇒ String
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.
62 63 64 |
# File 'lib/berkshelf/config.rb', line 62 def initialize(path = self.class.path, = {}) super(path, ) end |
Class Method Details
.file ⇒ String?
Returns the contents of the file.
34 35 36 |
# File 'lib/berkshelf/config.rb', line 34 def file File.read(path) if File.exists?(path) end |
.instance ⇒ Config
Instantiate and return or just return the currently instantiated Berkshelf configuration
42 43 44 45 46 47 48 |
# File 'lib/berkshelf/config.rb', line 42 def instance @instance ||= if file from_json file else new end end |
.local_location ⇒ String
12 13 14 |
# File 'lib/berkshelf/config.rb', line 12 def local_location ENV['BERKSHELF_CONFIG'] || File.join('.', '.berkshelf', 'config.json') end |
.path ⇒ String
17 18 19 20 |
# File 'lib/berkshelf/config.rb', line 17 def path path = File.exists?(local_location) ? local_location : store_location File.(path) end |
.reload ⇒ Config
Reload the currently instantiated Berkshelf configuration
53 54 55 56 |
# File 'lib/berkshelf/config.rb', line 53 def reload @instance = nil self.instance end |
.set_config(config) ⇒ Object
23 24 25 |
# File 'lib/berkshelf/config.rb', line 23 def set_config(config) @instance = config end |
.set_path(new_path) ⇒ Object
28 29 30 |
# File 'lib/berkshelf/config.rb', line 28 def set_path(new_path) @instance = nil end |
.store_location ⇒ String
7 8 9 |
# File 'lib/berkshelf/config.rb', line 7 def store_location File.join(Berkshelf.berkshelf_path, 'config.json') end |