rack-app 0.23.0 → 0.24.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: fa7ed787ed29cd062ef3cbc6f721693f4a1d70df
4
- data.tar.gz: e79de1870917b30fe6a4f940c16775deed6a49ae
3
+ metadata.gz: 4540204d722b8a8095a57d0f842022290db437fb
4
+ data.tar.gz: 8460edbebc8ed290637f170d38304c8f45a2d21b
5
5
  SHA512:
6
- metadata.gz: 030aa3836cb585f3a3c0d006efdae86646efe531fa48c97418f93dae495604fd8526cf7afdeb05a8adc6dd69b9349f5e1d25a31c4265f41968c3536cda00bf63
7
- data.tar.gz: 58fd6808e3716ae0de6d4c90edd2ac61edfa353013502499ef1027b775c5b806111f481e7d80fa37dfd23ded75ba32f8457555d74eee072ff985fc11bde9231d
6
+ metadata.gz: 81b30a658e13d1b0cb920554eb5154d12f836095dabe2a35d0eefbb306dc70f6bd767f3bfd3ba5c6e3a9e305422a5631e2d59e4e42a9465ccb9a4192a7050f3a
7
+ data.tar.gz: 2799da05163d51508ece54fc6b8c5adbcc0177af9654dccae9233fa10df48c6b24e6b9d6c28e4f47255ec006158d2262f512c184787f76e226d15a0b2a0685e4
data/README.md CHANGED
@@ -213,28 +213,33 @@ end
213
213
  * [Escher Authorized Api](https://github.com/rack-app/rack-app-example-escher)
214
214
  * complex authorization for corporal level api use
215
215
 
216
- ## [Benchmarking](https://github.com/adamluzsi/rack-app.rb-benchmark)
216
+ ## [Benchmarking](https://github.com/rack-app/rack-app-benchmark)
217
217
 
218
218
  the benchmarking was taken on the following hardware specification:
219
219
  * Processor: 2,7 GHz Intel Core i5
220
220
  * Memory: 16 GB 1867 MHz DDR3
221
221
  * Ruby: ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin15.0]
