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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 805e9eb8a82e58d39a73357208675377e91da78b
4
- data.tar.gz: 986add7fe01156db17d32306bcf2fd83f38283bc
3
+ metadata.gz: 65b1db9343140ad9785f449d4d2ebbfd0f3c860f
4
+ data.tar.gz: f58629f4e5ebd8258c56a0fa76b298820ccfa47f
5
5
  SHA512:
6
- metadata.gz: 8ae71fe9c27cd1c3ab821a5a9f9cf344e90926d5bd59bcb6884f3d2ff3e62b5f3d391fd13505d1903e0a098ec9c5a789db796e5eb8c5731aea66b620fc788300
7
- data.tar.gz: dd9febe79c1e1e7147be13d5251ee78f6c86f94208b0d73756b66bc9d9e1241772d9cbc212be0580524386fb07ec39a95186d93b6dc4cae9a2b3e60ef6cf183f
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
- ## [Contributors](CONTRIBUTORS.md)
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.9.0
1
+ 5.10.0
@@ -0,0 +1 @@
1
+ theme: jekyll-theme-minimal
@@ -21,6 +21,7 @@ class Rack::App
21
21
  require 'rack/app/middlewares'
22
22
  require 'rack/app/file_server'
23
23
  require 'rack/app/error_handler'
24
+ require 'rack/app/request_stream'
24
25
  require 'rack/app/bundled_extensions'
25
26
  require 'rack/app/request_configurator'
26
27
 
@@ -1,13 +1,13 @@
1
1
  module Rack::App::Payload::Parser::Builder::Formats
2
2
  extend(self)
3
3
 
4
- JSON_CONTENT_TYPE = [
5
- "application/json",
6
- "application/x-javascript",
7
- "text/javascript",
8
- "text/x-javascript",
9
- "text/x-json",
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 "json"
25
- JSON_CONTENT_TYPE.each do |content_type|
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
- lambda do |form|
57
- ::Rack::Utils.default_query_parser.parse_nested_query(form, FORM_SEP_CHAR)
58
- end
59
- else
60
- lambda do |form|
61
- ::Rack::Utils.parse_nested_query(form, FORM_SEP_CHAR)
62
- end
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
@@ -0,0 +1,11 @@
1
+ fib = Enumerator.new do |y|
2
+ a = b = 1
3
+ 10.times do
4
+ y << a
5
+ a, b = b, a + b
6
+ end
7
+ end
8
+
9
+ fib.each do |e|
10
+ p e
11
+ 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: 5.9.0
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-17 00:00:00.000000000 Z
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
@@ -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