Class: Tootsie::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/tootsie/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



5
6
7
8
9
# File 'lib/tootsie/configuration.rb', line 5

def initialize
  @ffmpeg_thread_count = 1
  @worker_count = 4
  @queue_options = {}
end

Instance Attribute Details

#aws_access_key_idObject

Returns the value of attribute aws_access_key_id.



35
36
37
# File 'lib/tootsie/configuration.rb', line 35

def aws_access_key_id
  @aws_access_key_id
end

#aws_secret_access_keyObject

Returns the value of attribute aws_secret_access_key.



34
35
36
# File 'lib/tootsie/configuration.rb', line 34

def aws_secret_access_key
  @aws_secret_access_key
end

#ffmpeg_thread_countObject

Returns the value of attribute ffmpeg_thread_count.



30
31
32
# File 'lib/tootsie/configuration.rb', line 30

def ffmpeg_thread_count
  @ffmpeg_thread_count
end

#log_pathObject

Returns the value of attribute log_path.



32
33
34
# File 'lib/tootsie/configuration.rb', line 32

def log_path
  @log_path
end

#pid_pathObject

Returns the value of attribute pid_path.



31
32
33
# File 'lib/tootsie/configuration.rb', line 31

def pid_path
  @pid_path
end

#queue_optionsObject

Returns the value of attribute queue_options.



29
30
31
# File 'lib/tootsie/configuration.rb', line 29

def queue_options
  @queue_options
end

#worker_countObject

Returns the value of attribute worker_count.



33
34
35
# File 'lib/tootsie/configuration.rb', line 33

def worker_count
  @worker_count
end

Instance Method Details

#load_from_file(file_name) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/tootsie/configuration.rb', line 11

def load_from_file(file_name)
  config = (YAML.load(File.read(file_name)) || {}).with_indifferent_access
  [:ffmpeg_thread_count, :worker_count, :pid_path, :log_path,
    :aws_access_key_id, :aws_secret_access_key].each do |key|
    if config.include?(key)
      value = config[key]
      value = $1.to_i if value =~ /\A\s*(\d+)\s*\z/
      instance_variable_set("@#{key}", value)
    end
  end

  @queue_options = (config[:queue] ||= {}).symbolize_keys

  # Backwards compatibility with old options
  @queue_options[:adapter] ||= 'sqs'
  @queue_options[:queue] ||= config[:sqs_queue_name]
end