Sha256: a19ba7500e9a3ecb66d38fdda25fd0d76704bd737f4189892735aa0c7a88d063

Contents?: true

Size: 448 Bytes

Versions: 3

Compression:

Stored size: 448 Bytes

Contents

require 'yaml'
require 'parseconfig'

class Settings

  def initialize(path)
    @path = path
    if !File.exist?(path) 
      FileUtils.mkdir_p("#{Dir.home}/.config/Propre/")
      FileUtils.touch(path)
    end
    conf = YAML.load_file(path)
    @settings = conf ? conf : Hash.new
  end

  def get(key)
    @settings[key]
  end

  def set(key, value)
    @settings[key] = value
    File.open(@path, 'w') { |f| YAML.dump(@settings, f) }
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
propre-0.1.1 lib/propre/settings.rb
propre-0.1.0 lib/propre/settings.rb
propre-0.0.8 lib/propre/settings.rb