Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base: cbee3cb94c
...
compare: ee73cd1e90
Checking mergeability… Don't worry, you can still create the pull request.
  • 3 commits
  • 5 files changed
  • 0 commit comments
  • 1 contributor
View
2  Gemfile.lock
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
- roy (0.5.1)
+ roy (0.5.2)
rack
GEM
View
20 lib/roy/base.rb
@@ -7,6 +7,7 @@
# local dependencies
require 'roy/version'
+require 'roy/context'
module Roy
Defaults = {allow: [:get], prefix: :'', use: [:halt]}
@@ -16,26 +17,11 @@ def self.included(base)
end
def roy
- @roy ||= OpenStruct.new.tap {|r|
- r.app = self
- r.conf = self.class.conf
- self.class.ancestors.reverse.each do |mod|
- mod.setup(r) if mod.respond_to?(:setup)
- end
- }
+ @roy ||= Context.new(self)
end
def call(env)
- roy.tap { |r|
- r.env = env
- r.request = Rack::Request.new(env)
- r.response = Rack::Response.new
- r.headers = r.response.header
- r.params = r.request.GET.merge(r.request.POST)
- r.params.default_proc = proc do |hash, key|
- hash[key.to_s] if Symbol === key
- end
- }
+ roy.prepare!(env)
method = roy.env['REQUEST_METHOD'].downcase.to_sym
roy.env['PATH_INFO'].sub!(/^([^\/])/, '/\1')
View
25 lib/roy/context.rb
@@ -0,0 +1,25 @@
+module Roy
+ class Context
+ attr_reader :app, :conf, :env, :request, :response, :headers, :params
+
+ def initialize(app)
+ @app = app
+ @conf = app.class.conf
+
+ app.class.ancestors.reverse.each do |mod|
+ mod.setup(self) if mod.respond_to?(:setup)
+ end
+ end
+
+ def prepare!(env)
+ @env = env
+ @request = Rack::Request.new(env)
+ @response = Rack::Response.new
+ @headers = @response.header
+ @params = @request.GET.merge(@request.POST)
+ @params.default_proc = proc do |hash, key|
+ hash[key.to_s] if Symbol === key
+ end
+ end
+ end
+end
View
6 lib/roy/version.rb
@@ -1,3 +1,7 @@
module Roy
- VERSION = "0.5.1"
+ VERSION = [0, 5, 2]
+
+ def self.version
+ VERSION.join('.')
+ end
end
View
2  roy.gemspec
@@ -4,7 +4,7 @@ require "roy/version"
Gem::Specification.new do |s|
s.name = "roy"
- s.version = Roy::VERSION
+ s.version = Roy.version
s.authors = ["madx"]
s.email = ["madx@yapok.org"]
s.homepage = "https://github.com/madx/roy"

No commit comments for this range

Something went wrong with that request. Please try again.