Class: Tekeya::Configuration

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/tekeya/configuration.rb

Overview

Parses the configuration file and holds important configuration attributes

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#feed_storage_ormObject

Returns the value of attribute feed_storage_orm.



10
11
12
# File 'lib/tekeya/configuration.rb', line 10

def feed_storage_orm
  @feed_storage_orm
end

#rebatObject (readonly)

Returns the value of attribute rebat.



9
10
11
# File 'lib/tekeya/configuration.rb', line 9

def rebat
  @rebat
end

#rebatdb_hostObject

Returns the value of attribute rebatdb_host.



10
11
12
# File 'lib/tekeya/configuration.rb', line 10

def rebatdb_host
  @rebatdb_host
end

#rebatdb_portObject

Returns the value of attribute rebatdb_port.



10
11
12
# File 'lib/tekeya/configuration.rb', line 10

def rebatdb_port
  @rebatdb_port
end

#redisObject (readonly)

Returns the value of attribute redis.



9
10
11
# File 'lib/tekeya/configuration.rb', line 9

def redis
  @redis
end

#redis_hostObject

Returns the value of attribute redis_host.



10
11
12
# File 'lib/tekeya/configuration.rb', line 10

def redis_host
  @redis_host
end

#redis_portObject

Returns the value of attribute redis_port.



10
11
12
# File 'lib/tekeya/configuration.rb', line 10

def redis_port
  @redis_port
end

Instance Method Details

#parse_config_file(path) ⇒ nil

Loads the configuration file

Returns:

  • (nil)


38
39
40
41
42
43
44
45
46
# File 'lib/tekeya/configuration.rb', line 38

def parse_config_file(path)
  return unless File.exists?(path)
  
  conf = YAML::load(ERB.new(IO.read(path)).result)[Rails.env]
  
  conf.each do |key,value|
    self.send("#{key}=", value) if self.respond_to?("#{key}=")
  end unless conf.nil?
end

#setup_databasesObject



25
26
27
28
29
30
31
32
33
34
# File 'lib/tekeya/configuration.rb', line 25

def setup_databases
  # Setup redis
  @redis = Redis.new host: @redis_host, port: @redis_port.to_i

  # Setup resque
  Resque.redis = @redis

  # Setup rebatdb
  @rebat = Rebat.new "#{@rebatdb_host}", "#{@rebatdb_port}", { tracks: 1, joins: 2, blocks: 3 }
end