rack-app 0.21.0 → 0.22.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -9
- data/VERSION +1 -1
- data/lib/rack/app.rb +15 -23
- data/lib/rack/app/file/server.rb +2 -5
- data/lib/rack/app/utils.rb +33 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc6e00653368212644684d6ba3c19c409eee6bad
|
4
|
+
data.tar.gz: 165212d0e3eaba27ff27f0b3e2534d70864be7dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 09b60839ee3b5a49f95c891f0b2c8a93be41503572c6943b313d42d0925e7be2a7c75625262da893c49bf2eac9707f53ad8ddae25d6c87fe0c8439fcb975c660
|
7
|
+
data.tar.gz: 5e808fc8b28adde7e389fd97f219ab9fde05d0a67d44bdab870e5e5aa18093f23f85aa5e1cfb9f1c5063dad9caf161d83792220704b60a571e6ade5dcc3d1134
|
data/README.md
CHANGED
@@ -180,15 +180,20 @@ end
|
|
180
180
|
|
181
181
|
## [Benchmarking](https://github.com/adamluzsi/rack-app.rb-benchmark)
|
182
182
|
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
183
|
+
| name | user | system | total | real |
|
184
|
+
|------------------|----------------------------|------------------------|-----------------------|------------------------|
|
185
|
+
| rack | 3.150000000000001e-05 | 1.3000000000000003e-06 | 3.280000000000001e-05 | 3.602101e-05 |
|
186
|
+
| rack-app | 0.0005159999999999999 | 1.4000000000000005e-05 | 0.0005300000000000001 | 0.0005141295 |
|
187
|
+
| ramaze | 0.0005166999999999999 | 1.98e-05 | 0.0005365 | 0.0005347348 |
|
188
|
+
| brooklyn | 0.0007564 | 3.700000000000001e-06 | 0.0007601000000000001 | 0.0007743060099999998 |
|
189
|
+
| nancy | 0.000812 | 5.900000000000001e-06 | 0.0008179000000000001 | 0.0008314749300000001 |
|
190
|
+
| scorched | 0.0008451000000000001 | 4.699999999999999e-06 | 0.0008498000000000001 | 0.00085131501 |
|
191
|
+
| sinatra | 0.0008465000000000001 | 7.000000000000001e-06 | 0.0008535000000000001 | 0.00086448211 |
|
192
|
+
| hobbit | 0.0013664 | 4.5e-06 | 0.0013709 | 0.0013804752700000004 |
|
193
|
+
| grape | 0.0018807 | 2.7800000000000005e-05 | 0.0019085 | 0.0019229531400000001 |
|
194
|
+
| rails | 0.0018995000000000001 | 7.06e-05 | 0.0019701 | 0.00198401458 |
|
195
|
+
| camping | 0.002921 | 7.24e-05 | 0.0029934000000000002 | 0.0030896778800000003 |
|
196
|
+
| cuba | 0.0034559000000000005 | 2.8600000000000004e-05 | 0.0034845 | 0.00349655002 |
|
192
197
|
|
193
198
|
## Roadmap
|
194
199
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.22.0
|
data/lib/rack/app.rb
CHANGED
@@ -91,13 +91,18 @@ class Rack::App
|
|
91
91
|
|
92
92
|
request_path = ::Rack::App::Utils.join(@namespaces, request_path)
|
93
93
|
|
94
|
-
properties =
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
94
|
+
properties = {
|
95
|
+
:user_defined_logic => block,
|
96
|
+
:request_method => request_method,
|
97
|
+
:request_path => request_path,
|
98
|
+
|
99
|
+
:default_headers => headers,
|
100
|
+
:error_handler => error,
|
101
|
+
:description => @last_description,
|
102
|
+
:serializer => serializer,
|
103
|
+
:app_class => self
|
104
|
+
}
|
105
|
+
|
101
106
|
|
102
107
|
endpoint = Rack::App::Endpoint.new(properties)
|
103
108
|
router.register_endpoint!(request_method, request_path, @last_description, endpoint)
|
@@ -107,10 +112,9 @@ class Rack::App
|
|
107
112
|
|
108
113
|
end
|
109
114
|
|
110
|
-
def serve_files_from(
|
111
|
-
|
112
|
-
|
113
|
-
request_path = Rack::App::Utils.join(@namespaces, options[:to], file_server.namespace, '**', '*')
|
115
|
+
def serve_files_from(file_path, options={})
|
116
|
+
file_server = Rack::App::File::Server.new(Rack::App::Utils.expand_path(file_path))
|
117
|
+
request_path = Rack::App::Utils.join(@namespaces, options[:to], '**', '*')
|
114
118
|
router.register_endpoint!('GET', request_path, @last_description, file_server)
|
115
119
|
@last_description = nil
|
116
120
|
end
|
@@ -152,18 +156,6 @@ class Rack::App
|
|
152
156
|
nil
|
153
157
|
end
|
154
158
|
|
155
|
-
protected
|
156
|
-
|
157
|
-
def endpoint_properties
|
158
|
-
{
|
159
|
-
:default_headers => headers,
|
160
|
-
:error_handler => error,
|
161
|
-
:description => @last_description,
|
162
|
-
:serializer => serializer,
|
163
|
-
:app_class => self
|
164
|
-
}
|
165
|
-
end
|
166
|
-
|
167
159
|
end
|
168
160
|
|
169
161
|
def params
|
data/lib/rack/app/file/server.rb
CHANGED
@@ -1,11 +1,8 @@
|
|
1
1
|
class Rack::App::File::Server
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
def initialize(root_folder, options={})
|
3
|
+
def initialize(root_folder)
|
6
4
|
require 'rack/file'
|
7
|
-
@
|
8
|
-
@root_folder = Rack::App::Utils.pwd(@raw_root_folder)
|
5
|
+
@root_folder = root_folder
|
9
6
|
@relative_file_paths = Dir.glob(File.join(@root_folder,'**','*')).map{|file_path| file_path.sub(@root_folder,'') }.sort_by{|str| str.length }.reverse
|
10
7
|
@rack_file_server = ::Rack::File.new(@root_folder, {})
|
11
8
|
end
|
data/lib/rack/app/utils.rb
CHANGED
@@ -18,15 +18,26 @@ module Rack::App::Utils
|
|
18
18
|
path
|
19
19
|
end
|
20
20
|
|
21
|
+
# Based on ActiveSupport, removed inflections.
|
22
|
+
# https://github.com/rails/rails/blob/v4.1.0.rc1/activesupport/lib/active_support/inflector/methods.rb
|
23
|
+
def underscore(camel_cased_word)
|
24
|
+
word = camel_cased_word.to_s.gsub('::', '/')
|
25
|
+
word.gsub!(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2')
|
26
|
+
word.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
|
27
|
+
word.tr!("-", "_")
|
28
|
+
word.downcase!
|
29
|
+
word
|
30
|
+
end
|
31
|
+
|
21
32
|
def pwd(*path_parts)
|
22
33
|
|
23
|
-
root_folder =if ENV['BUNDLE_GEMFILE']
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
34
|
+
root_folder = if ENV['BUNDLE_GEMFILE']
|
35
|
+
ENV['BUNDLE_GEMFILE'].split(File::Separator)[0..-2].join(File::Separator)
|
36
|
+
else
|
37
|
+
Dir.pwd.to_s
|
38
|
+
end
|
28
39
|
|
29
|
-
return File.join(root_folder
|
40
|
+
return File.join(root_folder, *path_parts)
|
30
41
|
|
31
42
|
end
|
32
43
|
|
@@ -39,7 +50,22 @@ module Rack::App::Utils
|
|
39
50
|
|
40
51
|
def join(*url_path_parts)
|
41
52
|
url_path_parts = [url_path_parts].flatten.compact
|
42
|
-
File.join(*url_path_parts).gsub(File::Separator,'/').sub(/^\/?(.*)$/,'/\1')
|
53
|
+
File.join(*url_path_parts).gsub(File::Separator, '/').sub(/^\/?(.*)$/, '/\1')
|
54
|
+
end
|
55
|
+
|
56
|
+
def expand_path(file_path)
|
57
|
+
case file_path
|
58
|
+
|
59
|
+
when /^\.\//
|
60
|
+
File.expand_path(File.join(File.dirname(caller[1]),file_path))
|
61
|
+
|
62
|
+
when /^[^\/]/
|
63
|
+
File.join(caller[1].split(/\.(?:rb|ru)/)[0],file_path)
|
64
|
+
|
65
|
+
when /^\//
|
66
|
+
pwd(file_path)
|
67
|
+
|
68
|
+
end
|
43
69
|
end
|
44
70
|
|
45
71
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-app
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.22.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Luzsi
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-02-
|
12
|
+
date: 2016-02-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|