lib/goliath/application.rb in goliath-0.9.4 vs lib/goliath/application.rb in goliath-1.0.0.beta.1

- old
+ new

@@ -1,22 +1,9 @@ require 'goliath/goliath' require 'goliath/runner' require 'goliath/rack' -# Pre-load the goliath environment so it's available as we try to parse the class. -# This means we can use Goliath.dev? or Goliath.prod? in the use statements. -# -# Note, as implmented, you have to have -e as it's own flag, you can't do -sve dev -# as it won't pickup the e flag. -env = ENV['RACK_ENV'] -env ||= begin - if ((i = ARGV.index('-e')) || (i = ARGV.index('--environment'))) - ARGV[i + 1] - end - end -Goliath.env = env if env - module Goliath # The main execution class for Goliath. This will execute in the at_exit # handler to run the server. # # @private @@ -89,11 +76,11 @@ # Retrieve the base directory for the API # # @param args [Array] Any arguments to append to the path # @return [String] path for the given arguments def self.root_path(*args) - return app_path(args) if Goliath.test? + return app_path(args) if Goliath.env?(:test) @root_path ||= File.expand_path("./") File.join(@root_path, *args) end @@ -106,15 +93,14 @@ @app_class = camel_case(file) end begin klass = Kernel - @app_class.split('::').each do |con| - klass = klass.const_get(con) - end + @app_class.split('::').each { |con| klass = klass.const_get(con) } rescue NameError raise NameError, "Class #{@app_class} not found." end + api = klass.new runner = Goliath::Runner.new(ARGV, api) runner.app = Goliath::Rack::Builder.build(klass, api)