Class: Nachos::Config
- Inherits:
-
Object
- Object
- Nachos::Config
- Defined in:
- lib/nachos/config.rb
Instance Method Summary collapse
- #config ⇒ Object
- #config_exists? ⇒ Boolean
- #config_path ⇒ Object
- #default_config ⇒ Object
- #display_config ⇒ Object
- #load_config ⇒ Object
- #repo_root ⇒ Object
Instance Method Details
#config ⇒ Object
8 9 10 |
# File 'lib/nachos/config.rb', line 8 def config config_exists? ? load_config : default_config end |
#config_exists? ⇒ Boolean
16 17 18 |
# File 'lib/nachos/config.rb', line 16 def config_exists? config_path.exist? end |
#config_path ⇒ Object
20 21 22 |
# File 'lib/nachos/config.rb', line 20 def config_path Pathname(ENV["HOME"]).join(".nachos") end |
#default_config ⇒ Object
24 25 26 |
# File 'lib/nachos/config.rb', line 24 def default_config @default_config ||= Hashie::Mash.new("repo_root" => "#{ENV["HOME"]}/src") end |
#display_config ⇒ Object
12 13 14 |
# File 'lib/nachos/config.rb', line 12 def display_config config_exists? ? load_config : "No config found - run nachos config to create one" end |
#load_config ⇒ Object
28 29 30 |
# File 'lib/nachos/config.rb', line 28 def load_config Hashie::Mash.new(YAML.load_file(config_path)) end |
#repo_root ⇒ Object
4 5 6 |
# File 'lib/nachos/config.rb', line 4 def repo_root Pathname(config.repo_root). end |