class ZendeskPolly::Config

Attributes

aws_key[RW]
aws_region[RW]
aws_secret[RW]
client[R]
zendesk_token[RW]
zendesk_url[RW]
zendesk_username[RW]

Public Class Methods

new(client = nil) click to toggle source
# File lib/zendesk_polly/config.rb, line 10
def initialize(client = nil)
  @client = client # retrieves the client to allow reseting when changing attributes
  deserialize_from_file if File.exist?(config_file)
  @aws_region ||= 'us-east-1'
end

Public Instance Methods

attributes() click to toggle source
# File lib/zendesk_polly/config.rb, line 37
def attributes
  {
    zendesk_token:          zendesk_token,
    zendesk_username:       zendesk_username,
    zendesk_url:            zendesk_url,
    aws_key:                aws_key,
    aws_secret:             aws_secret,
    aws_region:             aws_region
  }
end
attributes=(options) click to toggle source
# File lib/zendesk_polly/config.rb, line 28
def attributes=(options)
  self.zendesk_token      = options[:zendesk_token]
  self.zendesk_username   = options[:zendesk_username]
  self.zendesk_url        = options[:zendesk_url]
  self.aws_region         = options[:aws_region]
  self.aws_key            = options[:aws_key]
  self.aws_secret         = options[:aws_secret]
end
config_file() click to toggle source
# File lib/zendesk_polly/config.rb, line 16
def config_file
  @config_file ||= File.join(File.expand_path('~'), '.zendesk_polly')
end
deserialize_from_file() click to toggle source
# File lib/zendesk_polly/config.rb, line 20
def deserialize_from_file
  self.attributes = YAML.load_file(config_file)
end
polly_configuration() click to toggle source
# File lib/zendesk_polly/config.rb, line 52
def polly_configuration
  attributes.select{ |k, _| k =~ /\Aaws/ }
end
serialize_to_file() click to toggle source
# File lib/zendesk_polly/config.rb, line 24
def serialize_to_file
  File.write(config_file, attributes.to_yaml)
end
zendesk_configuration() click to toggle source
# File lib/zendesk_polly/config.rb, line 48
def zendesk_configuration
  attributes.select{ |k, _| k =~ /\Azendesk/ }
end