Class: Nachos::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/nachos/config.rb

Instance Method Summary collapse

Instance Method Details

#configObject



8
9
10
# File 'lib/nachos/config.rb', line 8

def config
  config_exists? ? load_config : default_config
end

#config_exists?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/nachos/config.rb', line 16

def config_exists?
  config_path.exist?
end

#config_pathObject



20
21
22
# File 'lib/nachos/config.rb', line 20

def config_path
  Pathname(ENV["HOME"]).join(".nachos")
end

#default_configObject



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_configObject



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_configObject



28
29
30
# File 'lib/nachos/config.rb', line 28

def load_config
  Hashie::Mash.new(YAML.load_file(config_path))
end

#repo_rootObject



4
5
6
# File 'lib/nachos/config.rb', line 4

def repo_root
  Pathname(config.repo_root)
end