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.
Files changed (56) hide show
  1. data/Rakefile +3 -3
  2. data/lib/amf/version.rb +1 -1
  3. data/lib/rack/amf.rb +1 -48
  4. data/spec/amf/deserializer_spec.rb +0 -2
  5. data/spec/amf/serializer_spec.rb +0 -2
  6. data/spec/fixtures/objects/amf0-boolean.bin +1 -0
  7. data/spec/fixtures/objects/amf0-date.bin +0 -0
  8. data/spec/fixtures/objects/amf0-ecma-ordinal-array.bin +0 -0
  9. data/spec/fixtures/objects/amf0-hash.bin +0 -0
  10. data/spec/fixtures/objects/amf0-null.bin +1 -0
  11. data/spec/fixtures/objects/amf0-number.bin +0 -0
  12. data/spec/fixtures/objects/amf0-object.bin +0 -0
  13. data/spec/fixtures/objects/amf0-ref-test.bin +0 -0
  14. data/spec/fixtures/objects/amf0-strict-array.bin +0 -0
  15. data/spec/fixtures/objects/amf0-string.bin +0 -0
  16. data/spec/fixtures/objects/amf0-typed-object.bin +0 -0
  17. data/spec/fixtures/objects/amf0-undefined.bin +1 -0
  18. data/spec/fixtures/objects/amf0-untyped-object.bin +0 -0
  19. data/spec/fixtures/objects/amf3-0.bin +0 -0
  20. data/spec/fixtures/objects/amf3-arrayRef.bin +1 -0
  21. data/spec/fixtures/objects/amf3-bigNum.bin +0 -0
  22. data/spec/fixtures/objects/amf3-date.bin +0 -0
  23. data/spec/fixtures/objects/amf3-datesRef.bin +0 -0
  24. data/spec/fixtures/objects/amf3-dynObject.bin +2 -0
  25. data/spec/fixtures/objects/amf3-emptyArray.bin +1 -0
  26. data/spec/fixtures/objects/amf3-emptyArrayRef.bin +1 -0
  27. data/spec/fixtures/objects/amf3-emptyStringRef.bin +1 -0
  28. data/spec/fixtures/objects/amf3-false.bin +1 -0
  29. data/spec/fixtures/objects/amf3-graphMember.bin +0 -0
  30. data/spec/fixtures/objects/amf3-hash.bin +2 -0
  31. data/spec/fixtures/objects/amf3-largeMax.bin +0 -0
  32. data/spec/fixtures/objects/amf3-largeMin.bin +0 -0
  33. data/spec/fixtures/objects/amf3-max.bin +1 -0
  34. data/spec/fixtures/objects/amf3-min.bin +0 -0
  35. data/spec/fixtures/objects/amf3-mixedArray.bin +11 -0
  36. data/spec/fixtures/objects/amf3-null.bin +1 -0
  37. data/spec/fixtures/objects/amf3-objRef.bin +0 -0
  38. data/spec/fixtures/objects/amf3-primArray.bin +1 -0
  39. data/spec/fixtures/objects/amf3-string.bin +1 -0
  40. data/spec/fixtures/objects/amf3-stringRef.bin +0 -0
  41. data/spec/fixtures/objects/amf3-symbol.bin +1 -0
  42. data/spec/fixtures/objects/amf3-true.bin +1 -0
  43. data/spec/fixtures/objects/amf3-typedObject.bin +2 -0
  44. data/spec/fixtures/request/acknowledge-response.bin +0 -0
  45. data/spec/fixtures/request/amf0-error-response.bin +0 -0
  46. data/spec/fixtures/request/commandMessage.bin +0 -0
  47. data/spec/fixtures/request/remotingMessage.bin +0 -0
  48. data/spec/fixtures/request/simple-response.bin +0 -0
  49. data/spec/rack/request_spec.rb +1 -0
  50. data/spec/rack/response_spec.rb +1 -0
  51. data/spec/rack/service_manager_spec.rb +9 -10
  52. data/spec/spec.opts +1 -0
  53. data/spec/spec_helper.rb +1 -0
  54. metadata +46 -4
  55. data/lib/rack/amf/middleware/rails.rb +0 -39
  56. 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.3'
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
@@ -1,6 +1,6 @@
1
1
  module AMF
2
2
  # AMF version
3
- VERSION = '0.0.3'
3
+ VERSION = '0.0.4'
4
4
  VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
@@ -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)
@@ -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
+   abc  
@@ -0,0 +1,2 @@
1
+
2
+ /another_public_propertya_public_valuenil_propertyproperty_onefooproperty_two
@@ -0,0 +1 @@
1
+     
@@ -0,0 +1 @@
1
+ ����
@@ -0,0 +1,11 @@
1
+ 
2
+ foo_onebar_one
3
+ foo_two
4
+ foo_three*
5
+ 
6
+  
7
+ 
8
+ 
9
+  * 
10
+ 
11
+ 
@@ -0,0 +1 @@
1
+ 
@@ -0,0 +1 @@
1
+ String . String
@@ -0,0 +1,2 @@
1
+
2
+ #'org.rackAMF.ASClassbazfoobar
@@ -1,5 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/../spec_helper.rb'
2
2
  require 'rack/amf'
3
+ require 'rack/amf/request'
3
4
 
4
5
  describe Rack::AMF::Request do
5
6
  end
@@ -1,5 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/../spec_helper.rb'
2
2
  require 'rack/amf'
3
+ require 'rack/amf/response'
3
4
 
4
5
  describe Rack::AMF::Response do
5
6
  it "should serialize response when converted to string" do
@@ -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
- @manager.register('path.Service', service)
12
- service.should_receive('respond_to?').with('test').and_return(true)
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
- @manager.register('', service)
21
- service.should_receive('respond_to?').with('test').and_return(true)
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
@@ -0,0 +1 @@
1
+ --colour
@@ -19,6 +19,7 @@ def object_fixture(binary_path)
19
19
  end
20
20
 
21
21
  def create_rack_request(binary_path)
22
+ require 'rack/amf/request'
22
23
  env = {'rack.input' => StringIO.new(request_fixture(binary_path))}
23
24
  Rack::AMF::Request.new(env)
24
25
  end
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.3
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-19 00:00:00 -04:00
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