module RMAL::Settings

Configuration of password, username and apikey, for use by other modules

Public Class Methods

init(dir = "/") click to toggle source

Create the settings.yml file

# File lib/rMAL.rb, line 9
def self.init(dir = "/") # Default dir may not have the correct access rights granted
        # Allows user to not bother with the trailing / if so desired
        if !(dir.end_with? "/")
                dir = dir + "/"
        end
        # Create a settings.yml file
        File.open("#{dir}settings.yml", "w") do |file|
        end
        # Create global path variable for ease of use
        $path = "#{dir}/settings.yml"
end
set(username, password, apikey) click to toggle source

Allows the user to change the settings where necessary (and rMAL where necessary)

# File lib/rMAL.rb, line 21
def self.set(username, password, apikey)
        configuration = {
                'username' => username,
                'password' => password,
                'apikey' => apikey
        }
        open($path, 'w') { |f| YAML.dump(configuration, f) }
        open($path) { |f| return f.read }
end