class Boto::Application

Attributes

called_from[RW]

Public Class Methods

config() click to toggle source
# File lib/boto/application.rb, line 37
def config
  @config ||= OpenStruct.new(root: find_root(Boto.app_class.called_from))
end
find_root(path) click to toggle source
# File lib/boto/application.rb, line 33
def find_root(path)
  Pathname.new(path).dirname
end
inherited(app_class) click to toggle source
Calls superclass method
# File lib/boto/application.rb, line 12
def inherited(app_class)
  Boto.app_class = app_class

  app_class.called_from = begin
    call_stack = if Kernel.respond_to?(:caller_locations)
      caller_locations.map { |l| l.absolute_path || l.path }
    else
      # Remove the line number from backtraces making sure we don't leave anything behind
      caller.map { |p| p.sub(/:\d+.*/, '') }
    end

    File.dirname(call_stack.detect { |p| p !~ %r[boto[\w.-]*/lib/boto] })
  end

  $LOAD_PATH.unshift("#{root}/lib")
  Dir["#{root}/lib/**/*.rb"].sort.each { |file| require file }
  Dotenv.load

  super
end
root() click to toggle source
# File lib/boto/application.rb, line 41
def root
  config.root
end

Public Instance Methods

adapter() click to toggle source
# File lib/boto/application.rb, line 54
def adapter
  config.adapter
end
config() click to toggle source
# File lib/boto/application.rb, line 46
def config
  self.class.config
end
root() click to toggle source
# File lib/boto/application.rb, line 50
def root
  config.root
end