222
- * Endpoint declaration count: 1000
223
-
224
- | name | version | current / fastest | user | system | total | real |
225
- | ---------------------- | ---------------------- | ---------------------- | ---------------------- | ---------------------- | ---------------------- | ---------------------- |
226
- | rack | 1.6.4 | 1.0 | 4.4999999999994597e-10 | 4.999999999999855e-11 | 5.000000000001581e-10 | 4.669824999999623e-10 |
227
- | rack-app | 0.23.0 | 5.64 | 2.6249999999995462e-09 | 5.0000000000003155e-11 | 2.674999999999656e-09 | 2.6337825000000033e-09 |
228
- | ramaze | 2012.12.08 | 10.761 | 4.7250000000004294e-09 | 3.249999999997837e-10 | 5.0499999999999815e-09 | 5.025382500000196e-09 |
229
- | brooklyn | 0.0.1 | 135.196 | 6.202499999997365e-08 | 2.5000000000010383e-10 | 6.227499999994257e-08 | 6.31342025000291e-08 |
230
- | nancy | 0.3.0 | 141.491 | 6.44500000000412e-08 | 4.0000000000002173e-10 | 6.485000000002128e-08 | 6.607404000000881e-08 |
231
- | rails | 4.2.5.1 | 149.063 | 6.475000000004323e-08 | 2.54999999999825e-09 | 6.729999999999027e-08 | 6.960978250001378e-08 |
232
- | hobbit | 0.6.1 | 152.009 | 6.86499999999909e-08 | 5.50000000000627e-10 | 6.920000000002929e-08 | 7.09855800000375e-08 |
233
- | scorched | 0.25 | 206.02 | 9.227499999997586e-08 | 6.249999999997911e-10 | 9.289999999997338e-08 | 9.620763750005751e-08 |
234
- | sinatra | 1.4.7 | 252.893 | 1.1582499999996941e-07 | 9.000000000006287e-10 | 1.167249999999214e-07 | 1.1809659249996387e-07 |
235
- | grape | 0.14.0 | 999.893 | 4.5052499999980065e-07 | 4.900000000001301e-09 | 4.554249999998522e-07 | 4.66932680000025e-07 |
236
- | camping | 2.1.532 | 2246.199 | 1.0080499999997654e-06 | 1.4049999999999699e-08 | 1.0220999999995006e-06 | 1.0489356725004438e-06 |
237
- | cuba | 3.5.0 | 2951.837 | 1.3101249999997173e-06 | 1.302499999999637e-08 | 1.3231499999997228e-06 | 1.3784562299989904e-06 |
222
+
223
+ ### number of declared endpoints: 100
224
+
225
+ ### number of declared endpoints: 100
226
+
227
+ | name | version | current / fastest | real |
228
+ | ---------------------- | ---------------------- | ---------------------- | ---------------------- |
229
+ | rack | 1.6.4 | 1.0 | 1.6755999999997824e-06 |
230
+ | rack-app | 0.23.0 | 12.949 | 2.169760000000045e-05 |
231
+ | ramaze | 2012.12.08 | 24.828 | 4.1601999999999315e-05 |
232
+ | hobbit | 0.6.1 | 40.391 | 6.76790000000015e-05 |
233
+ | brooklyn | 0.0.1 | 72.983 | 0.00012229050000000643 |
234
+ | nancy | 0.3.0 | 91.488 | 0.00015329779999998726 |
235
+ | scorched | 0.25 | 179.476 | 0.00030072970000003256 |
236
+ | sinatra | 1.4.7 | 191.033 | 0.00032009470000000435 |
237
+ | rails | 4.2.5.1 | 453.927 | 0.0007605999000000241 |
238
+ | camping | 2.1.532 | 574.146 | 0.0009620388000000196 |
239
+ | grape | 0.14.0 | 582.409 | 0.000975884299999979 |
240
+ | cuba | 3.5.0 | 763.772 | 0.001279777100000003 |
241
+
242
+ For more reports check the Benchmark repo out :)
238
243
 
239
244
  ## Roadmap
240
245
 
@@ -252,3 +257,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
252
257
 
253
258
  Bug reports and pull requests are welcome on GitHub at https://github.com/adamluzsi/rack-app.rb This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
254
259
 
