Sha256: 04d1134212457cc7690bc7928828bfeba163e726413ba3625e6fcc0413cca246

Contents?: true

Size: 1.52 KB

Versions: 1

Compression:

Stored size: 1.52 KB

Contents

#  Copyright (c) 2013-2014 SUSE LLC
#
#  This program is free software; you can redistribute it and/or
#  modify it under the terms of version 3 of the GNU General Public License as
#  published by the Free Software Foundation.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.   See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, contact SUSE LLC.
#
#  To contact SUSE about this file by physical or electronic mail,
#  you may find current contact information at www.suse.com

class Settings

  attr_accessor :verbose, :raw
  attr_accessor :developer_public_key, :member_token

  def initialize config_file_path
    @config_file_path = config_file_path
    if File.exists? config_file_path
      @config = YAML.load_file(config_file_path)

      if @config
        @developer_public_key = @config["developer_public_key"]
        @member_token = @config["member_token"]
      else
        raise "Couldn't read config data from '#{config_file_path}'"
      end
    end
    
    @verbose = false
    @raw = false
  end

  def save_config
    @config = {}
    @config["developer_public_key"] = @developer_public_key
    @config["member_token"] = @member_token
    
    File.open(@config_file_path,"w") do |f|
      f.write(@config.to_yaml)
    end
  end
  
  def version
    Trollolo::VERSION
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
trollolo-0.0.3 lib/settings.rb