class BodegaShopify::Configuration

Attributes

config[RW]
environment[RW]
shopify_config[RW]

Public Class Methods

new(params={}) click to toggle source
# File lib/bodega-shopify/configuration.rb, line 7
def initialize params={}
  self.environment = (params[:environment] || DEFAULT_ENVIRONMENT).to_sym
  self.config = File.exists?(CONFIG_FILE) ? YAML.load(File.read(CONFIG_FILE)) || {} : {}
  self.shopify_config = File.exists?(SHOPIFY_CONFIG_FILE) ? YAML.load(File.read(SHOPIFY_CONFIG_FILE)) || {} : {}
  BodegaShopify.logger.info "Configured #{environment} store #{store}"
  save_shopify_config
end

Public Instance Methods

api_key() click to toggle source
# File lib/bodega-shopify/configuration.rb, line 19
def api_key
  config[environment][:api_key]
end
config_file(key) click to toggle source
# File lib/bodega-shopify/configuration.rb, line 15
def config_file key
  config[key.to_s].to_s.chomp("/").reverse.chomp("/").reverse if config.has_key?(key.to_s)
end
ignore_files() click to toggle source
# File lib/bodega-shopify/configuration.rb, line 31
def ignore_files
  (shopify_config[:ignore_files] || []).compact.map { |r| Regexp.new(r) }
end
last_sync_at() click to toggle source
# File lib/bodega-shopify/configuration.rb, line 35
def last_sync_at
  config[environment][:last_sync_at] ||= Time.parse('2000-01-01 00:00:00')
end
last_sync_at=(last_sync_at) click to toggle source
# File lib/bodega-shopify/configuration.rb, line 39
def last_sync_at= last_sync_at
  config[environment][:last_sync_at] = last_sync_at
end
password() click to toggle source
# File lib/bodega-shopify/configuration.rb, line 23
def password
  config[environment][:password]
end
save() click to toggle source
# File lib/bodega-shopify/configuration.rb, line 43
def save
  File.open(CONFIG_FILE, 'w') {|f| f.write config.to_yaml }
end
save_shopify_config() click to toggle source
# File lib/bodega-shopify/configuration.rb, line 47
def save_shopify_config
  shopify_config[:api_key] = api_key
  shopify_config[:password] = password
  shopify_config[:store] = store
  File.open(SHOPIFY_CONFIG_FILE, 'w') {|f| f.write shopify_config.to_yaml }
end
store() click to toggle source
# File lib/bodega-shopify/configuration.rb, line 27
def store
  config[environment][:store]
end