260
+ ## License and Copyright
261
+
262
+ Rack::App is free software released under the [Apache License V2](https://opensource.org/licenses/Apache-2.0) License.
263
+ The logo was designed by Zsófia Gebauer. It is Copyright © 2015 Adam Luzsi. All Rights Reserved.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.23.0
1
+ 0.24.0
@@ -20,6 +20,64 @@ class Rack::App
20
20
 
21
21
  class << self
22
22
 
23
+ def inherited(klass)
24
+
25
+ error.handlers.each do |ex_class, block|
26
+ klass.error(ex_class, &block)
27
+ end
28
+
29
+ klass.serializer(&serializer.logic)
30
+ middlewares.each { |builder_block| klass.middlewares(&builder_block) }
31
+ klass.headers.merge!(headers)
32
+
33
+ end
34
+
35
+ def serializer(&definition_how_to_serialize)
36
+ @serializer ||= Rack::App::Serializer.new
37
+
38
+ unless definition_how_to_serialize.nil?
39
+ @serializer.set_serialization_logic(definition_how_to_serialize)
40
+ end
41
+
42
+ return @serializer
43
+ end
44
+
45
+ def headers(new_headers=nil)
46
+ @headers ||= {}
47
+ @headers.merge!(new_headers) if new_headers.is_a?(Hash)
48
+ @headers
49
+ end
50
+
51
+ def middlewares(&block)
52
+ @middlewares ||= []
53
+ @middlewares << block unless block.nil?
54
+ @middlewares
55
+ end
56
+
57
+ alias middleware middlewares
58
+
59
+ def error(*exception_classes, &block)
60
+ @error_handler ||= Rack::App::ErrorHandler.new
61
+ unless block.nil?
62
+ @error_handler.register_handler(exception_classes, block)
63
+ end
64
+
65
+ return @error_handler
66
+ end
67
+
68
+ def namespace(request_path_namespace)
69
+ return unless block_given?
70
+ @namespaces ||= []
71
+ @namespaces.push(request_path_namespace)
72
+ yield
73
+ @namespaces.pop
74
+ nil
75
+ end
76
+
77
+ def router
78
+ @router ||= Rack::App::Router.new
79
+ end
80
+
23
81
  def call(request_env)
24
82
  Rack::App::RequestConfigurator.configure(request_env)
25
83
  endpoint = router.fetch_endpoint(
@@ -75,23 +133,15 @@ class Rack::App
75
133
  end
76
134
  end
77
135
 
78
- def error(*exception_classes, &block)
79
- @error_handler ||= Rack::App::ErrorHandler.new
80
- unless block.nil?
81
- @error_handler.register_handler(exception_classes, block)
82
- end
83
-
84
- return @error_handler
85
- end
86
-
87
- def router
88
- @router ||= Rack::App::Router.new
89
- end
90
-
91
136
  def add_route(request_method, request_path, &block)
92
137
 
93
138
  request_path = ::Rack::App::Utils.join(@namespaces, request_path)
94
139
 
140
+ builder = Rack::Builder.new
141
+ middlewares.each do |builder_block|
142
+ builder_block.call(builder)
143
+ end
144
+
95
145
  properties = {
96
146
  :user_defined_logic => block,
97
147
  :request_method => request_method,
@@ -101,7 +151,7 @@ class Rack::App
101
151
  :error_handler => error,
102
152
  :description => @last_description,
103
153
  :serializer => serializer,
104
- :middleware => middleware,
154
+ :middleware => builder,
105
155
  :app_class => self
106
156
  }
107
157
 
@@ -133,37 +183,6 @@ class Rack::App
133
183
  return nil
134
184
  end
135
185
 
136
- def serializer(&definition_how_to_serialize)
137
- @serializer ||= Rack::App::Serializer.new
138
-
139
- unless definition_how_to_serialize.nil?
140
- @serializer.set_serialization_logic(definition_how_to_serialize)
141
- end
142
-
143
- return @serializer
144
- end
145
-
146
- def headers(new_headers=nil)
147
- @headers ||= {}
148
- @headers.merge!(new_headers) if new_headers.is_a?(Hash)
149
- @headers
150
- end
151
-
152
- def namespace(request_path_namespace)
153
- return unless block_given?
154
- @namespaces ||= []
155
- @namespaces.push(request_path_namespace)
156
- yield
157
- @namespaces.pop
158
- nil
159
- end
160
-
161
- def middleware(&block)
162
- @builder ||= Rack::Builder.new
163
- block.call(@builder) unless block.nil?
164
- @builder
165
- end
166
-
167
186
  end
168
187
 
169
188
  def params
@@ -1,5 +1,7 @@
1
1
  class Rack::App::ErrorHandler
2
2
 
3
+ attr_reader :handlers
4
+
3
5
  def initialize
4
6
  @handlers = {}
5
7
  end
@@ -1,15 +1,17 @@
1
1
  class Rack::App::Serializer
2
2
 
3
+ attr_reader :logic
4
+
3
5
  def initialize
4
- @proc = lambda { |o| o.to_s }
6
+ @logic = lambda { |o| o.to_s }
5
7
  end
6
8
 
7
9
  def set_serialization_logic(proc)
8
- @proc = proc
10
+ @logic = proc
9
11
  end
10
12
 
11
13
  def serialize(object)
12
- @proc.call(object)
14
+ @logic.call(object)
13
15
  end
14
16
 
15
17
  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.23.0
4
+ version: 0.24.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-23 00:00:00.000000000 Z
12
+ date: 2016-02-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler