rack-app 7.6.5 → 8.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +4 -10
- data/README.md +10 -75
- data/VERSION +1 -1
- data/lib/rack/app/cli/fetcher/server.rb +2 -1
- data/lib/rack/app/file_server.rb +39 -13
- data/lib/rack/app/instance_methods/payload.rb +1 -1
- data/lib/rack/app/request_stream.rb +1 -1
- data/lib/rack/app/singleton_methods/mounting.rb +2 -2
- data/lib/rack/app/test/utils.rb +1 -1
- data/rack-app.gemspec +3 -4
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6e6d84d14ed02cbbb286899bf197d4c363191ecc25503468e1dca3230eef711
|
4
|
+
data.tar.gz: a4a933650eb1050978a8bc9203164f5d9fc7989a9c418d5e259a88a239e95184
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21f5551525d331ccde1ca6231ec0fb9029cf2b5cd3b7b9988af4a678ead66f5aeef9f62d2aaca8aac5979e79cf880d38d13a9b563c8acd7cb2b3f1ce8984dd91
|
7
|
+
data.tar.gz: a3c755643ab469528c2fb936b5c0a91a9d1cc0bb1969b1d398f50f8c700e0fdeb4c7b7131e0548d357c29292af759149ff6f7a28ef7b55d3089ba7a7bfd773b3
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.0.0
|
data/.travis.yml
CHANGED
@@ -8,12 +8,10 @@ install:
|
|
8
8
|
rvm:
|
9
9
|
- ruby-head
|
10
10
|
- jruby-head
|
11
|
-
-
|
12
|
-
-
|
13
|
-
- 2.
|
14
|
-
-
|
15
|
-
- 2.5.5
|
16
|
-
- 2.6.3
|
11
|
+
- 2.5
|
12
|
+
- 2.6
|
13
|
+
- 2.7
|
14
|
+
- 3.0
|
17
15
|
|
18
16
|
matrix:
|
19
17
|
allow_failures:
|
@@ -27,10 +25,6 @@ env:
|
|
27
25
|
- BENCHMARK_QUANTITY=100000
|
28
26
|
- STREAM_FILE_SIZE=68
|
29
27
|
|
30
|
-
branches:
|
31
|
-
only:
|
32
|
-
- master
|
33
|
-
|
34
28
|
notifications:
|
35
29
|
email:
|
36
30
|
- adamluzsi@gmail.com
|
data/README.md
CHANGED
@@ -6,24 +6,22 @@
|
|
6
6
|
|
7
7
|
![rack-app-logo](/assets/rack-app-logo.png)
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
`rack-app` is a minimalist web framework that focuses on simplicity and maintainability.
|
10
|
+
The framework is meant to be used by seasoned web developers.
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
while able to write pure rack apps,
|
12
|
+
`rack-app` focus on keeping the dependencies as little as possible,
|
13
|
+
while allowing writing functional and minimalist rack-based applications,
|
15
14
|
that will do nothing more than what you defined.
|
16
15
|
|
17
|
-
The
|
18
|
-
|
19
|
-
you still don't have to worry about response speed.
|
16
|
+
The routing uses a prefix tree,
|
17
|
+
thus adding a large number of API endpoints won't affect the routing lookup time.
|
20
18
|
|
21
|
-
It was inspirited by
|
22
|
-
It's in production, powering
|
19
|
+
It was inspirited by `Sinatra`, `grape`, and `rack`.
|
20
|
+
It's used in production, powering back-end APIs running on the public cloud.
|
23
21
|
|
24
22
|
## Development Status
|
25
23
|
|
26
|
-
The framework considered stable.
|
24
|
+
The framework is considered stable.
|
27
25
|
I don't have the plan to feature creep the framework without real-life use-cases,
|
28
26
|
since most of the custom edge cases can be resolved with composition.
|
29
27
|
|
@@ -34,24 +32,10 @@ If you have an issue, I weekly check the issues tab,
|
|
34
32
|
answer and reply, or implement a fix for it.
|
35
33
|
|
36
34
|
Since the framework's only dependency is the `rack` gem,
|
37
|
-
I don't have to update the
|
35
|
+
I don't have to update the codebase too often.
|
38
36
|
|
39
37
|
Cheers and Happy Coding!
|
40
38
|
|
41
|
-
## Concerns
|
42
|
-
|
43
|
-
If you want to see fancy magic, you are in a bad place buddy!
|
44
|
-
|
45
|
-
This also implies that the framework does not include extensions that monkey patch the whole world to give you nice features.
|
46
|
-
Clean architecture defines that a web framework should only provide an external interface to the web, and nothing more.
|
47
|
-
|
48
|
-
If you use rack-app, one thing is sure.
|
49
|
-
|
50
|
-
You either love it or will be able to remove it from the project even after years of development because,
|
51
|
-
it will not vendor-lock your application business entities and business use cases to this framework.
|
52
|
-
|
53
|
-
And it's totally fine for us. We don't want everyone to be tied to our solutions, we only want to build clean and well-designed software for the developer happiness.
|
54
|
-
|
55
39
|
## Installation
|
56
40
|
|
57
41
|
Add this line to your application's Gemfile:
|
@@ -324,55 +308,6 @@ end
|
|
324
308
|
* [Escher Authorized Api](https://github.com/rack-app/rack-app-example-escher)
|
325
309
|
* complex authorization for corporal level API use
|
326
310
|
|
327
|
-
## [Benchmarking](https://github.com/rack-app/rack-app-benchmark)
|
328
|
-
|
329
|
-
This is a repo that used for measure Rack::App project speed in order to keep an eye on the performance in every release.
|
330
|
-
|
331
|
-
the benchmarking was taken on the following hardware specification:
|
332
|
-
* Processor: 2,7 GHz Intel Core i5
|
333
|
-
* Memory: 16 GB 1867 MHz DDR3
|
334
|
-
* Ruby: ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15]
|
335
|
-
|
336
|
-
|
337
|
-
### Endpoint to be call type: static
|
338
|
-
|
339
|
-
#### number of declared endpoints: 100
|
340
|
-
|
341
|
-
| name | version | current / fastest | real |
|
342
|
-
| ---------------------- | ---------------------- | ---------------------- | ---------------------- |
|
343
|
-
| rack-app | 4.0.0 | 1.0 | 2.2053215187043942e-05 |
|
344
|
-
| rack-app | 5.2.0 | 1.185 | 2.6140331494390213e-05 |
|
345
|
-
| rack-app | 5.0.0.rc3 | 1.387 | 3.0592694940592784e-05 |
|
346
|
-
| rack-app | 5.10.0 | 1.687 | 3.719768107671963e-05 |
|
347
|
-
| rack-app | 5.12.0 | 1.747 | 3.852106360719058e-05 |
|
348
|
-
| rack-app | 5.7.0 | 1.784 | 3.934149001724991e-05 |
|
349
|
-
| ramaze | 2012.12.08 | 2.237 | 4.932373271523216e-05 |
|
350
|
-
| hobbit | 0.6.1 | 3.111 | 6.860981349018188e-05 |
|
351
|
-
| brooklyn | 0.0.1 | 5.245 | 0.00011567194234917104 |
|
352
|
-
| plezi | 0.14.1 | 5.334 | 0.00011763589749898317 |
|
353
|
-
| plezi | 0.14.2 | 5.588 | 0.00012324020796222724 |
|
354
|
-
| nancy | 0.3.0 | 5.725 | 0.00012626088352407584 |
|
355
|
-
| nyny | 3.4.3 | 5.744 | 0.00012667404900032145 |
|
356
|
-
| roda | 2.20.0 | 9.662 | 0.00021307581296423227 |
|
357
|
-
| roda | 2.17.0 | 10.646 | 0.00023477471132838754 |
|
358
|
-
| scorched | 0.25 | 12.728 | 0.0002807019599946191 |
|
359
|
-
| scorched | 0.27 | 16.074 | 0.0003544879730325173 |
|
360
|
-
| sinatra | 1.4.7 | 19.857 | 0.00043791615583657487 |
|
361
|
-
| grape | 0.17.0 | 25.941 | 0.0005720832234016178 |
|
362
|
-
| rails | 5.0.0 | 33.234 | 0.0007329187002032537 |
|
363
|
-
| camping | 2.1.532 | 39.818 | 0.0008781073650072727 |
|
364
|
-
| grape | 0.18.0 | 41.857 | 0.000923075147962645 |
|
365
|
-
| rails | 5.0.0.1 | 47.286 | 0.0010428086559986802 |
|
366
|
-
| cuba | 3.8.0 | 55.397 | 0.0012216723478342246 |
|
367
|
-
| almost-sinatra | unknown | 58.728 | 0.0012951477793394547 |
|
368
|
-
|
369
|
-
For more reports check the Benchmark repo out :)
|
370
|
-
|
371
|
-
## Roadmap
|
372
|
-
|
373
|
-
### Team [Backlog](https://docs.google.com/spreadsheets/d/19GGX51i6uCQQz8pQ-lvsIxu43huKCX-eC1526-RL3YA/edit?usp=sharing)
|
374
|
-
|
375
|
-
If you have anything to say, you can leave a comment. :)
|
376
311
|
|
377
312
|
## Development
|
378
313
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
8.0.0
|
data/lib/rack/app/file_server.rb
CHANGED
@@ -1,10 +1,24 @@
|
|
1
1
|
class Rack::App::FileServer
|
2
|
+
attr_accessor :relative_file_paths
|
2
3
|
|
3
|
-
def
|
4
|
-
|
4
|
+
def self.serve_file(env, file_path)
|
5
|
+
dir_path = File.dirname(file_path)
|
6
|
+
basename = File.basename(file_path)
|
7
|
+
file_server = new(dir_path, map_relative_file_paths: false)
|
8
|
+
env = env.dup
|
9
|
+
env[::Rack::App::Constants::ENV::REQUEST_METHOD] = 'GET'
|
10
|
+
env[::Rack::App::Constants::ENV::PATH_INFO] = basename
|
11
|
+
file_server.call(env)
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(root_folder, opts = {})
|
5
15
|
@root_folder = root_folder
|
6
|
-
@relative_file_paths =
|
7
|
-
@rack_file_server = ::Rack::
|
16
|
+
@relative_file_paths = []
|
17
|
+
@rack_file_server = ::Rack::Files.new(@root_folder, {})
|
18
|
+
|
19
|
+
if map_relative_file_paths?(opts)
|
20
|
+
map_relative_paths!
|
21
|
+
end
|
8
22
|
end
|
9
23
|
|
10
24
|
def call(env)
|
@@ -12,7 +26,7 @@ class Rack::App::FileServer
|
|
12
26
|
|
13
27
|
@relative_file_paths.each do |relative_file_path|
|
14
28
|
if path_info =~ /#{Regexp.escape(relative_file_path)}$/
|
15
|
-
env[::Rack::App::Constants::ENV::PATH_INFO]= relative_file_path
|
29
|
+
env[::Rack::App::Constants::ENV::PATH_INFO] = relative_file_path
|
16
30
|
break
|
17
31
|
end
|
18
32
|
end
|
@@ -20,19 +34,31 @@ class Rack::App::FileServer
|
|
20
34
|
@rack_file_server.call(env)
|
21
35
|
end
|
22
36
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
37
|
+
protected
|
38
|
+
|
39
|
+
def map_relative_file_paths?(opts = {})
|
40
|
+
unless opts.key?(:map_relative_file_paths)
|
41
|
+
return true
|
42
|
+
end
|
43
|
+
|
44
|
+
opts[:map_relative_file_paths]
|
29
45
|
end
|
30
46
|
|
31
|
-
|
47
|
+
def opts_set_defaults(opts)
|
48
|
+
unless opts.key?(:map_relative_file_paths)
|
49
|
+
opts[:map_relative_file_paths] = true
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def map_relative_paths!
|
54
|
+
@relative_file_paths = Dir.glob(File.join(@root_folder, '**', '*'))
|
55
|
+
.map { |file_path| file_path.sub(@root_folder, '') }
|
56
|
+
.sort_by { |str| str.length }
|
57
|
+
.reverse
|
58
|
+
end
|
32
59
|
|
33
60
|
def clean_path_info(env)
|
34
61
|
path_info = ::Rack::Utils.unescape(env[::Rack::App::Constants::ENV::PATH_INFO])
|
35
62
|
::Rack::Utils.clean_path_info(path_info)
|
36
63
|
end
|
37
|
-
|
38
64
|
end
|
@@ -46,8 +46,8 @@ module Rack::App::SingletonMethods::Mounting
|
|
46
46
|
nil
|
47
47
|
end
|
48
48
|
|
49
|
-
def serve_files_from(
|
50
|
-
file_server = Rack::App::FileServer.new(Rack::App::Utils.expand_path(
|
49
|
+
def serve_files_from(dir_path, options={})
|
50
|
+
file_server = Rack::App::FileServer.new(Rack::App::Utils.expand_path(dir_path))
|
51
51
|
request_path = Rack::App::Utils.join(options[:to], Rack::App::Constants::PATH::MOUNT_POINT)
|
52
52
|
add_route(::Rack::App::Constants::HTTP::METHOD::ANY, request_path, file_server)
|
53
53
|
nil
|
data/lib/rack/app/test/utils.rb
CHANGED
@@ -15,7 +15,7 @@ module Rack::App::Test::Utils
|
|
15
15
|
properties = format_properties(properties)
|
16
16
|
env = properties[:headers].reduce({}) { |m, (k, v)| m.merge("HTTP_#{k.to_s.tr('-', '_').upcase}" => v.to_s) }
|
17
17
|
payload = properties.delete(:payload)
|
18
|
-
env["rack.input"]= ::Rack::Lint::InputWrapper.new(string_io_for(payload))
|
18
|
+
env["rack.input"]= ::Rack::Lint::Wrapper::InputWrapper.new(string_io_for(payload))
|
19
19
|
env[::Rack::QUERY_STRING]= query_string_by(uri, properties[:params])
|
20
20
|
env.merge!(properties[:env] || {})
|
21
21
|
|
data/rack-app.gemspec
CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
|
|
9
9
|
summary = 'Minimalist rack application interface building framework.'
|
10
10
|
spec.summary = summary
|
11
11
|
spec.description = summary
|
12
|
-
|
13
12
|
spec.homepage = 'http://www.rack-app.com/'
|
13
|
+
spec.license = 'Apache License 2.0'
|
14
14
|
|
15
15
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
16
|
spec.require_paths = ['lib']
|
@@ -18,10 +18,9 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.bindir = 'bin'
|
19
19
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
20
20
|
|
21
|
-
spec.license = 'Apache License 2.0'
|
22
|
-
|
23
21
|
spec.add_development_dependency 'bundler'
|
24
22
|
spec.add_development_dependency 'rspec'
|
25
|
-
spec.add_dependency 'rack'
|
23
|
+
spec.add_dependency 'rack', '<= 3.0.0'
|
24
|
+
spec.add_dependency 'rackup'
|
26
25
|
|
27
26
|
end
|
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:
|
4
|
+
version: 8.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Luzsi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -40,6 +40,20 @@ dependencies:
|
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rack
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "<="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.0.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "<="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.0.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rackup
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
59
|
- - ">="
|
@@ -212,7 +226,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
212
226
|
- !ruby/object:Gem::Version
|
213
227
|
version: '0'
|
214
228
|
requirements: []
|
215
|
-
rubygems_version: 3.
|
229
|
+
rubygems_version: 3.2.3
|
216
230
|
signing_key:
|
217
231
|
specification_version: 4
|
218
232
|
summary: Minimalist rack application interface building framework.
|