Class: Wutang::Config

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



5
6
7
8
# File 'lib/wutang/config.rb', line 5

def initialize
  @config_file = File.expand_path('~/.wutang.yml')
  parse
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



3
4
5
# File 'lib/wutang/config.rb', line 3

def attributes
  @attributes
end

#config_fileObject (readonly)

Returns the value of attribute config_file.



3
4
5
# File 'lib/wutang/config.rb', line 3

def config_file
  @config_file
end

Instance Method Details

#parseObject



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/wutang/config.rb', line 10

def parse
  if File.world_readable?(config_file)
    puts "Your config file has world readable permissions"
    puts "Please run: chmod 640 ~/.wutang.yml"
    exit 1
  elsif File.exists?(config_file)
    @attributes = YAML.load_file(config_file)
  else
    puts "Please create a ~/.wutang.yml with a `path` and `pasphrase`"
    exit 1
  end
end