Sha256: 1f09a4d3a08a88897f9fb7c0b7a0ac50091c0599fbcf3158e58c99e49e95401a

Contents?: true

Size: 1.68 KB

Versions: 16

Compression:

Stored size: 1.68 KB

Contents

require 'rubygems'
require 'bundler/setup'

require 'fileutils'

module RubyApp
  require 'ruby_app/configuration'
  require 'ruby_app/log'
  require 'ruby_app/mixins'
  require 'ruby_app/version'

  class Application
    extend RubyApp::Mixins::ConfigurationMixin
    extend RubyApp::Mixins::DelegateMixin

    attr_reader :options, :environment

    def initialize

      @environment = {}

      RubyApp::Log.info("LOG       RubyApp::Application.root                    = #{RubyApp::Application.root.inspect}")
      RubyApp::Log.info("LOG       RubyApp::Response.configuration.cache.read?  = #{RubyApp::Response.configuration.cache.read?}")
      RubyApp::Log.info("LOG       RubyApp::Response.configuration.cache.write? = #{RubyApp::Response.configuration.cache.write?}")

    end

    def self.root
      @@_root ||= '/'
    end

    def self.root=(value)
      @@_root = value
    end

    def self.root_or_nil
      return self.root.nil_if('/')
    end

    def self.get
      @@_application ||= nil
    end

    def self.exists?
      return @@_application ||= nil
    end

    def self.create!
      @@_application = ( Kernel.eval(RubyApp::Application.configuration._class) ).new
    end

    def self.destroy!
      @@_application = nil
    end

    def self.create_context!(configuration_paths = [File.join(RubyApp::ROOT, %w[configuration.yml])])
      unless RubyApp::Application.exists?
        RubyApp::Configuration.load!(configuration_paths)
        RubyApp::Log.open!
        RubyApp::Application.create!
        begin
          yield
        ensure
          RubyApp::Application.destroy!
          RubyApp::Log.close!
          RubyApp::Configuration.unload!
        end
      end
    end

  end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
RubyApp-0.7.16 lib/ruby_app/application.rb
RubyApp-0.7.15 lib/ruby_app/application.rb
RubyApp-0.7.14 lib/ruby_app/application.rb
RubyApp-0.7.13 lib/ruby_app/application.rb
RubyApp-0.7.12 lib/ruby_app/application.rb
RubyApp-0.7.11 lib/ruby_app/application.rb
RubyApp-0.7.10 lib/ruby_app/application.rb
RubyApp-0.7.9 lib/ruby_app/application.rb
RubyApp-0.7.5 lib/ruby_app/application.rb
RubyApp-0.7.4 lib/ruby_app/application.rb
RubyApp-0.7.3 lib/ruby_app/application.rb
RubyApp-0.7.2 lib/ruby_app/application.rb
RubyApp-0.7.1 lib/ruby_app/application.rb
RubyApp-0.7.0 lib/ruby_app/application.rb
RubyApp-0.6.71 lib/ruby_app/application.rb
RubyApp-0.6.70 lib/ruby_app/application.rb