Class: Birdy::Config

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

Constant Summary collapse

CONFIG_PATH =
"#{ENV['HOME']}/.config/birdy/"
CONFIG_FILE =
CONFIG_PATH + "birdy.yml"

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



7
8
9
# File 'lib/birdy/config.rb', line 7

def initialize
  FileUtils.mkdir_p CONFIG_PATH
end

Instance Method Details

#deleteObject



25
26
27
28
29
# File 'lib/birdy/config.rb', line 25

def delete
  File.delete(CONFIG_FILE)
rescue
  nil
end

#readObject



19
20
21
22
23
# File 'lib/birdy/config.rb', line 19

def read
  YAML.load_file(CONFIG_FILE)
rescue
  {}
end

#write(login, password) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/birdy/config.rb', line 11

def write(, password)
  config = {:login => , :password => password}

  File.open(CONFIG_FILE, 'w') do |out|
    YAML.dump(config, out)
  end
end