Class: Tootsie::Application
- Inherits:
-
Object
- Object
- Tootsie::Application
- Defined in:
- lib/tootsie/application.rb
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
-
#task_manager ⇒ Object
readonly
Returns the value of attribute task_manager.
Class Method Summary collapse
Instance Method Summary collapse
- #configure!(config_path) ⇒ Object
-
#initialize(options = {}) ⇒ Application
constructor
A new instance of Application.
- #s3_service ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Application
Returns a new instance of Application.
5 6 7 8 9 |
# File 'lib/tootsie/application.rb', line 5 def initialize( = {}) @@instance = self @logger = Logger.new('/dev/null') @configuration = Configuration.new end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
61 62 63 |
# File 'lib/tootsie/application.rb', line 61 def configuration @configuration end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
64 65 66 |
# File 'lib/tootsie/application.rb', line 64 def logger @logger end |
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
63 64 65 |
# File 'lib/tootsie/application.rb', line 63 def queue @queue end |
#task_manager ⇒ Object (readonly)
Returns the value of attribute task_manager.
62 63 64 |
# File 'lib/tootsie/application.rb', line 62 def task_manager @task_manager end |
Class Method Details
.get ⇒ Object
56 57 58 |
# File 'lib/tootsie/application.rb', line 56 def get @@instance end |
Instance Method Details
#configure!(config_path) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/tootsie/application.rb', line 11 def configure!(config_path) @configuration.load_from_file(config_path) case @configuration.log_path when 'syslog' @logger = SyslogLogger.new('tootsie') when String @logger = Logger.new(@configuration.log_path) else @logger = Logger.new($stderr) end @logger.info "Starting" = @configuration. ||= {} adapter = ([:adapter] || 'sqs').to_s case adapter when 'sqs' @queue = Tootsie::SqsQueue.new( :queue_name => [:queue], :access_key_id => @configuration.aws_access_key_id, :secret_access_key => @configuration.aws_secret_access_key, :max_backoff => [:max_backoff]) when 'amqp' @queue = Tootsie::AmqpQueue.new( :host_name => [:host], :queue_name => [:queue], :max_backoff => [:max_backoff]) when 'file' @queue = Tootsie::FileSystemQueue.new([:root]) else raise 'Invalid queue configuration' end @task_manager = TaskManager.new(@queue) end |
#s3_service ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/tootsie/application.rb', line 47 def s3_service abort "AWS access key and secret required" unless @configuration.aws_access_key_id and @configuration.aws_secret_access_key return @s3_service ||= ::S3::Service.new( :access_key_id => @configuration.aws_access_key_id, :secret_access_key => @configuration.aws_secret_access_key) end |