em-midori 0.1.7 → 0.1.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/em-midori +1 -1
- data/lib/midori/api.rb +254 -7
- data/lib/midori/api_engine.rb +22 -4
- data/lib/midori/clean_room.rb +1 -1
- data/lib/midori/configure.rb +1 -0
- data/lib/midori/core_ext/string.rb +1 -1
- data/lib/midori/extension/postgres.rb +1 -1
- data/lib/midori/request.rb +1 -2
- data/lib/midori/response.rb +1 -1
- data/lib/midori/runner.rb +1 -1
- data/lib/midori/version.rb +1 -1
- data/lib/midori/websocket.rb +4 -4
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1141fbd9e570a32ea33eb07ad6687a8b60bf36e
|
4
|
+
data.tar.gz: a8c597845b57be046d0ec3e438e5d83694c5df84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7dca5dee8b994779f9b684155bb20ac948d068e38b35e2f361a6ca01457b85ac5b1227c2e35ebf862b317343ced90cb567ec82d794e27f71a1c7bcf24c81162c
|
7
|
+
data.tar.gz: 609351a34a8741f942afa9deda5ebf097b5cfdffd17fb153999073e43d9b6bd902ca601237032714ef6a4f4ade9fdd16a4befdebdb9615a34718131a0ec9b8e0
|
data/lib/em-midori
CHANGED
@@ -1 +1 @@
|
|
1
|
-
midori
|
1
|
+
lib/midori
|
data/lib/midori/api.rb
CHANGED
@@ -12,13 +12,31 @@ class Midori::API
|
|
12
12
|
# @return [ nil ] nil
|
13
13
|
def class_initialize
|
14
14
|
@routes = {
|
15
|
+
DELETE: [],
|
15
16
|
GET: [],
|
17
|
+
HEAD: [],
|
16
18
|
POST: [],
|
17
19
|
PUT: [],
|
18
|
-
|
20
|
+
CONNECT: [],
|
19
21
|
OPTIONS: [],
|
20
|
-
|
21
|
-
|
22
|
+
TRACE: [],
|
23
|
+
COPY: [],
|
24
|
+
LOCK: [],
|
25
|
+
MKCOL: [],
|
26
|
+
MOVE: [],
|
27
|
+
PROPFIND: [],
|
28
|
+
PROPPATCH: [],
|
29
|
+
UNLOCK: [],
|
30
|
+
REPORT: [],
|
31
|
+
MKACTIVITY: [],
|
32
|
+
CHECKOUT: [],
|
33
|
+
MERGE: [],
|
34
|
+
:'M-SEARCH' => [],
|
35
|
+
NOTIFY: [],
|
36
|
+
SUBSCRIBE: [],
|
37
|
+
UNSUBSCRIBE: [],
|
38
|
+
PATCH: [],
|
39
|
+
PURGE: [],
|
22
40
|
WEBSOCKET: [],
|
23
41
|
EVENTSOURCE: [],
|
24
42
|
MOUNT: []
|
@@ -28,6 +46,16 @@ class Midori::API
|
|
28
46
|
nil
|
29
47
|
end
|
30
48
|
|
49
|
+
# Add DELETE method as a DSL for route definition
|
50
|
+
# @param [ String ] path Accepts as part of path in route definition
|
51
|
+
# @yield what to run when route matched
|
52
|
+
# @return [ nil ] nil
|
53
|
+
# @example String as router
|
54
|
+
# delete '/' do
|
55
|
+
# puts 'Hello World'
|
56
|
+
# end
|
57
|
+
def delete(path, &block) end
|
58
|
+
|
31
59
|
# Add GET method as a DSL for route definition
|
32
60
|
# @param [ String ] path Accepts as part of path in route definition
|
33
61
|
# @yield what to run when route matched
|
@@ -38,6 +66,16 @@ class Midori::API
|
|
38
66
|
# end
|
39
67
|
def get(path, &block) end
|
40
68
|
|
69
|
+
# Add HEAD method as a DSL for route definition
|
70
|
+
# @param [ String ] path Accepts as part of path in route definition
|
71
|
+
# @yield what to run when route matched
|
72
|
+
# @return [ nil ] nil
|
73
|
+
# @example String as router
|
74
|
+
# head '/' do
|
75
|
+
# puts 'Hello World'
|
76
|
+
# end
|
77
|
+
def head(path, &block) end
|
78
|
+
|
41
79
|
# Add POST method as a DSL for route definition
|
42
80
|
# @param [ String ] path Accepts as part of path in route definition
|
43
81
|
# @yield what to run when route matched
|
@@ -58,15 +96,15 @@ class Midori::API
|
|
58
96
|
# end
|
59
97
|
def put(path, &block) end
|
60
98
|
|
61
|
-
# Add
|
99
|
+
# Add CONNECT method as a DSL for route definition
|
62
100
|
# @param [ String ] path Accepts as part of path in route definition
|
63
101
|
# @yield what to run when route matched
|
64
102
|
# @return [ nil ] nil
|
65
103
|
# @example String as router
|
66
|
-
#
|
104
|
+
# connect '/' do
|
67
105
|
# puts 'Hello World'
|
68
106
|
# end
|
69
|
-
def
|
107
|
+
def connect(path, &block) end
|
70
108
|
|
71
109
|
# Add OPTIONS method as a DSL for route definition
|
72
110
|
# @param [ String ] path Accepts as part of path in route definition
|
@@ -77,6 +115,189 @@ class Midori::API
|
|
77
115
|
# end
|
78
116
|
def options(path, &block) end
|
79
117
|
|
118
|
+
# Add TRACE method as a DSL for route definition
|
119
|
+
# @param [ String ] path Accepts as part of path in route definition
|
120
|
+
# @yield what to run when route matched
|
121
|
+
# @return [ nil ] nil
|
122
|
+
# @example String as router
|
123
|
+
# trace '/' do
|
124
|
+
# puts 'Hello World'
|
125
|
+
# end
|
126
|
+
def trace(path, &block) end
|
127
|
+
|
128
|
+
# Add COPY method as a DSL for route definition
|
129
|
+
# @param [ String ] path Accepts as part of path in route definition
|
130
|
+
# @yield what to run when route matched
|
131
|
+
# @return [ nil ] nil
|
132
|
+
# @example String as router
|
133
|
+
# copy '/' do
|
134
|
+
# puts 'Hello World'
|
135
|
+
# end
|
136
|
+
def copy(path, &block) end
|
137
|
+
|
138
|
+
# Add LOCK method as a DSL for route definition
|
139
|
+
# @param [ String ] path Accepts as part of path in route definition
|
140
|
+
# @yield what to run when route matched
|
141
|
+
# @return [ nil ] nil
|
142
|
+
# @example String as router
|
143
|
+
# lock '/' do
|
144
|
+
# puts 'Hello World'
|
145
|
+
# end
|
146
|
+
def lock(path, &block) end
|
147
|
+
|
148
|
+
# Add MKCOK method as a DSL for route definition
|
149
|
+
# @param [ String ] path Accepts as part of path in route definition
|
150
|
+
# @yield what to run when route matched
|
151
|
+
# @return [ nil ] nil
|
152
|
+
# @example String as router
|
153
|
+
# mkcol '/' do
|
154
|
+
# puts 'Hello World'
|
155
|
+
# end
|
156
|
+
def mkcol(path, &block) end
|
157
|
+
|
158
|
+
# Add MOVE method as a DSL for route definition
|
159
|
+
# @param [ String ] path Accepts as part of path in route definition
|
160
|
+
# @yield what to run when route matched
|
161
|
+
# @return [ nil ] nil
|
162
|
+
# @example String as router
|
163
|
+
# move '/' do
|
164
|
+
# puts 'Hello World'
|
165
|
+
# end
|
166
|
+
def move(path, &block) end
|
167
|
+
|
168
|
+
|
169
|
+
# Add PROPFIND method as a DSL for route definition
|
170
|
+
# @param [ String ] path Accepts as part of path in route definition
|
171
|
+
# @yield what to run when route matched
|
172
|
+
# @return [ nil ] nil
|
173
|
+
# @example String as router
|
174
|
+
# propfind '/' do
|
175
|
+
# puts 'Hello World'
|
176
|
+
# end
|
177
|
+
def proppatch(path, &block) end
|
178
|
+
|
179
|
+
# Add PROPPATCH method as a DSL for route definition
|
180
|
+
# @param [ String ] path Accepts as part of path in route definition
|
181
|
+
# @yield what to run when route matched
|
182
|
+
# @return [ nil ] nil
|
183
|
+
# @example String as router
|
184
|
+
# proppatch '/' do
|
185
|
+
# puts 'Hello World'
|
186
|
+
# end
|
187
|
+
def proppatch(path, &block) end
|
188
|
+
|
189
|
+
# Add UNLOCK method as a DSL for route definition
|
190
|
+
# @param [ String ] path Accepts as part of path in route definition
|
191
|
+
# @yield what to run when route matched
|
192
|
+
# @return [ nil ] nil
|
193
|
+
# @example String as router
|
194
|
+
# unlock '/' do
|
195
|
+
# puts 'Hello World'
|
196
|
+
# end
|
197
|
+
def unlock(path, &block) end
|
198
|
+
|
199
|
+
# Add REPORT method as a DSL for route definition
|
200
|
+
# @param [ String ] path Accepts as part of path in route definition
|
201
|
+
# @yield what to run when route matched
|
202
|
+
# @return [ nil ] nil
|
203
|
+
# @example String as router
|
204
|
+
# report '/' do
|
205
|
+
# puts 'Hello World'
|
206
|
+
# end
|
207
|
+
def report(path, &block) end
|
208
|
+
|
209
|
+
# Add MKACTIVITY method as a DSL for route definition
|
210
|
+
# @param [ String ] path Accepts as part of path in route definition
|
211
|
+
# @yield what to run when route matched
|
212
|
+
# @return [ nil ] nil
|
213
|
+
# @example String as router
|
214
|
+
# mkactivity '/' do
|
215
|
+
# puts 'Hello World'
|
216
|
+
# end
|
217
|
+
def mkactivity(path, &block) end
|
218
|
+
|
219
|
+
# Add CHECKOUT method as a DSL for route definition
|
220
|
+
# @param [ String ] path Accepts as part of path in route definition
|
221
|
+
# @yield what to run when route matched
|
222
|
+
# @return [ nil ] nil
|
223
|
+
# @example String as router
|
224
|
+
# checkout '/' do
|
225
|
+
# puts 'Hello World'
|
226
|
+
# end
|
227
|
+
def checkout(path, &block) end
|
228
|
+
|
229
|
+
# Add MERGE method as a DSL for route definition
|
230
|
+
# @param [ String ] path Accepts as part of path in route definition
|
231
|
+
# @yield what to run when route matched
|
232
|
+
# @return [ nil ] nil
|
233
|
+
# @example String as router
|
234
|
+
# merge '/' do
|
235
|
+
# puts 'Hello World'
|
236
|
+
# end
|
237
|
+
def merge(path, &block) end
|
238
|
+
|
239
|
+
# Add M-SEARCH method as a DSL for route definition
|
240
|
+
# @param [ String ] path Accepts as part of path in route definition
|
241
|
+
# @yield what to run when route matched
|
242
|
+
# @return [ nil ] nil
|
243
|
+
# @example String as router
|
244
|
+
# msearch '/' do
|
245
|
+
# puts 'Hello World'
|
246
|
+
# end
|
247
|
+
def msearch(path, &block)
|
248
|
+
add_route(:'M-SEARCH', path, block)
|
249
|
+
end
|
250
|
+
|
251
|
+
# Add NOTIFY method as a DSL for route definition
|
252
|
+
# @param [ String ] path Accepts as part of path in route definition
|
253
|
+
# @yield what to run when route matched
|
254
|
+
# @return [ nil ] nil
|
255
|
+
# @example String as router
|
256
|
+
# notify '/' do
|
257
|
+
# puts 'Hello World'
|
258
|
+
# end
|
259
|
+
def notify(path, &block) end
|
260
|
+
|
261
|
+
# Add SUBSCRIBE method as a DSL for route definition
|
262
|
+
# @param [ String ] path Accepts as part of path in route definition
|
263
|
+
# @yield what to run when route matched
|
264
|
+
# @return [ nil ] nil
|
265
|
+
# @example String as router
|
266
|
+
# subscribe '/' do
|
267
|
+
# puts 'Hello World'
|
268
|
+
# end
|
269
|
+
def merge(path, &block) end
|
270
|
+
|
271
|
+
# Add UNSUBSCRIBE method as a DSL for route definition
|
272
|
+
# @param [ String ] path Accepts as part of path in route definition
|
273
|
+
# @yield what to run when route matched
|
274
|
+
# @return [ nil ] nil
|
275
|
+
# @example String as router
|
276
|
+
# unsubscribe '/' do
|
277
|
+
# puts 'Hello World'
|
278
|
+
# end
|
279
|
+
def unsubscribe(path, &block) end
|
280
|
+
|
281
|
+
# Add PATCH method as a DSL for route definition
|
282
|
+
# @param [ String ] path Accepts as part of path in route definition
|
283
|
+
# @yield what to run when route matched
|
284
|
+
# @return [ nil ] nil
|
285
|
+
# @example String as router
|
286
|
+
# patch '/' do
|
287
|
+
# puts 'Hello World'
|
288
|
+
# end
|
289
|
+
def patch(path, &block) end
|
290
|
+
|
291
|
+
# Add PURGE method as a DSL for route definition
|
292
|
+
# @param [ String ] path Accepts as part of path in route definition
|
293
|
+
# @yield what to run when route matched
|
294
|
+
# @return [ nil ] nil
|
295
|
+
# @example String as router
|
296
|
+
# purge '/' do
|
297
|
+
# puts 'Hello World'
|
298
|
+
# end
|
299
|
+
def purge(path, &block) end
|
300
|
+
|
80
301
|
# Add LINK method as a DSL for route definition
|
81
302
|
# @param [ String ] path Accepts as part of path in route definition
|
82
303
|
# @yield what to run when route matched
|
@@ -193,7 +414,33 @@ class Midori::API
|
|
193
414
|
private_class_method :add_route, :inherited
|
194
415
|
|
195
416
|
# Constants of supported methods in route definition
|
196
|
-
METHODS = %w(
|
417
|
+
METHODS = %w( delete
|
418
|
+
get
|
419
|
+
head
|
420
|
+
post
|
421
|
+
put
|
422
|
+
connect
|
423
|
+
options
|
424
|
+
trace
|
425
|
+
copy
|
426
|
+
lock
|
427
|
+
mkcol
|
428
|
+
move
|
429
|
+
propfind
|
430
|
+
proppatch
|
431
|
+
unlock
|
432
|
+
report
|
433
|
+
mkactivity
|
434
|
+
checkout
|
435
|
+
merge
|
436
|
+
notify
|
437
|
+
subscribe
|
438
|
+
unsubscribe
|
439
|
+
patch
|
440
|
+
purge
|
441
|
+
websocket
|
442
|
+
eventsource
|
443
|
+
).freeze
|
197
444
|
|
198
445
|
# Magics to fill DSL methods through dynamically class method definition
|
199
446
|
METHODS.each do |method|
|
data/lib/midori/api_engine.rb
CHANGED
@@ -9,13 +9,31 @@ class Midori::APIEngine
|
|
9
9
|
# @param [ Symbol ] type type mustermann support
|
10
10
|
def initialize(root_api, type = :sinatra)
|
11
11
|
@routes = {
|
12
|
+
DELETE: [],
|
12
13
|
GET: [],
|
14
|
+
HEAD: [],
|
13
15
|
POST: [],
|
14
16
|
PUT: [],
|
15
|
-
|
17
|
+
CONNECT: [],
|
16
18
|
OPTIONS: [],
|
17
|
-
|
18
|
-
|
19
|
+
TRACE: [],
|
20
|
+
COPY: [],
|
21
|
+
LOCK: [],
|
22
|
+
MKCOL: [],
|
23
|
+
MOVE: [],
|
24
|
+
PROPFIND: [],
|
25
|
+
PROPPATCH: [],
|
26
|
+
UNLOCK: [],
|
27
|
+
REPORT: [],
|
28
|
+
MKACTIVITY: [],
|
29
|
+
CHECKOUT: [],
|
30
|
+
MERGE: [],
|
31
|
+
:'M-SEARCH' => [],
|
32
|
+
NOTIFY: [],
|
33
|
+
SUBSCRIBE: [],
|
34
|
+
UNSUBSCRIBE: [],
|
35
|
+
PATCH: [],
|
36
|
+
PURGE: [],
|
19
37
|
WEBSOCKET: [],
|
20
38
|
EVENTSOURCE: []
|
21
39
|
}
|
@@ -55,7 +73,7 @@ class Midori::APIEngine
|
|
55
73
|
def receive(request, connection = nil)
|
56
74
|
@routes[request.method].each do |route|
|
57
75
|
params = route.path.params(request.path)
|
58
|
-
next unless params
|
76
|
+
next unless params # Skip if not matched
|
59
77
|
request.params = params
|
60
78
|
route.middlewares.each { |middleware| request = middleware.before(request) }
|
61
79
|
clean_room = Midori::CleanRoom.new(request)
|
data/lib/midori/clean_room.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
##
|
2
2
|
# This class is used to be sandbox of requests processing.
|
3
|
-
# @attr [
|
3
|
+
# @attr [Integer] status HTTP response code
|
4
4
|
# @attr [Hash] header HTTP response header
|
5
5
|
# @attr [Object] body HTTP response body. String could is accepted by default, but could leave for further process with +Midori::Middleware+
|
6
6
|
# @attr [Midori::Request] request HTTP request
|
data/lib/midori/configure.rb
CHANGED
data/lib/midori/request.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
##
|
2
2
|
# Request class for midori
|
3
3
|
# @attr [String] ip client ip address
|
4
|
-
# @attr [
|
4
|
+
# @attr [Integer] port client port
|
5
5
|
# @attr [String] protocol protocol version of HTTP request
|
6
6
|
# @attr [String] method HTTP method
|
7
7
|
# @attr [String] path request path
|
@@ -35,7 +35,6 @@ class Midori::Request
|
|
35
35
|
# @param [ String ] data
|
36
36
|
# @return [ nil ] nil
|
37
37
|
def parse(data)
|
38
|
-
|
39
38
|
offset = @parser << data
|
40
39
|
@body = data[offset..-1]
|
41
40
|
@query_string = @path.match(/\?(.*?)$/)
|
data/lib/midori/response.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
class Midori::Response
|
7
7
|
attr_accessor :status, :header, :body
|
8
8
|
|
9
|
-
# @param [
|
9
|
+
# @param [Integer] code HTTP response code
|
10
10
|
# @param [Hash] header HTTP response header
|
11
11
|
# @param [String] body HTTP response body
|
12
12
|
# Init a Response
|
data/lib/midori/runner.rb
CHANGED
data/lib/midori/version.rb
CHANGED
data/lib/midori/websocket.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
##
|
2
2
|
# This class provides methods for WebSocket connection instance.
|
3
|
-
# @attr [ Array<
|
4
|
-
# @attr [
|
3
|
+
# @attr [ Array<Integer>, String ] msg message send from client
|
4
|
+
# @attr [ Integer ] opcode operation code of WebSocket
|
5
5
|
# @attr [ Hash ] events response for different event
|
6
6
|
# @attr [ EM::Connection ] connection raw EventMachine connection
|
7
7
|
# @attr [ Midori::Request ] request raw request
|
@@ -63,7 +63,7 @@ class Midori::WebSocket
|
|
63
63
|
end
|
64
64
|
|
65
65
|
# Send data
|
66
|
-
# @param [ Array<
|
66
|
+
# @param [ Array<Integer>, String ] msg data to send
|
67
67
|
def send(msg)
|
68
68
|
output = []
|
69
69
|
if msg.is_a?String
|
@@ -91,7 +91,7 @@ class Midori::WebSocket
|
|
91
91
|
end
|
92
92
|
|
93
93
|
# Ancestor of ping pong
|
94
|
-
# @param [
|
94
|
+
# @param [ Integer ] method opcode
|
95
95
|
# @param [ String ] str string to send
|
96
96
|
def heartbeat(method, str)
|
97
97
|
raise Midori::Exception::PingPongSizeTooLarge if str.size > 125
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: em-midori
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.7
|
4
|
+
version: 0.1.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- HeckPsi Lab
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: eventmachine
|
@@ -25,33 +25,33 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: mustermann
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0.
|
33
|
+
version: '0.4'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0.
|
40
|
+
version: '0.4'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: midori_http_parser
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 0.6.1
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 0.6.1
|
55
55
|
description: EM Midori is an EventMachine-based Web Framework written in pure Ruby,
|
56
56
|
providing high performance and proper abstraction.
|
57
57
|
email: business@heckpsi.com
|
@@ -104,7 +104,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
104
104
|
requirements:
|
105
105
|
- - ">="
|
106
106
|
- !ruby/object:Gem::Version
|
107
|
-
version: 2.
|
107
|
+
version: 2.1.0
|
108
108
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
109
|
requirements:
|
110
110
|
- - ">="
|
@@ -112,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
112
|
version: '0'
|
113
113
|
requirements: []
|
114
114
|
rubyforge_project:
|
115
|
-
rubygems_version: 2.
|
115
|
+
rubygems_version: 2.6.8
|
116
116
|
signing_key:
|
117
117
|
specification_version: 4
|
118
118
|
summary: An EventMachine Based Web Framework on Ruby
|