rack-amf 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +3 -3
- data/lib/amf/version.rb +1 -1
- data/lib/rack/amf.rb +1 -48
- data/spec/amf/deserializer_spec.rb +0 -2
- data/spec/amf/serializer_spec.rb +0 -2
- data/spec/fixtures/objects/amf0-boolean.bin +1 -0
- data/spec/fixtures/objects/amf0-date.bin +0 -0
- data/spec/fixtures/objects/amf0-ecma-ordinal-array.bin +0 -0
- data/spec/fixtures/objects/amf0-hash.bin +0 -0
- data/spec/fixtures/objects/amf0-null.bin +1 -0
- data/spec/fixtures/objects/amf0-number.bin +0 -0
- data/spec/fixtures/objects/amf0-object.bin +0 -0
- data/spec/fixtures/objects/amf0-ref-test.bin +0 -0
- data/spec/fixtures/objects/amf0-strict-array.bin +0 -0
- data/spec/fixtures/objects/amf0-string.bin +0 -0
- data/spec/fixtures/objects/amf0-typed-object.bin +0 -0
- data/spec/fixtures/objects/amf0-undefined.bin +1 -0
- data/spec/fixtures/objects/amf0-untyped-object.bin +0 -0
- data/spec/fixtures/objects/amf3-0.bin +0 -0
- data/spec/fixtures/objects/amf3-arrayRef.bin +1 -0
- data/spec/fixtures/objects/amf3-bigNum.bin +0 -0
- data/spec/fixtures/objects/amf3-date.bin +0 -0
- data/spec/fixtures/objects/amf3-datesRef.bin +0 -0
- data/spec/fixtures/objects/amf3-dynObject.bin +2 -0
- data/spec/fixtures/objects/amf3-emptyArray.bin +1 -0
- data/spec/fixtures/objects/amf3-emptyArrayRef.bin +1 -0
- data/spec/fixtures/objects/amf3-emptyStringRef.bin +1 -0
- data/spec/fixtures/objects/amf3-false.bin +1 -0
- data/spec/fixtures/objects/amf3-graphMember.bin +0 -0
- data/spec/fixtures/objects/amf3-hash.bin +2 -0
- data/spec/fixtures/objects/amf3-largeMax.bin +0 -0
- data/spec/fixtures/objects/amf3-largeMin.bin +0 -0
- data/spec/fixtures/objects/amf3-max.bin +1 -0
- data/spec/fixtures/objects/amf3-min.bin +0 -0
- data/spec/fixtures/objects/amf3-mixedArray.bin +11 -0
- data/spec/fixtures/objects/amf3-null.bin +1 -0
- data/spec/fixtures/objects/amf3-objRef.bin +0 -0
- data/spec/fixtures/objects/amf3-primArray.bin +1 -0
- data/spec/fixtures/objects/amf3-string.bin +1 -0
- data/spec/fixtures/objects/amf3-stringRef.bin +0 -0
- data/spec/fixtures/objects/amf3-symbol.bin +1 -0
- data/spec/fixtures/objects/amf3-true.bin +1 -0
- data/spec/fixtures/objects/amf3-typedObject.bin +2 -0
- data/spec/fixtures/request/acknowledge-response.bin +0 -0
- data/spec/fixtures/request/amf0-error-response.bin +0 -0
- data/spec/fixtures/request/commandMessage.bin +0 -0
- data/spec/fixtures/request/remotingMessage.bin +0 -0
- data/spec/fixtures/request/simple-response.bin +0 -0
- data/spec/rack/request_spec.rb +1 -0
- data/spec/rack/response_spec.rb +1 -0
- data/spec/rack/service_manager_spec.rb +9 -10
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +1 -0
- metadata +46 -4
- data/lib/rack/amf/middleware/rails.rb +0 -39
- data/lib/rack/amf/rails/rack_amf_controller.rb +0 -23
data/Rakefile
CHANGED
@@ -23,10 +23,10 @@ end
|
|
23
23
|
|
24
24
|
spec = Gem::Specification.new do |s|
|
25
25
|
s.name = 'rack-amf'
|
26
|
-
s.version = '0.0.
|
26
|
+
s.version = '0.0.4'
|
27
27
|
s.summary = 'AMF serializer/deserializer and AMF gateway packaged as a rack middleware'
|
28
28
|
|
29
|
-
s.files = FileList['README.rdoc', 'Rakefile', 'lib/**/*.rb', 'spec/**/*.rb']
|
29
|
+
s.files = FileList['README.rdoc', 'Rakefile', 'lib/**/*.rb', 'spec/**/*.rb', 'spec/**/*.bin', 'spec/spec.opts']
|
30
30
|
s.require_path = 'lib'
|
31
31
|
s.test_files = Dir[*['spec/**/*_spec.rb']]
|
32
32
|
|
@@ -51,4 +51,4 @@ task :gemspec do
|
|
51
51
|
File.open("#{spec.name}.gemspec", 'w') do |f|
|
52
52
|
f.write spec.to_ruby
|
53
53
|
end
|
54
|
-
end
|
54
|
+
end
|
data/lib/amf/version.rb
CHANGED
data/lib/rack/amf.rb
CHANGED
@@ -18,51 +18,4 @@ module Rack::AMF
|
|
18
18
|
raise "Invalide mode: #{options[:mode]}"
|
19
19
|
end
|
20
20
|
end
|
21
|
-
end
|
22
|
-
=begin
|
23
|
-
require 'rack'
|
24
|
-
require 'amf'
|
25
|
-
require 'rack/amf/environment'
|
26
|
-
|
27
|
-
# Rack::AMF middleware
|
28
|
-
module Rack::AMF; end;
|
29
|
-
|
30
|
-
# Bootstrap based on environment
|
31
|
-
if defined?(Rails)
|
32
|
-
# Load in needed files
|
33
|
-
require 'rack/amf/middleware/rails'
|
34
|
-
|
35
|
-
#--
|
36
|
-
# Then we'll modify new to return the middleware to use in rails
|
37
|
-
module Rack::AMF
|
38
|
-
def self.new app, options={} #:nodoc:
|
39
|
-
Middleware::Rails.new(app, options)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
# Set default configs
|
44
|
-
Rack::AMF::Environment.url = '/amf'
|
45
|
-
Rack::AMF::Environment.mode = :rails
|
46
|
-
|
47
|
-
# Install rails mods
|
48
|
-
Rack::AMF::Middleware::Rails.install_environment
|
49
|
-
else
|
50
|
-
module Rack::AMF
|
51
|
-
def self.new app, options={} #:nodoc:
|
52
|
-
# Set default mode
|
53
|
-
options[:mode] = :service_manager if !options[:mode]
|
54
|
-
|
55
|
-
# Which version of the middleware?
|
56
|
-
if options[:mode] == :pass_through
|
57
|
-
require 'rack/amf/middleware/pass_through'
|
58
|
-
Middleware::PassThrough.new(app, options)
|
59
|
-
elsif options[:mode] == :service_manager
|
60
|
-
require 'rack/amf/middleware/service_manager'
|
61
|
-
Middleware::ServiceManager.new(app, options)
|
62
|
-
else
|
63
|
-
raise "Invalide mode: #{options[:mode]}"
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
=end
|
21
|
+
end
|
@@ -205,8 +205,6 @@ describe "when deserializing" do
|
|
205
205
|
output.should == {:foo => "bar", :answer => 42}
|
206
206
|
end
|
207
207
|
|
208
|
-
it "should deserialize an open struct as a dynamic anonymous object"
|
209
|
-
|
210
208
|
it "should deserialize an empty array" do
|
211
209
|
input = object_fixture("amf3-emptyArray.bin")
|
212
210
|
output = AMF.deserialize(input, 3)
|
data/spec/amf/serializer_spec.rb
CHANGED
@@ -196,8 +196,6 @@ describe "when serializing" do
|
|
196
196
|
output.should == expected
|
197
197
|
end
|
198
198
|
|
199
|
-
it "should serialize an open struct as a dynamic anonymous object"
|
200
|
-
|
201
199
|
it "should serialize an empty array" do
|
202
200
|
expected = object_fixture("amf3-emptyArray.bin")
|
203
201
|
input = []
|
@@ -0,0 +1 @@
|
|
1
|
+
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
|
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
abc
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
����
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
String . String
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
foo
|
@@ -0,0 +1 @@
|
|
1
|
+
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/spec/rack/request_spec.rb
CHANGED
data/spec/rack/response_spec.rb
CHANGED
@@ -1,25 +1,24 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
2
2
|
require 'rack/amf'
|
3
|
+
require 'rack/amf/middleware/service_manager'
|
3
4
|
|
4
|
-
describe Rack::AMF::ServiceManager do
|
5
|
+
describe Rack::AMF::Middleware::ServiceManager do
|
5
6
|
before :each do
|
6
|
-
@manager = Rack::AMF::ServiceManager.new
|
7
|
+
@manager = Rack::AMF::Middleware::ServiceManager.new nil
|
7
8
|
end
|
8
9
|
|
9
10
|
it "should support mapped services" do
|
10
|
-
service = mock "Service"
|
11
|
-
|
12
|
-
service.should_receive('
|
13
|
-
service.should_receive('test').with('arg1', 'arg2').and_return('success')
|
11
|
+
service = mock "Service", :test => 'success'
|
12
|
+
Rack::AMF::Environment.register_service 'path.Service', service
|
13
|
+
service.should_receive('test').with('arg1', 'arg2')
|
14
14
|
|
15
15
|
@manager.send(:handle_method, 'path.Service.test', ['arg1', 'arg2']).should == 'success'
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should map '' to no path method calls" do
|
19
|
-
service = mock "Service"
|
20
|
-
|
21
|
-
service.should_receive('
|
22
|
-
service.should_receive('test').and_return('success')
|
19
|
+
service = mock "Service", :test => 'success'
|
20
|
+
Rack::AMF::Environment.register_service '', service
|
21
|
+
service.should_receive('test')
|
23
22
|
|
24
23
|
@manager.send(:handle_method, 'test', []).should == 'success'
|
25
24
|
end
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-amf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tony Hillerson
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-10-
|
13
|
+
date: 2009-10-25 00:00:00 -04:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|
@@ -40,10 +40,8 @@ files:
|
|
40
40
|
- lib/amf.rb
|
41
41
|
- lib/rack/amf/environment.rb
|
42
42
|
- lib/rack/amf/middleware/pass_through.rb
|
43
|
-
- lib/rack/amf/middleware/rails.rb
|
44
43
|
- lib/rack/amf/middleware/service_manager.rb
|
45
44
|
- lib/rack/amf/middleware.rb
|
46
|
-
- lib/rack/amf/rails/rack_amf_controller.rb
|
47
45
|
- lib/rack/amf/request.rb
|
48
46
|
- lib/rack/amf/response.rb
|
49
47
|
- lib/rack/amf.rb
|
@@ -58,6 +56,50 @@ files:
|
|
58
56
|
- spec/rack/response_spec.rb
|
59
57
|
- spec/rack/service_manager_spec.rb
|
60
58
|
- spec/spec_helper.rb
|
59
|
+
- spec/fixtures/objects/amf0-boolean.bin
|
60
|
+
- spec/fixtures/objects/amf0-date.bin
|
61
|
+
- spec/fixtures/objects/amf0-ecma-ordinal-array.bin
|
62
|
+
- spec/fixtures/objects/amf0-hash.bin
|
63
|
+
- spec/fixtures/objects/amf0-null.bin
|
64
|
+
- spec/fixtures/objects/amf0-number.bin
|
65
|
+
- spec/fixtures/objects/amf0-object.bin
|
66
|
+
- spec/fixtures/objects/amf0-ref-test.bin
|
67
|
+
- spec/fixtures/objects/amf0-strict-array.bin
|
68
|
+
- spec/fixtures/objects/amf0-string.bin
|
69
|
+
- spec/fixtures/objects/amf0-typed-object.bin
|
70
|
+
- spec/fixtures/objects/amf0-undefined.bin
|
71
|
+
- spec/fixtures/objects/amf0-untyped-object.bin
|
72
|
+
- spec/fixtures/objects/amf3-0.bin
|
73
|
+
- spec/fixtures/objects/amf3-arrayRef.bin
|
74
|
+
- spec/fixtures/objects/amf3-bigNum.bin
|
75
|
+
- spec/fixtures/objects/amf3-date.bin
|
76
|
+
- spec/fixtures/objects/amf3-datesRef.bin
|
77
|
+
- spec/fixtures/objects/amf3-dynObject.bin
|
78
|
+
- spec/fixtures/objects/amf3-emptyArray.bin
|
79
|
+
- spec/fixtures/objects/amf3-emptyArrayRef.bin
|
80
|
+
- spec/fixtures/objects/amf3-emptyStringRef.bin
|
81
|
+
- spec/fixtures/objects/amf3-false.bin
|
82
|
+
- spec/fixtures/objects/amf3-graphMember.bin
|
83
|
+
- spec/fixtures/objects/amf3-hash.bin
|
84
|
+
- spec/fixtures/objects/amf3-largeMax.bin
|
85
|
+
- spec/fixtures/objects/amf3-largeMin.bin
|
86
|
+
- spec/fixtures/objects/amf3-max.bin
|
87
|
+
- spec/fixtures/objects/amf3-min.bin
|
88
|
+
- spec/fixtures/objects/amf3-mixedArray.bin
|
89
|
+
- spec/fixtures/objects/amf3-null.bin
|
90
|
+
- spec/fixtures/objects/amf3-objRef.bin
|
91
|
+
- spec/fixtures/objects/amf3-primArray.bin
|
92
|
+
- spec/fixtures/objects/amf3-string.bin
|
93
|
+
- spec/fixtures/objects/amf3-stringRef.bin
|
94
|
+
- spec/fixtures/objects/amf3-symbol.bin
|
95
|
+
- spec/fixtures/objects/amf3-true.bin
|
96
|
+
- spec/fixtures/objects/amf3-typedObject.bin
|
97
|
+
- spec/fixtures/request/acknowledge-response.bin
|
98
|
+
- spec/fixtures/request/amf0-error-response.bin
|
99
|
+
- spec/fixtures/request/commandMessage.bin
|
100
|
+
- spec/fixtures/request/remotingMessage.bin
|
101
|
+
- spec/fixtures/request/simple-response.bin
|
102
|
+
- spec/spec.opts
|
61
103
|
has_rdoc: true
|
62
104
|
homepage: http://github.com/warhammerkid/rack-amf
|
63
105
|
licenses: []
|
@@ -1,39 +0,0 @@
|
|
1
|
-
require 'rack/amf/middleware'
|
2
|
-
|
3
|
-
module Rack::AMF::Middleware #:nodoc:
|
4
|
-
class Rails
|
5
|
-
include Rack::AMF::Middleware
|
6
|
-
|
7
|
-
def initialize app, options={}
|
8
|
-
@app = app
|
9
|
-
|
10
|
-
options.delete(:url) # Too late to modify the URL
|
11
|
-
Rack::AMF::Environment.populate options
|
12
|
-
end
|
13
|
-
|
14
|
-
def handle env
|
15
|
-
@app.call env
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.install_environment
|
19
|
-
return if @installed
|
20
|
-
@installed = true
|
21
|
-
|
22
|
-
# Load in files
|
23
|
-
extras_dir = File.dirname(__FILE__)+'/../rails'
|
24
|
-
Dir["#{extras_dir}/*.rb"].each {|f| require f}
|
25
|
-
|
26
|
-
# Install route
|
27
|
-
ActionController::Routing::RouteSet.class_eval do
|
28
|
-
next if self.instance_methods.include? 'draw_with_rackamf'
|
29
|
-
def draw_with_rackamf
|
30
|
-
draw_without_rackamf do |map|
|
31
|
-
map.rack_amf Rack::AMF::Environment.url, :controller => 'rack_amf', :action => 'handle'
|
32
|
-
yield map
|
33
|
-
end
|
34
|
-
end
|
35
|
-
alias_method_chain :draw, :rackamf
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
class RackAmfController < ApplicationController
|
2
|
-
def handle
|
3
|
-
if request.env['rack-amf.request']
|
4
|
-
RAILS_DEFAULT_LOGGER.info "[rack-amf] Handle request"
|
5
|
-
request.env['rack-amf.response'].each_method_call do |method, args|
|
6
|
-
handle_call method, args
|
7
|
-
end
|
8
|
-
else
|
9
|
-
render :text => '<html><body>Rack::AMF Gateway</body></html>'
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
private
|
14
|
-
def handle_call method, args
|
15
|
-
path = method.split('.')
|
16
|
-
raise "Invalid method '#{method}': Methods must look like this 'ServiceController.method'" if path.length != 2
|
17
|
-
|
18
|
-
action = path.pop
|
19
|
-
controller = path.pop
|
20
|
-
|
21
|
-
|
22
|
-
end
|
23
|
-
end
|