lib/hanami.rb in hanami-2.0.0.alpha8 vs lib/hanami.rb in hanami-2.0.0.beta1

- old
+ new

@@ -1,73 +1,81 @@ # frozen_string_literal: true -require_relative "hanami/application" -require_relative "hanami/errors" -require_relative "hanami/version" - - # A complete web framework for Ruby # # @since 0.1.0 # # @see http://hanamirb.org module Hanami @_mutex = Mutex.new + @_bundled = {} - def self.application + def self.app @_mutex.synchronize do - unless defined?(@_application) - raise ApplicationLoadError, - "Hanami.application is not yet configured. " \ - "You may need to `require \"hanami/setup\"` to load your config/application.rb file." + unless defined?(@_app) + raise AppLoadError, + "Hanami.app is not yet configured. " \ + "You may need to `require \"hanami/setup\"` to load your config/app.rb file." end - @_application + @_app end end - def self.application? - defined?(@_application) + def self.app? + defined?(@_app) end - def self.application=(klass) + def self.app=(klass) @_mutex.synchronize do - if defined?(@_application) - raise ApplicationLoadError, "Hanami.application is already configured." + if defined?(@_app) + raise AppLoadError, "Hanami.app is already configured." end - @_application = klass unless klass.name.nil? + @_app = klass unless klass.name.nil? end end - def self.rack_app - application.rack_app - end - def self.env - (ENV["HANAMI_ENV"] || "development").to_sym + ENV.fetch("HANAMI_ENV") { ENV.fetch("RACK_ENV", "development") }.to_sym end def self.env?(*names) names.map(&:to_sym).include?(env) end def self.logger - application[:logger] + app[:logger] end def self.prepare - application.prepare + app.prepare end def self.boot - application.boot + app.boot end def self.shutdown - application.shutdown + app.shutdown end + def self.bundled?(gem_name) + @_mutex.synchronize do + @_bundled[gem_name] ||= begin + gem(gem_name) + true + rescue Gem::LoadError + false + end + end + end + def self.bundler_groups [:plugins] end + + require_relative "hanami/version" + require_relative "hanami/errors" + require_relative "hanami/extensions" + require_relative "hanami/app" end