lib/rocketio.rb in rocketio-0.3.0 vs lib/rocketio.rb in rocketio-0.4.0

- old
+ new

@@ -19,63 +19,56 @@ 'stage' => 'stage'.freeze, 'production' => 'production'.freeze, }.freeze environment = ENV['APP_ENV'] || ENV['RACK_ENV'] || ENVIRONMENTS.values[0] - unless ENVIRONMENT = ENVIRONMENTS[environment] - raise(StandardError, '%s environment not supported. Use one of %s' % [environment.inspect, ENVIRONMENTS.keys*', ']) - end + ENVIRONMENT = ENVIRONMENTS[environment] + ENVIRONMENT || raise(StandardError, '%s environment not supported. Use one of %s' % [environment.inspect, ENVIRONMENTS.keys*', ']) def environment ENVIRONMENT end ENVIRONMENTS.each_value do |env| define_method(env + '?') {ENVIRONMENT == env} end - GET = 'GET'.freeze - POST = 'POST'.freeze - PUT = 'PUT'.freeze - DELETE = 'DELETE'.freeze - HEAD = 'HEAD'.freeze - REQUEST_METHODS = { - GET => :get, - POST => :post, - PUT => :put, - DELETE => :delete, - HEAD => :head + (GET = 'GET'.freeze) => :get, + (POST = 'POST'.freeze) => :post, + (PUT = 'PUT'.freeze) => :put, + (DELETE = 'DELETE'.freeze) => :delete, + (HEAD = 'HEAD'.freeze) => :head }.freeze INDEX_METHOD = :index - EMPTY_STRING = ''.freeze + EMPTY_STRING = ''.freeze EMPTY_STRING_PROC = proc {RocketIO::EMPTY_STRING} - EMPTY_ARRAY = [].freeze - EMPTY_HASH = {}.freeze + EMPTY_ARRAY = [].freeze + EMPTY_HASH = {}.freeze - SLASH = '/'.freeze - QUERY_PREFIX = '?'.freeze + SLASH = '/'.freeze + QUERY_PREFIX = '?'.freeze PATH_SPLITTER = /[^\/]+/.freeze - CONTENT_TYPE = 'Content-Type'.freeze - DEFAULT_CONTENT_TYPE = 'text/html'.freeze - CONTENT_LENGTH = 'Content-Length'.freeze - CONTENT_DISPOSITION = 'Content-Disposition'.freeze + CONTENT_TYPE = 'Content-Type'.freeze + DEFAULT_CONTENT_TYPE = 'text/html'.freeze + CONTENT_LENGTH = 'Content-Length'.freeze + CONTENT_DISPOSITION = 'Content-Disposition'.freeze APPLICATION_OCTET_STREAM = 'application/octet-stream'.freeze - APPLICATION_JSON = 'application/json'.freeze - APPLICATION_JSON_REGEXP = /application\/json/i + APPLICATION_JSON = 'application/json'.freeze + APPLICATION_JSON_REGEXP = /application\/json/i - DEFAULT_AUTH_REALM = 'AccessRestricted'.freeze + DEFAULT_AUTH_REALM = 'AccessRestricted'.freeze DEFAULT_TOKEN_AUTH_REALM = 'Application'.freeze REQUEST_METHOD = 'REQUEST_METHOD'.freeze - PATH_INFO = 'PATH_INFO'.freeze - HTTP_ACCEPT = 'HTTP_ACCEPT'.freeze - REMOTE_USER = 'REMOTE_USER'.freeze + PATH_INFO = 'PATH_INFO'.freeze + HTTP_ACCEPT = 'HTTP_ACCEPT'.freeze + REMOTE_USER = 'REMOTE_USER'.freeze HTTP_CONTENT_TYPE = 'CONTENT_TYPE'.freeze HTTP_CONNECTION = 'HTTP_CONNECTION'.freeze HTTP_AUTHORIZATION_KEYS = ['HTTP_AUTHORIZATION', 'X-HTTP_AUTHORIZATION', 'X_HTTP_AUTHORIZATION'].map(&:freeze).freeze @@ -122,26 +115,28 @@ end.freeze BEFORE_FORMAT = 'before_%s'.freeze AROUND_FORMAT = 'around_%s'.freeze AFTER_FORMAT = 'after_%s'.freeze - ROUTE_INSPECT_FORMAT = '#<RocketIO::Route:%s>'.freeze - ENGINE_CONST_FORMAT = '%sTemplate'.freeze - TEMPLATE_PATH_FORMAT = '%s/%s.%s'.freeze - FOUND_TEMPLATES = {} - READ_TEMPLATES = {} - COMPILED_TEMPLATES = {} + INHERITABLE_SETUPS = [ + :before, + :around, + :after, + :basic_auth, + :digest_auth, + :token_auth, + :error_handlers, + :middleware, + :sessions, + ] - DEFAULT_ENGINE = [Tilt::ERBTemplate, [].freeze].freeze - def controllers @controllers ||= [] end end require 'rocketio/util' -require 'rocketio/exceptions' require 'rocketio/controller' require 'rocketio/router' require 'rocketio/application' RocketIO::Controller.map(RocketIO::SLASH)