rack-app 0.2.3 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/LICENSE +2 -2
- data/README.md +3 -3
- data/VERSION +1 -1
- data/lib/rack/app.rb +4 -4
- data/lib/rack/app/class_methods.rb +5 -5
- data/lib/rack/app/endpoint.rb +1 -1
- data/lib/rack/app/endpoint/not_found.rb +2 -2
- data/lib/rack/app/request_helper/params.rb +4 -5
- data/lib/rack/app/request_helpers.rb +2 -2
- data/lib/rack/app/router.rb +5 -5
- data/lib/rack/app/router/dynamic.rb +4 -4
- data/lib/rack/app/router/static.rb +2 -2
- data/lib/rack/app/runner.rb +1 -1
- data/lib/rack/app/utils.rb +1 -1
- data/lib/rack/app/version.rb +2 -2
- data/rack-app.gemspec +1 -1
- data/spike/routing_time.rb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 08805ebc1c3be6338441b4ca870489333fdee27a
|
4
|
+
data.tar.gz: 0fc3f607f9bbc02ed4fe4392b49968e23612015e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eaa0c3dc517544bc6dee91ae97a3208a39172da520c4368c399f222e928947252ed7c87a9e9dec637d7352bc6abd616a44304331c6622419c77316f84b68d1d8
|
7
|
+
data.tar.gz: ae56428e27d1ad9e30ebb9e21b215cd440d3b0cde6bb97ef8a0ddcb92a2b4b15f6390ce631bee218de7efd426af76b6330f5755301fc93669e166d266be1f35a
|
data/Gemfile.lock
CHANGED
data/LICENSE
CHANGED
@@ -589,7 +589,7 @@ later version.
|
|
589
589
|
15. Disclaimer of Warranty.
|
590
590
|
|
591
591
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
592
|
-
|
592
|
+
AppLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
593
593
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
594
594
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
595
595
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
@@ -599,7 +599,7 @@ ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
|
599
599
|
|
600
600
|
16. Limitation of Liability.
|
601
601
|
|
602
|
-
IN NO EVENT UNLESS REQUIRED BY
|
602
|
+
IN NO EVENT UNLESS REQUIRED BY AppLICABLE LAW OR AGREED TO IN WRITING
|
603
603
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
604
604
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
605
605
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Rack::
|
1
|
+
# Rack::App
|
2
2
|
|
3
3
|
Your next favourite rack based micro framework that is totally addition free!
|
4
4
|
Have a cup of awesomeness with your performance designed framework!
|
@@ -39,7 +39,7 @@ require 'rack/app'
|
|
39
39
|
|
40
40
|
require_relative 'lib/bootstrap'
|
41
41
|
|
42
|
-
class YourAwesomeApp < Rack::
|
42
|
+
class YourAwesomeApp < Rack::App
|
43
43
|
|
44
44
|
mount AwesomeController
|
45
45
|
|
@@ -93,7 +93,7 @@ By default if you dont write anything to the response 'body' the endpoint block
|
|
93
93
|
* Dump duration with zero if or routing: 6.0e-06 s
|
94
94
|
* no routing
|
95
95
|
* return only a static array with static values
|
96
|
-
* Rack::
|
96
|
+
* Rack::App duration with routing lookup: 7.0e-05 s
|
97
97
|
* with routing
|
98
98
|
* with value parsing and reponse object building
|
99
99
|
* Grape::API duration with routing lookup: 0.180764 s
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/lib/rack/app.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'rack'
|
2
2
|
require 'rack/request'
|
3
3
|
require 'rack/response'
|
4
|
-
class Rack::
|
4
|
+
class Rack::App
|
5
5
|
|
6
6
|
require 'rack/app/version'
|
7
7
|
|
@@ -12,14 +12,14 @@ class Rack::APP
|
|
12
12
|
require 'rack/app/runner'
|
13
13
|
|
14
14
|
require 'rack/app/class_methods'
|
15
|
-
extend Rack::
|
15
|
+
extend Rack::App::ClassMethods
|
16
16
|
|
17
17
|
require 'rack/app/request_helpers'
|
18
18
|
|
19
|
-
include Rack::
|
19
|
+
include Rack::App::RequestHelpers
|
20
20
|
|
21
21
|
def self.call(request_env)
|
22
|
-
Rack::
|
22
|
+
Rack::App::Runner.response_for(self,request_env)
|
23
23
|
end
|
24
24
|
|
25
25
|
attr_reader :request, :response
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module Rack::
|
1
|
+
module Rack::App::ClassMethods
|
2
2
|
|
3
3
|
def description(*description_texts)
|
4
4
|
@last_description = description_texts.join("\n")
|
@@ -33,12 +33,12 @@ module Rack::APP::ClassMethods
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def router
|
36
|
-
@static_router ||= Rack::
|
36
|
+
@static_router ||= Rack::App::Router.new
|
37
37
|
end
|
38
38
|
|
39
39
|
def add_route(request_method, request_path, &block)
|
40
40
|
|
41
|
-
endpoint = Rack::
|
41
|
+
endpoint = Rack::App::Endpoint.new(
|
42
42
|
self,
|
43
43
|
{
|
44
44
|
request_method: request_method,
|
@@ -57,8 +57,8 @@ module Rack::APP::ClassMethods
|
|
57
57
|
|
58
58
|
def mount(api_class)
|
59
59
|
|
60
|
-
unless api_class.is_a?(Class) and api_class <= Rack::
|
61
|
-
raise(ArgumentError, 'Invalid class given for mount, must be a Rack::
|
60
|
+
unless api_class.is_a?(Class) and api_class <= Rack::App
|
61
|
+
raise(ArgumentError, 'Invalid class given for mount, must be a Rack::App')
|
62
62
|
end
|
63
63
|
|
64
64
|
router.merge!(api_class.router)
|
data/lib/rack/app/endpoint.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
api_class = Class.new(Rack::
|
2
|
-
Rack::
|
1
|
+
api_class = Class.new(Rack::App)
|
2
|
+
Rack::App::Endpoint::NOT_FOUND = Rack::App::Endpoint.new(api_class) do
|
3
3
|
response.status= 404
|
4
4
|
response.write '404 Not Found'
|
5
5
|
response.finish
|
@@ -1,11 +1,10 @@
|
|
1
1
|
require 'cgi'
|
2
|
-
class Rack::
|
2
|
+
class Rack::App::RequestHelpers::Params
|
3
3
|
|
4
|
-
def initialize(request_env,
|
4
|
+
def initialize(request_env, options = {})
|
5
5
|
@request_env = request_env
|
6
6
|
|
7
|
-
@path_params_matcher = path_params_matcher
|
8
|
-
|
7
|
+
@path_params_matcher = options[:path_params_matcher] || {}
|
9
8
|
end
|
10
9
|
|
11
10
|
def to_hash
|
@@ -32,7 +31,7 @@ class Rack::APP::RequestHelpers::Params
|
|
32
31
|
path_params = {}
|
33
32
|
if @path_params_matcher.is_a?(Hash) and not @path_params_matcher.empty?
|
34
33
|
|
35
|
-
request_path_parts = Rack::
|
34
|
+
request_path_parts = Rack::App::Utils.normalize_path(@request_env['REQUEST_PATH']).split('/')
|
36
35
|
|
37
36
|
path_params = request_path_parts.each.with_index.reduce({}) do |params_col, (path_part, index)|
|
38
37
|
if @path_params_matcher[index]
|
@@ -1,9 +1,9 @@
|
|
1
|
-
module Rack::
|
1
|
+
module Rack::App::RequestHelpers
|
2
2
|
|
3
3
|
require 'rack/app/request_helper/params'
|
4
4
|
|
5
5
|
def params
|
6
|
-
@__request_params__ ||= Rack::
|
6
|
+
@__request_params__ ||= Rack::App::RequestHelpers::Params.new(request.env,@options).to_hash
|
7
7
|
end
|
8
8
|
|
9
9
|
def status(new_status=nil)
|
data/lib/rack/app/router.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
class Rack::
|
1
|
+
class Rack::App::Router
|
2
2
|
|
3
3
|
require 'rack/app/router/static'
|
4
4
|
require 'rack/app/router/dynamic'
|
5
5
|
|
6
6
|
def add_endpoint(request_method, request_path, endpoint)
|
7
|
-
if defined_path_is_dynamic?(Rack::
|
7
|
+
if defined_path_is_dynamic?(Rack::App::Utils.normalize_path(request_path))
|
8
8
|
@dynamic_router.add_endpoint(request_method, request_path, endpoint)
|
9
9
|
else
|
10
10
|
@static_router.add_endpoint(request_method, request_path, endpoint)
|
@@ -14,7 +14,7 @@ class Rack::APP::Router
|
|
14
14
|
def fetch_endpoint(request_method, request_path)
|
15
15
|
@static_router.fetch_endpoint(request_method, request_path) or
|
16
16
|
@dynamic_router.fetch_endpoint(request_method, request_path) or
|
17
|
-
Rack::
|
17
|
+
Rack::App::Endpoint::NOT_FOUND
|
18
18
|
end
|
19
19
|
|
20
20
|
def merge!(router)
|
@@ -27,8 +27,8 @@ class Rack::APP::Router
|
|
27
27
|
protected
|
28
28
|
|
29
29
|
def initialize
|
30
|
-
@static_router = Rack::
|
31
|
-
@dynamic_router = Rack::
|
30
|
+
@static_router = Rack::App::Router::Static.new
|
31
|
+
@dynamic_router = Rack::App::Router::Dynamic.new
|
32
32
|
end
|
33
33
|
|
34
34
|
def defined_path_is_dynamic?(path_str)
|
@@ -1,9 +1,9 @@
|
|
1
|
-
class Rack::
|
1
|
+
class Rack::App::Router::Dynamic
|
2
2
|
|
3
|
-
ANY = 'Rack::
|
3
|
+
ANY = 'Rack::App::Router::Dynamic::ANY'.freeze
|
4
4
|
|
5
5
|
def add_endpoint(request_method, request_path, endpoint)
|
6
|
-
request_path = Rack::
|
6
|
+
request_path = Rack::App::Utils.normalize_path(request_path)
|
7
7
|
|
8
8
|
current_cluster = main_cluster(request_method)
|
9
9
|
path_params = {}
|
@@ -27,7 +27,7 @@ class Rack::APP::Router::Dynamic
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def fetch_endpoint(request_method, request_path)
|
30
|
-
normalized_request_path = Rack::
|
30
|
+
normalized_request_path = Rack::App::Utils.normalize_path(request_path)
|
31
31
|
|
32
32
|
current_cluster = main_cluster(request_method)
|
33
33
|
normalized_request_path.split('/').each do |path_part|
|
@@ -1,7 +1,7 @@
|
|
1
|
-
class Rack::
|
1
|
+
class Rack::App::Router::Static
|
2
2
|
|
3
3
|
def add_endpoint(request_method, request_path, endpoint)
|
4
|
-
@endpoints[[request_method.to_s.upcase, Rack::
|
4
|
+
@endpoints[[request_method.to_s.upcase, Rack::App::Utils.normalize_path(request_path)]]= endpoint
|
5
5
|
end
|
6
6
|
|
7
7
|
def fetch_endpoint(request_method, request_path)
|
data/lib/rack/app/runner.rb
CHANGED
data/lib/rack/app/utils.rb
CHANGED
data/lib/rack/app/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
Rack ||= Module.new
|
2
|
-
Rack::
|
3
|
-
Rack::
|
2
|
+
Rack::App ||= Class.new
|
3
|
+
Rack::App::VERSION = File.read(File.join(File.dirname(__FILE__), '..', '..', '..', 'VERSION')).strip
|
data/rack-app.gemspec
CHANGED
data/spike/routing_time.rb
CHANGED
@@ -2,8 +2,8 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
2
2
|
require 'rack/app'
|
3
3
|
require 'securerandom'
|
4
4
|
|
5
|
-
static_router = Rack::
|
6
|
-
dynamic_router = Rack::
|
5
|
+
static_router = Rack::App::Router::Static.new
|
6
|
+
dynamic_router = Rack::App::Router::Dynamic.new
|
7
7
|
|
8
8
|
classic_router = []
|
9
9
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-app
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Luzsi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -118,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
118
|
version: '0'
|
119
119
|
requirements: []
|
120
120
|
rubyforge_project:
|
121
|
-
rubygems_version: 2.
|
121
|
+
rubygems_version: 2.4.8
|
122
122
|
signing_key:
|
123
123
|
specification_version: 4
|
124
124
|
summary: Your next favourite, performance designed micro framework!
|