class ShopkeepReports::Configuration

Attributes

account[RW]
email[RW]
password[RW]
tmp_directory[RW]

Public Class Methods

instance() click to toggle source
# File lib/shopkeep_reports/configuration.rb, line 9
def self.instance
  @@instance ||= new
end

Public Instance Methods

init(args = {}) click to toggle source
# File lib/shopkeep_reports/configuration.rb, line 13
def init(args = {})
  @email = default_email
  @password = default_password
  @account = default_account
  @tmp_directory = "/tmp"
  args.each_pair do |option, value|
    self.send("#{option}=", value)
  end
end
transaction_uri(path) click to toggle source
# File lib/shopkeep_reports/configuration.rb, line 35
def transaction_uri(path)
  "https://www.shopkeepapp.com" + path
end
uri(path) click to toggle source
# File lib/shopkeep_reports/configuration.rb, line 31
def uri(path)
  "https://" + @account + ".shopkeepapp.com" + path
end
valid?() click to toggle source
# File lib/shopkeep_reports/configuration.rb, line 23
def valid?
  result = true
  [:email, :password, :account, :tmp_directory].each do |value|
    result = false if self.send(value).blank?
  end
  result
end

Private Instance Methods

default_account() click to toggle source
# File lib/shopkeep_reports/configuration.rb, line 48
def default_account
  ENV['SHOPKEEP_ACCOUNT']
end
default_email() click to toggle source
# File lib/shopkeep_reports/configuration.rb, line 40
def default_email
  ENV['SHOPKEEP_EMAIL']
end
default_password() click to toggle source
# File lib/shopkeep_reports/configuration.rb, line 44
def default_password
  ENV['SHOPKEEP_PASSWORD']
end