riddl 0.99.130 → 0.99.131
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ruby/riddl/protocols/websocket.rb +1 -0
- data/lib/ruby/riddl/server.rb +19 -10
- data/lib/ruby/riddl/wrapper.rb +1 -1
- data/riddl.gemspec +2 -2
- metadata +6 -6
data/lib/ruby/riddl/server.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
gem 'thin', '=1.5.1'
|
1
|
+
#gem 'thin', '=1.5.1'
|
2
2
|
require File.expand_path(File.dirname(__FILE__) + '/constants')
|
3
3
|
require File.expand_path(File.dirname(__FILE__) + '/implementation')
|
4
4
|
require File.expand_path(File.dirname(__FILE__) + '/protocols/http/parser')
|
@@ -146,7 +146,7 @@ module Riddl
|
|
146
146
|
:pid => File.expand_path(@riddl_opts[:basepath] + '/' + @riddl_opts[:pidfile])
|
147
147
|
)
|
148
148
|
else
|
149
|
-
|
149
|
+
Rack::Server.new(
|
150
150
|
:app => app,
|
151
151
|
:Port => @riddl_opts[:port],
|
152
152
|
:environment => 'none',
|
@@ -164,8 +164,9 @@ module Riddl
|
|
164
164
|
begin
|
165
165
|
EM.run do
|
166
166
|
puts "Server (#{@riddl_opts[:url]}) started as PID:#{Process.pid}"
|
167
|
-
puts "XMPP support (#{@riddl_xmpp_jid}) active" if @riddl_xmpp_jid && @riddl_xmpp_pass
|
168
167
|
server.start
|
168
|
+
|
169
|
+
puts "XMPP support (#{@riddl_xmpp_jid}) active" if @riddl_xmpp_jid && @riddl_xmpp_pass
|
169
170
|
if @riddl_xmpp_jid && @riddl_xmpp_pass
|
170
171
|
xmpp = Blather::Client.setup @riddl_xmpp_jid, @riddl_xmpp_pass
|
171
172
|
@riddl_opts[:xmpp] = xmpp
|
@@ -188,8 +189,16 @@ module Riddl
|
|
188
189
|
]
|
189
190
|
end
|
190
191
|
xmpp.connect
|
192
|
+
end
|
193
|
+
|
194
|
+
[:INT, :TERM].each do |signal|
|
195
|
+
Signal.trap(signal) do
|
196
|
+
EM.stop
|
197
|
+
end
|
191
198
|
end
|
199
|
+
|
192
200
|
end
|
201
|
+
|
193
202
|
rescue => e
|
194
203
|
if e.is_a?(Blather::Stream::ConnectionFailed)
|
195
204
|
puts "Server (#{@riddl_xmpp_jid}) stopped due to connection error (PID:#{Process.pid})"
|
@@ -242,7 +251,7 @@ module Riddl
|
|
242
251
|
def __call #{{{
|
243
252
|
@riddl_message = @riddl.io_messages(@riddl_matching_path[0],@riddl_method,@riddl_parameters,@riddl_headers)
|
244
253
|
if @riddl_message.nil?
|
245
|
-
if @riddl_info[:env].has_key?('HTTP_ORIGIN') && @riddl_cross_site_xhr
|
254
|
+
if @riddl_info[:env].has_key?('HTTP_ORIGIN') && @riddl_cross_site_xhr && @riddl_method == 'options'
|
246
255
|
@riddl_res['Access-Control-Allow-Origin'] = '*'
|
247
256
|
@riddl_res['Access-Control-Allow-Methods'] = 'GET, POST, PUT, DELETE, OPTIONS'
|
248
257
|
@riddl_res['Access-Control-Allow-Headers'] = @riddl_info[:env]['HTTP_ACCESS_CONTROL_REQUEST_HEADERS'] if @riddl_info[:env]['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']
|
@@ -401,10 +410,10 @@ module Riddl
|
|
401
410
|
# TODO raise error when declaration and route or (not route and non-local interface)
|
402
411
|
# raise SpecificationError, 'RIDDL description does not conform to specification' unless @riddl.validate!
|
403
412
|
@riddl_info[:m] = @riddl_method = 'websocket'
|
413
|
+
@riddl_message = @riddl.io_messages(@riddl_matching_path[0],'websocket',@riddl_parameters,@riddl_headers)
|
404
414
|
if @riddl.description?
|
405
415
|
instance_exec(@riddl_info, &@riddl_interfaces[nil])
|
406
416
|
elsif @riddl.declaration?
|
407
|
-
@riddl_message = @riddl.io_messages(@riddl_matching_path[0],'websocket',@riddl_parameters,@riddl_headers)
|
408
417
|
# one ws connection, no overlay
|
409
418
|
unless @riddl_message.nil?
|
410
419
|
if @riddl_interfaces.key? @riddl_message.interface.name
|
@@ -514,11 +523,11 @@ module Riddl
|
|
514
523
|
false
|
515
524
|
end
|
516
525
|
end # }}}
|
517
|
-
def post(min='*'); return false if @riddl_message.nil?; @riddl_path == '/' + @riddl_info[:s].join('/') && min == @riddl_message.in.name && @riddl_method == 'post' end
|
518
|
-
def get(min='*'); return false if @riddl_message.nil?; @riddl_path == '/' + @riddl_info[:s].join('/') && min == @riddl_message.in.name && @riddl_method == 'get' end
|
519
|
-
def delete(min='*'); return false if @riddl_message.nil?; @riddl_path == '/' + @riddl_info[:s].join('/') && min == @riddl_message.in.name && @riddl_method == 'delete' end
|
520
|
-
def put(min='*'); return false if @riddl_message.nil?; @riddl_path == '/' + @riddl_info[:s].join('/') && min == @riddl_message.in.name && @riddl_method == 'put' end
|
521
|
-
def websocket; return false if @riddl_message.nil?; @riddl_path == '/' + @riddl_info[:s].join('/')
|
526
|
+
def post(min='*'); return false if @riddl_message.nil?; @riddl_path == '/' + @riddl_info[:s].join('/') && @riddl_message.in && min == @riddl_message.in.name && @riddl_method == 'post' end
|
527
|
+
def get(min='*'); return false if @riddl_message.nil?; @riddl_path == '/' + @riddl_info[:s].join('/') && @riddl_message.in && min == @riddl_message.in.name && @riddl_method == 'get' end
|
528
|
+
def delete(min='*'); return false if @riddl_message.nil?; @riddl_path == '/' + @riddl_info[:s].join('/') && @riddl_message.in && min == @riddl_message.in.name && @riddl_method == 'delete' end
|
529
|
+
def put(min='*'); return false if @riddl_message.nil?; @riddl_path == '/' + @riddl_info[:s].join('/') && @riddl_message.in && min == @riddl_message.in.name && @riddl_method == 'put' end
|
530
|
+
def websocket; return false if @riddl_message.nil?; @riddl_path == '/' + @riddl_info[:s].join('/') && @riddl_method == 'websocket' end
|
522
531
|
def resource(rname=nil); return rname.nil? ? '{}' : rname end
|
523
532
|
|
524
533
|
def matching_path #{{{
|
data/lib/ruby/riddl/wrapper.rb
CHANGED
@@ -179,7 +179,7 @@ module Riddl
|
|
179
179
|
return IOMessages.new(Riddl::Wrapper::Description::Star.new, Riddl::Wrapper::Description::Star.new)
|
180
180
|
end
|
181
181
|
r.select{|o|o.class==Riddl::Wrapper::Description::WebSocket}.each do |o|
|
182
|
-
return IOMessages.new(nil,nil,nil,
|
182
|
+
return IOMessages.new(nil,nil,nil,nil)
|
183
183
|
end
|
184
184
|
end
|
185
185
|
if @is_declaration
|
data/riddl.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "riddl"
|
3
|
-
s.version = "0.99.
|
3
|
+
s.version = "0.99.131"
|
4
4
|
s.platform = Gem::Platform::RUBY
|
5
5
|
s.license = "LGPL-3"
|
6
6
|
s.summary = "restful interface description and declaration language: tools and client/server libs"
|
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
|
|
23
23
|
|
24
24
|
s.add_runtime_dependency 'xml-smart', '>=0.3.6'
|
25
25
|
s.add_runtime_dependency 'rack'
|
26
|
-
s.add_runtime_dependency 'thin', '
|
26
|
+
s.add_runtime_dependency 'thin', '>=1.6.1'
|
27
27
|
s.add_runtime_dependency 'eventmachine', '>= 1.0.0'
|
28
28
|
s.add_runtime_dependency 'em-websocket', '>= 0.4.0'
|
29
29
|
s.add_runtime_dependency 'em-websocket-client'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: riddl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.99.
|
4
|
+
version: 0.99.131
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: tools
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-12-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: xml-smart
|
@@ -48,17 +48,17 @@ dependencies:
|
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
49
49
|
none: false
|
50
50
|
requirements:
|
51
|
-
- - '
|
51
|
+
- - ! '>='
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 1.
|
53
|
+
version: 1.6.1
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
none: false
|
58
58
|
requirements:
|
59
|
-
- - '
|
59
|
+
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.
|
61
|
+
version: 1.6.1
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: eventmachine
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|