rack-app 5.9.0 → 5.10.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 +17 -1
- data/VERSION +1 -1
- data/_config.yml +1 -0
- data/lib/rack/app.rb +1 -0
- data/lib/rack/app/payload/parser/builder/formats.rb +32 -17
- data/lib/rack/app/request_stream.rb +20 -0
- data/spike/enum.rb +11 -0
- metadata +5 -3
- data/CONTRIBUTORS.md +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65b1db9343140ad9785f449d4d2ebbfd0f3c860f
|
4
|
+
data.tar.gz: f58629f4e5ebd8258c56a0fa76b298820ccfa47f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7c7e69709ef90f0eb699e22afcc80f8669760458ecb7853bdee93881050f9ec2363a26c94328739054b818bb4e913419b968bd16e8349052c393ffe9822bb2e
|
7
|
+
data.tar.gz: 105c6deb752cc928ef70f3d3ee8fd665f68b21b6c5ec1f568f490a46fdf9b26e5ef031a838d1e405d5185ffdc2463e57e505406134cd2ba13a5dbb42ff5095b3
|
data/README.md
CHANGED
@@ -82,7 +82,23 @@ Yes, in fact it's already powering heroku hosted micro-services.
|
|
82
82
|
* note that this is not only memory friendly way pure rack solution, but also 2x faster than the usually solution which includes buffering in memory
|
83
83
|
* params validation with ease
|
84
84
|
|
85
|
-
##
|
85
|
+
## Contributors
|
86
|
+
|
87
|
+
* **[Daniel Nagy](https://github.com/thilonel)**
|
88
|
+
|
89
|
+
* Serializer MVP implementation
|
90
|
+
|
91
|
+
* **[Daniel Szpisjak](https://github.com/felin-arch)**
|
92
|
+
|
93
|
+
* Pimp up the website descriptions
|
94
|
+
|
95
|
+
* **[Jeremy Evans](https://github.com/jeremyevans)**
|
96
|
+
|
97
|
+
* suggestion for application stand up speed optimization
|
98
|
+
|
99
|
+
* **[David Bush](https://github.com/disavowd)**
|
100
|
+
|
101
|
+
* [wrote an article](https://www.sitepoint.com/rack-app-a-performant-and-pragmatic-web-microframework/) about the project
|
86
102
|
|
87
103
|
## [Contributing](CONTRIBUTING.md)
|
88
104
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
5.
|
1
|
+
5.10.0
|
data/_config.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
theme: jekyll-theme-minimal
|
data/lib/rack/app.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
module Rack::App::Payload::Parser::Builder::Formats
|
2
2
|
extend(self)
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
]
|
4
|
+
JSON_CONTENT_TYPES = [
|
5
|
+
'application/json',
|
6
|
+
'application/x-javascript',
|
7
|
+
'text/javascript',
|
8
|
+
'text/x-javascript',
|
9
|
+
'text/x-json'
|
10
|
+
].freeze
|
11
11
|
|
12
12
|
JSON_PARSER = proc do |io|
|
13
13
|
begin
|
@@ -21,12 +21,28 @@ module Rack::App::Payload::Parser::Builder::Formats
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def json(builder)
|
24
|
-
require
|
25
|
-
|
24
|
+
require 'json'
|
25
|
+
JSON_CONTENT_TYPES.each do |content_type|
|
26
26
|
builder.on(content_type, &JSON_PARSER)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
+
JSON_STREAM_CONTENT_TYPES = [
|
31
|
+
'application/jsonstream',
|
32
|
+
'application/stream+json',
|
33
|
+
'application/x-json-stream'
|
34
|
+
].freeze
|
35
|
+
|
36
|
+
JSON_STREAM_PARSER = proc do |io|
|
37
|
+
Rack::App::RequestStream.new(io, JSON_PARSER)
|
38
|
+
end
|
39
|
+
|
40
|
+
def json_stream(builder)
|
41
|
+
JSON_STREAM_CONTENT_TYPES.each do |content_type|
|
42
|
+
builder.on(content_type, &JSON_STREAM_PARSER)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
30
46
|
# CSV_CONTENT_TYPE = [
|
31
47
|
# "text/comma-separated-values",
|
32
48
|
# "application/csv",
|
@@ -53,13 +69,13 @@ module Rack::App::Payload::Parser::Builder::Formats
|
|
53
69
|
FORM_SEP_CHAR = '&'.freeze
|
54
70
|
|
55
71
|
RACK_QUERY_PARSER = if Rack::Utils.respond_to?(:default_query_parser)
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
72
|
+
lambda do |form|
|
73
|
+
::Rack::Utils.default_query_parser.parse_nested_query(form, FORM_SEP_CHAR)
|
74
|
+
end
|
75
|
+
else
|
76
|
+
lambda do |form|
|
77
|
+
::Rack::Utils.parse_nested_query(form, FORM_SEP_CHAR)
|
78
|
+
end
|
63
79
|
end
|
64
80
|
|
65
81
|
NULL_END_CHAR = /#{"\u0000"}$/
|
@@ -89,5 +105,4 @@ module Rack::App::Payload::Parser::Builder::Formats
|
|
89
105
|
rescue NoMethodError
|
90
106
|
raise(NotImplementedError, "unknown formatter: #{last_name}")
|
91
107
|
end
|
92
|
-
|
93
108
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "enumerator"
|
2
|
+
class Rack::App::RequestStream
|
3
|
+
include Enumerable
|
4
|
+
|
5
|
+
def initialize(io, parser)
|
6
|
+
@io = io
|
7
|
+
@parser = parser
|
8
|
+
end
|
9
|
+
|
10
|
+
def each(&block)
|
11
|
+
enum = Enumerator.new do |y|
|
12
|
+
@io.rewind
|
13
|
+
while chunk = @io.gets
|
14
|
+
y << @parser.call(chunk)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
block_given? ? enum.each(&block) : enum
|
19
|
+
end
|
20
|
+
end
|
data/spike/enum.rb
ADDED
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: 5.
|
4
|
+
version: 5.10.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: 2016-12-
|
11
|
+
date: 2016-12-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -82,13 +82,13 @@ files:
|
|
82
82
|
- ".travis.yml"
|
83
83
|
- CODE_OF_CONDUCT.md
|
84
84
|
- CONTRIBUTING.md
|
85
|
-
- CONTRIBUTORS.md
|
86
85
|
- Gemfile
|
87
86
|
- LICENSE
|
88
87
|
- README.md
|
89
88
|
- Rakefile
|
90
89
|
- VERSION
|
91
90
|
- Vagrantfile
|
91
|
+
- _config.yml
|
92
92
|
- bin/rack-app
|
93
93
|
- dev/console
|
94
94
|
- dev/rack-app
|
@@ -146,6 +146,7 @@ files:
|
|
146
146
|
- lib/rack/app/payload/parser/builder.rb
|
147
147
|
- lib/rack/app/payload/parser/builder/formats.rb
|
148
148
|
- lib/rack/app/request_configurator.rb
|
149
|
+
- lib/rack/app/request_stream.rb
|
149
150
|
- lib/rack/app/router.rb
|
150
151
|
- lib/rack/app/router/base.rb
|
151
152
|
- lib/rack/app/router/dynamic.rb
|
@@ -190,6 +191,7 @@ files:
|
|
190
191
|
- rack-app.gemspec
|
191
192
|
- spec_files.txt
|
192
193
|
- spike/array_vs_proc.rb
|
194
|
+
- spike/enum.rb
|
193
195
|
- spike/long_endpoint.rb
|
194
196
|
- spike/method_vs_hash.rb
|
195
197
|
- spike/method_vs_instance_exec.rb
|
data/CONTRIBUTORS.md
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
Contributors
|
2
|
-
============================================
|
3
|
-
|
4
|
-
* **[Daniel Nagy](https://github.com/thilonel)**
|
5
|
-
|
6
|
-
* Serializer MVP implementation
|
7
|
-
|
8
|
-
* **[Daniel Szpisjak](https://github.com/felin-arch)**
|
9
|
-
|
10
|
-
* Pimp up the website descriptions
|
11
|
-
|
12
|
-
* **[Jeremy Evans](https://github.com/jeremyevans)**
|
13
|
-
|
14
|
-
* suggestion for application stand up speed optimization
|