mrpin-rocketamf 1.0.4 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/README.rdoc +1 -1
  3. data/Rakefile +7 -7
  4. data/benchmark.rb +44 -37
  5. data/ext/rocketamf_ext/class_mapping.c +11 -11
  6. data/ext/rocketamf_ext/remoting.c +1 -1
  7. data/lib/rocketamf.rb +41 -98
  8. data/lib/rocketamf/constants.rb +20 -20
  9. data/lib/rocketamf/errors.rb +2 -0
  10. data/lib/rocketamf/errors/amf_error.rb +5 -0
  11. data/lib/rocketamf/errors/amf_error_incomplete.rb +5 -0
  12. data/lib/rocketamf/ext.rb +0 -6
  13. data/lib/rocketamf/extensions.rb +4 -4
  14. data/lib/rocketamf/{class_mapping.rb → mapping/class_mapping.rb} +70 -103
  15. data/lib/rocketamf/mapping/mapping_set.rb +63 -0
  16. data/lib/rocketamf/pure.rb +1 -9
  17. data/lib/rocketamf/pure/deserializer.rb +234 -262
  18. data/lib/rocketamf/pure/helpers/io_helper_base.rb +19 -0
  19. data/lib/rocketamf/pure/helpers/io_helper_read.rb +67 -0
  20. data/lib/rocketamf/pure/helpers/io_helper_write.rb +48 -0
  21. data/lib/rocketamf/pure/helpers/object_cache.rb +20 -0
  22. data/lib/rocketamf/pure/helpers/string_cache.rb +14 -0
  23. data/lib/rocketamf/pure/serializer.rb +138 -271
  24. data/lib/rocketamf/types.rb +1 -0
  25. data/lib/rocketamf/{values → types}/typed_hash.rb +12 -2
  26. data/mrpin-rocketamf.gemspec +27 -16
  27. data/spec/class_mapping_spec.rb +59 -52
  28. data/spec/deserializer_spec.rb +164 -328
  29. data/spec/fast_class_mapping_spec.rb +52 -46
  30. data/spec/helpers/class_mapping_test.rb +4 -0
  31. data/spec/helpers/class_mapping_test2.rb +3 -0
  32. data/spec/helpers/externalizable_test.rb +24 -0
  33. data/spec/helpers/fixtures.rb +28 -0
  34. data/spec/helpers/other_class.rb +4 -0
  35. data/spec/helpers/ruby_class.rb +4 -0
  36. data/spec/helpers/test_ruby_class.rb +4 -0
  37. data/spec/serializer_spec.rb +248 -339
  38. data/spec/spec_helper.rb +4 -49
  39. metadata +47 -53
  40. data/lib/rocketamf/pure/io_helpers.rb +0 -94
  41. data/lib/rocketamf/pure/remoting.rb +0 -117
  42. data/lib/rocketamf/remoting.rb +0 -196
  43. data/lib/rocketamf/values/messages.rb +0 -214
  44. data/spec/fixtures/objects/amf0-boolean.bin +0 -1
  45. data/spec/fixtures/objects/amf0-complex-encoded-string.bin +0 -0
  46. data/spec/fixtures/objects/amf0-date.bin +0 -0
  47. data/spec/fixtures/objects/amf0-ecma-ordinal-array.bin +0 -0
  48. data/spec/fixtures/objects/amf0-empty-string-key-hash.bin +0 -0
  49. data/spec/fixtures/objects/amf0-hash.bin +0 -0
  50. data/spec/fixtures/objects/amf0-null.bin +0 -1
  51. data/spec/fixtures/objects/amf0-number.bin +0 -0
  52. data/spec/fixtures/objects/amf0-object.bin +0 -0
  53. data/spec/fixtures/objects/amf0-ref-test.bin +0 -0
  54. data/spec/fixtures/objects/amf0-strict-array.bin +0 -0
  55. data/spec/fixtures/objects/amf0-string.bin +0 -0
  56. data/spec/fixtures/objects/amf0-time.bin +0 -0
  57. data/spec/fixtures/objects/amf0-typed-object.bin +0 -0
  58. data/spec/fixtures/objects/amf0-undefined.bin +0 -1
  59. data/spec/fixtures/objects/amf0-untyped-object.bin +0 -0
  60. data/spec/fixtures/objects/amf0-xml-doc.bin +0 -0
  61. data/spec/messages_spec.rb +0 -39
  62. data/spec/remoting_spec.rb +0 -196
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 89a384bbdb4acd4fbd09cec6b2b1bc063f33eb6a
4
- data.tar.gz: 9a547e174f37ec203153c2a871406495a3339f5a
3
+ metadata.gz: 9d63832510464963b845035c265bbc971b411ecb
4
+ data.tar.gz: 658cafa2f6e9ec23b55d343178eeeeb1466410de
5
5
  SHA512:
6
- metadata.gz: 6b46b6df13dd18e05c4963cd791de40f5ec5a35786f20822e48118605e2913a573c8277ca1152fa3d7aa7e8e1849e4aad2a4098f11722e7e2f4f2bdd84a01742
7
- data.tar.gz: ef6039476cc10fbe2f29a55f77577d9801614bec24f1fca758231c4bc5c0f2eee5c6af557745ceb37d385bcd5bfa7352ce64030d1b42b9e4c64acd38deb83193
6
+ metadata.gz: 38481d7ea20ab45a9b3ebb9f7b339e7796a9756c93f75773f2a671fdc62d4c2109a3b92811b121a2a7cf4bd285f95f927feb0309002d77c841a7211bbe8741be
7
+ data.tar.gz: 3bed4925ed2fb064f79bb1ed8716fc65bf40a9dd51187634fb7b646bf9bd776fcf55930ffbe83547fb811a0675b6c379a8a80bf2f2c92d710f4b94a2c5f884b1
data/README.rdoc CHANGED
@@ -18,7 +18,7 @@ compatible with Ruby 1.9.
18
18
 
19
19
  hash = {:apple => "Apfel", :red => "Rot", :eyes => "Augen"}
20
20
  File.open("amf.dat", 'w') do |f|
21
- f.write RocketAMF.serialize(hash, 3) # Use AMF3 encoding to serialize
21
+ f.write RocketAMF.serialize(hash) # Use AMF3 encoding to serialize
22
22
  end
23
23
 
24
24
  == LICENSE:
data/Rakefile CHANGED
@@ -6,15 +6,15 @@ require 'rspec/core/rake_task'
6
6
  require 'rake/extensiontask'
7
7
 
8
8
  desc 'Default: run the specs.'
9
- task :default => :spec
9
+ task default: :spec
10
10
 
11
11
  # I don't want to depend on bundler, so we do it the bundler way without it
12
12
  gemspec_path = 'mrpin-rocketamf.gemspec'
13
- spec = begin
13
+ spec = begin
14
14
  eval(File.read(File.join(File.dirname(__FILE__), gemspec_path)), TOPLEVEL_BINDING, gemspec_path)
15
15
  rescue LoadError => e
16
16
  original_line = e.backtrace.find { |line| line.include?(gemspec_path) }
17
- msg = "There was a LoadError while evaluating #{gemspec_path}:\n #{e.message}"
17
+ msg = "There was a LoadError while evaluating #{gemspec_path}:\n #{e.message}"
18
18
  msg << " from\n #{original_line}" if original_line
19
19
  msg << "\n"
20
20
  puts msg
@@ -28,7 +28,7 @@ desc 'Generate documentation'
28
28
  Rake::RDocTask.new(:rdoc) do |rdoc|
29
29
  rdoc.rdoc_dir = 'rdoc'
30
30
  rdoc.title = spec.name
31
- rdoc.options += spec.rdoc_options
31
+ rdoc.options += spec.rdoc_options
32
32
  rdoc.rdoc_files.include(*spec.extra_rdoc_files)
33
33
  rdoc.rdoc_files.include('lib') # Don't include ext folder because no one cares
34
34
  end
@@ -39,15 +39,15 @@ Gem::PackageTask.new(spec) do |pkg|
39
39
  end
40
40
 
41
41
  Rake::ExtensionTask.new('rocketamf_ext', spec) do |ext|
42
- if RUBY_PLATFORM =~ /mswin|mingw/ then
42
+ if RUBY_PLATFORM =~ /mswin|mingw/
43
43
  # No cross-compile on win, so compile extension to lib/1.[89]
44
44
  RUBY_VERSION =~ /(\d+\.\d+)/
45
45
  ext.lib_dir = "lib/#{$1}"
46
46
  else
47
- ext.cross_compile = true
47
+ ext.cross_compile = true
48
48
  ext.cross_platform = 'x86-mingw32'
49
49
  ext.cross_compiling do |gem_spec|
50
- gem_spec.post_install_message = "You installed the binary version of this gem!"
50
+ gem_spec.post_install_message = 'You installed the binary version of this gem!'
51
51
  end
52
52
  end
53
53
  #ext.config_options << '--enable-sort-props'
data/benchmark.rb CHANGED
@@ -6,7 +6,7 @@ require 'rocketamf/pure/deserializer' # Only ext gets included by default if ava
6
6
  require 'rocketamf/pure/serializer'
7
7
 
8
8
  OBJECT_COUNT = 100000
9
- TESTS = 5
9
+ TESTS = 5
10
10
 
11
11
  class TestClass
12
12
  attr_accessor :prop_a, :prop_b, :prop_c, :prop_d, :prop_e
@@ -28,47 +28,54 @@ OBJECT_COUNT.times do
28
28
  objs << TestClass.new.populate
29
29
  end
30
30
 
31
- ["native", "pure"].each do |type|
31
+ %w(native pure).each do |type|
32
+
33
+ use_ruby_version = type == 'pure'
34
+
32
35
  # Set up class mapper
33
- cm = if type == "pure"
34
- RocketAMF::ClassMapping
36
+ class_mapper = nil
37
+
38
+ if use_ruby_version
39
+ class_mapper = RocketAMF::ClassMapping
35
40
  else
36
- RocketAMF::Ext::FastClassMapping
41
+ class_mapper = RocketAMF::Ext::FastClassMapping
37
42
  end
38
- cm.define do |m|
39
- m.map :as => 'TestClass', :ruby => 'TestClass'
43
+
44
+ class_mapper.define do |m|
45
+ m.map as: 'TestClass', ruby: 'TestClass'
40
46
  end
41
47
 
42
- [0, 3].each do |version|
43
- # 2**24 is larger than anyone is ever going to run this for
44
- min_serialize = 2**24
45
- min_deserialize = 2**24
46
-
47
- puts "Testing #{type} AMF#{version}:"
48
- TESTS.times do
49
- ser = if type == "pure"
50
- RocketAMF::Pure::Serializer.new(cm.new)
51
- else
52
- RocketAMF::Ext::Serializer.new(cm.new)
53
- end
54
- start_time = Time.now
55
- out = ser.serialize(version, objs)
56
- end_time = Time.now
57
- puts "\tserialize run: #{end_time-start_time}s"
58
- min_serialize = [end_time-start_time, min_serialize].min
59
-
60
- des = if type == "pure"
61
- RocketAMF::Pure::Deserializer.new(cm.new)
62
- else
63
- RocketAMF::Ext::Deserializer.new(cm.new)
64
- end
65
- start_time = Time.now
66
- temp = des.deserialize(version, out)
67
- end_time = Time.now
68
- puts "\tdeserialize run: #{end_time-start_time}s"
69
- min_deserialize = [end_time-start_time, min_deserialize].min
48
+
49
+ # 2**24 is larger than anyone is ever going to run this for
50
+ min_serialize = 2**24
51
+ min_deserialize = 2**24
52
+
53
+ puts "Testing #{type} AMF3"
54
+ TESTS.times do
55
+ serializer = nil
56
+ deserializer = nil
57
+
58
+ if use_ruby_version
59
+ serializer = RocketAMF::Pure::Serializer.new(class_mapper.new)
60
+ deserializer = RocketAMF::Pure::Deserializer.new(class_mapper.new)
61
+ else
62
+ serializer = RocketAMF::Ext::Serializer.new(class_mapper.new)
63
+ deserializer = RocketAMF::Ext::Deserializer.new(class_mapper.new)
70
64
  end
71
- puts "\tminimum serialize time: #{min_serialize}s"
72
- puts "\tminimum deserialize time: #{min_deserialize}s"
65
+
66
+ start_time = Time.now
67
+ out = serializer.serialize(objs)
68
+ end_time = Time.now
69
+ puts "\tserialize run: #{end_time-start_time}s"
70
+ min_serialize = [end_time-start_time, min_serialize].min
71
+
72
+ start_time = Time.now
73
+ temp = deserializer.deserialize(out)
74
+ end_time = Time.now
75
+ puts "\tdeserialize run: #{end_time-start_time}s"
76
+ min_deserialize = [end_time-start_time, min_deserialize].min
73
77
  end
78
+
79
+ puts "\tminimum serialize time: #{min_serialize}s"
80
+ puts "\tminimum deserialize time: #{min_deserialize}s"
74
81
  end
@@ -88,15 +88,15 @@ static VALUE mapset_init(VALUE self) {
88
88
  static VALUE mapset_map_defaults(VALUE self) {
89
89
  const int NUM_MAPPINGS = 9;
90
90
  const char* ruby_classes[] = {
91
- "RocketAMF::Values::AbstractMessage",
92
- "RocketAMF::Values::RemotingMessage",
93
- "RocketAMF::Values::AsyncMessage",
94
- "RocketAMF::Values::AsyncMessageExt",
95
- "RocketAMF::Values::CommandMessage",
96
- "RocketAMF::Values::CommandMessageExt",
97
- "RocketAMF::Values::AcknowledgeMessage",
98
- "RocketAMF::Values::AcknowledgeMessageExt",
99
- "RocketAMF::Values::ErrorMessage"
91
+ "RocketAMF::Types::AbstractMessage",
92
+ "RocketAMF::Types::RemotingMessage",
93
+ "RocketAMF::Types::AsyncMessage",
94
+ "RocketAMF::Types::AsyncMessageExt",
95
+ "RocketAMF::Types::CommandMessage",
96
+ "RocketAMF::Types::CommandMessageExt",
97
+ "RocketAMF::Types::AcknowledgeMessage",
98
+ "RocketAMF::Types::AcknowledgeMessageExt",
99
+ "RocketAMF::Types::ErrorMessage"
100
100
  };
101
101
  const char* as_classes[] = {
102
102
  "flex.messaging.messages.AbstractMessage",
@@ -309,7 +309,7 @@ static VALUE mapping_as_class_name(VALUE self, VALUE obj) {
309
309
  *
310
310
  * Instantiates a ruby object using the mapping configuration based on the
311
311
  * source AS class name. If there is no mapping defined, it returns a
312
- * <tt>RocketAMF::Values::TypedHash</tt> with the serialized class name.
312
+ * <tt>RocketAMF::Types::TypedHash</tt> with the serialized class name.
313
313
  */
314
314
  static VALUE mapping_get_ruby_obj(VALUE self, VALUE name) {
315
315
  CLASS_MAPPING *map;
@@ -475,7 +475,7 @@ void Init_rocket_amf_fast_class_mapping() {
475
475
  rb_define_method(cFastClassMapping, "props_for_serialization", mapping_props, 1);
476
476
 
477
477
  // Cache values
478
- cTypedHash = rb_const_get(rb_const_get(mRocketAMF, rb_intern("Values")), rb_intern("TypedHash"));
478
+ cTypedHash = rb_const_get(rb_const_get(mRocketAMF, rb_intern("Types")), rb_intern("TypedHash"));
479
479
  id_use_ac = rb_intern("use_array_collection");
480
480
  id_use_ac_ivar = rb_intern("@use_array_collection");
481
481
  id_mappings = rb_intern("mappings");
@@ -180,5 +180,5 @@ void Init_rocket_amf_remoting() {
180
180
  id_data = rb_intern("data");
181
181
  cRocketAMFHeader = rb_const_get(mRocketAMF, rb_intern("Header"));
182
182
  cRocketAMFMessage = rb_const_get(mRocketAMF, rb_intern("Message"));
183
- cRocketAMFAbstractMessage = rb_const_get(rb_const_get(mRocketAMF, rb_intern("Values")), rb_intern("AbstractMessage"));
183
+ cRocketAMFAbstractMessage = rb_const_get(rb_const_get(mRocketAMF, rb_intern("Types")), rb_intern("AbstractMessage"));
184
184
  }
data/lib/rocketamf.rb CHANGED
@@ -1,20 +1,31 @@
1
1
  $:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
2
2
  $:.unshift "#{File.expand_path(File.dirname(__FILE__))}/rocketamf/"
3
+ $:.unshift "#{File.expand_path(File.dirname(__FILE__))}/rocketamf/types/"
3
4
 
4
- require "date"
5
- require "stringio"
5
+ require 'date'
6
+ require 'stringio'
7
+ require 'rocketamf/errors'
6
8
  require 'rocketamf/extensions'
7
- require 'rocketamf/class_mapping'
9
+ require 'rocketamf/mapping/class_mapping'
8
10
  require 'rocketamf/constants'
9
- require 'rocketamf/remoting'
11
+ require 'rocketamf/types'
10
12
 
11
- # RocketAMF is a full featured AMF0/3 serializer and deserializer with support for
13
+
14
+ #todo: implement C version
15
+ # begin
16
+ # require 'rocketamf/ext'
17
+ # rescue LoadError
18
+
19
+ require 'rocketamf/pure'
20
+ # end
21
+
22
+ # MrPin RocketAMF is a full featured AMF3 serializer and deserializer with support for
12
23
  # bi-directional Flash to Ruby class mapping, custom serialization and mapping,
13
- # remoting gateway helpers that follow AMF0/3 messaging specs, and a suite of specs
24
+ # remoting gateway helpers that follow AMF3 messaging specs, and a suite of specs
14
25
  # to ensure adherence to the specification documents put out by Adobe. If the C
15
26
  # components compile, then RocketAMF automatically takes advantage of them to
16
27
  # provide a substantial performance benefit. In addition, RocketAMF is fully
17
- # compatible with Ruby 1.9.
28
+ # compatible with Ruby 2.0, 2.1.
18
29
  #
19
30
  # == Performance
20
31
  #
@@ -27,17 +38,12 @@ require 'rocketamf/remoting'
27
38
  # some benchmarks I took using using a simple little benchmarking utility I whipped
28
39
  # up, which can be found in the root of the repository.
29
40
  #
41
+ #todo:change benchmark
30
42
  # # 100000 objects
31
43
  # # Ruby 1.8
32
- # Testing native AMF0:
33
- # minimum serialize time: 1.229868s
34
- # minimum deserialize time: 0.86465s
35
44
  # Testing native AMF3:
36
45
  # minimum serialize time: 1.444652s
37
46
  # minimum deserialize time: 0.879407s
38
- # Testing pure AMF0:
39
- # minimum serialize time: 25.427931s
40
- # minimum deserialize time: 11.706084s
41
47
  # Testing pure AMF3:
42
48
  # minimum serialize time: 31.637864s
43
49
  # minimum deserialize time: 14.773969s
@@ -47,9 +53,7 @@ require 'rocketamf/remoting'
47
53
  # RocketAMF provides two main methods - <tt>serialize</tt> and <tt>deserialize</tt>.
48
54
  # Deserialization takes a String or StringIO object and the AMF version if different
49
55
  # from the default. Serialization takes any Ruby object and the version if different
50
- # from the default. Both default to AMF0, as it's more widely supported and slightly
51
- # faster, but AMF3 does a better job of not sending duplicate data. Which you choose
52
- # depends on what you need to communicate with and how much serialized size matters.
56
+ # from the default. AMF3 not sending duplicate data.
53
57
  #
54
58
  # == Mapping Classes Between Flash and Ruby
55
59
  #
@@ -60,50 +64,6 @@ require 'rocketamf/remoting'
60
64
  # replace it with a class mapper of your own devising that matches the documented
61
65
  # API.
62
66
  #
63
- # == Remoting
64
- #
65
- # You can use RocketAMF bare to write an AMF gateway using the following code.
66
- # In addition, you can use rack-amf (http://github.com/rubyamf/rack-amf) or
67
- # RubyAMF (http://github.com/rubyamf/rubyamf), both of which provide rack-compliant
68
- # AMF gateways.
69
- #
70
- # # helloworld.ru
71
- # require 'rocketamf'
72
- #
73
- # class HelloWorldApp
74
- # APPLICATION_AMF = 'application/x-amf'.freeze
75
- #
76
- # def call env
77
- # if is_amf?(env)
78
- # # Wrap request and response
79
- # env['rack.input'].rewind
80
- # request = RocketAMF::Envelope.new.populate_from_stream(env['rack.input'].read)
81
- # response = RocketAMF::Envelope.new
82
- #
83
- # # Handle request
84
- # response.each_method_call request do |method, args|
85
- # raise "Service #{method} does not exists" unless method == 'App.helloWorld'
86
- # 'Hello world'
87
- # end
88
- #
89
- # # Pass back response
90
- # response_str = response.serialize
91
- # return [200, {'Content-Type' => APPLICATION_AMF, 'Content-Length' => response_str.length.to_s}, [response_str]]
92
- # else
93
- # return [200, {'Content-Type' => 'text/plain', 'Content-Length' => '16' }, ["Rack AMF gateway"]]
94
- # end
95
- # end
96
- #
97
- # private
98
- # def is_amf? env
99
- # return false unless env['CONTENT_TYPE'] == APPLICATION_AMF
100
- # return false unless env['PATH_INFO'] == '/amf'
101
- # return true
102
- # end
103
- # end
104
- #
105
- # run HelloWorldApp.new
106
- #
107
67
  # == Advanced Serialization (encode_amf and IExternalizable)
108
68
  #
109
69
  # RocketAMF provides some additional functionality to support advanced
@@ -129,11 +89,7 @@ require 'rocketamf/remoting'
129
89
  #
130
90
  # class VariableObject
131
91
  # def encode_amf ser
132
- # if ser.version == 0
133
- # ser.serialize 0, true
134
- # else
135
- # ser.serialize 3, false
136
- # end
92
+ # ser.serialize(false)
137
93
  # end
138
94
  # end
139
95
  #
@@ -148,10 +104,6 @@ require 'rocketamf/remoting'
148
104
  #
149
105
  # class ResultSet < Array
150
106
  # def encode_amf ser
151
- # if ser.version == 0
152
- # # Serialize as simple array in AMF0
153
- # ser.write_array self
154
- # else
155
107
  # # Serialize as an ArrayCollection object
156
108
  # # It conforms to IExternalizable, does not have any dynamic properties,
157
109
  # # and has no "sealed" members. See the AMF3 specs for more details about
@@ -162,7 +114,6 @@ require 'rocketamf/remoting'
162
114
  # :dynamic => false,
163
115
  # :members => []
164
116
  # }
165
- # end
166
117
  # end
167
118
  #
168
119
  # # Write self as array to stream
@@ -176,43 +127,35 @@ require 'rocketamf/remoting'
176
127
  # end
177
128
  # end
178
129
  module RocketAMF
179
- #todo: implement C version
180
- # begin
181
- # require 'rocketamf/ext'
182
- # rescue LoadError
183
130
 
184
- require 'rocketamf/pure'
185
- # end
131
+ #
132
+ # Constants
133
+ #
134
+
135
+ #todo: use c version
136
+ CLASS_MAPPER = RocketAMF::ClassMapping
137
+
138
+ #
139
+ # Static methods
140
+ #
186
141
 
187
142
  # Deserialize the AMF string _source_ of the given AMF version into a Ruby
188
143
  # data structure and return it. Creates an instance of <tt>RocketAMF::Deserializer</tt>
189
- # with a new instance of <tt>RocketAMF::ClassMapper</tt> and calls deserialize
190
- # on it with the given source and amf version, returning the result.
191
- def self.deserialize source, amf_version = 0
192
- des = RocketAMF::Deserializer.new(RocketAMF::ClassMapper.new)
193
- des.deserialize(amf_version, source)
144
+ # with a new instance of <tt>RocketAMF::CLASS_MAPPER</tt> and calls deserialize
145
+ # on it with the given source, returning the result.
146
+ def self.deserialize(source)
147
+ deserializer = RocketAMF::Deserializer.new(RocketAMF::CLASS_MAPPER.new)
148
+ deserializer.deserialize(source)
194
149
  end
195
150
 
196
151
  # Serialize the given Ruby data structure _obj_ into an AMF stream using the
197
152
  # given AMF version. Creates an instance of <tt>RocketAMF::Serializer</tt>
198
- # with a new instance of <tt>RocketAMF::ClassMapper</tt> and calls serialize
199
- # on it with the given object and amf version, returning the result.
200
- def self.serialize obj, amf_version = 0
201
- ser = RocketAMF::Serializer.new(RocketAMF::ClassMapper.new)
202
- ser.serialize(amf_version, obj)
153
+ # with a new instance of <tt>RocketAMF::CLASS_MAPPER</tt> and calls serialize
154
+ # on it with the given object, returning the result.
155
+ def self.serialize(obj)
156
+ serializer = RocketAMF::Serializer.new(RocketAMF::CLASS_MAPPER.new)
157
+ serializer.serialize(obj)
203
158
  end
204
159
 
205
- # We use const_missing to define the active ClassMapper at runtime. This way,
206
- # heavy modification of class mapping functionality is still possible without
207
- # forcing extenders to redefine the constant.
208
- def self.const_missing const #:nodoc:
209
- if const == :ClassMapper
210
- RocketAMF.const_set(:ClassMapper, RocketAMF::ClassMapping)
211
- else
212
- super(const)
213
- end
214
- end
215
160
 
216
- # The base exception for AMF errors.
217
- class AMFError < StandardError; end
218
161
  end
@@ -20,24 +20,24 @@ module RocketAMF
20
20
  AMF0_AMF3_MARKER = 0x11 #"\021"
21
21
 
22
22
  # AMF3 Type Markers
23
- AMF3_UNDEFINED_MARKER = 0x00 #"\000"
24
- AMF3_NULL_MARKER = 0x01 #"\001"
25
- AMF3_FALSE_MARKER = 0x02 #"\002"
26
- AMF3_TRUE_MARKER = 0x03 #"\003"
27
- AMF3_INTEGER_MARKER = 0x04 #"\004"
28
- AMF3_DOUBLE_MARKER = 0x05 #"\005"
29
- AMF3_STRING_MARKER = 0x06 #"\006"
30
- AMF3_XML_DOC_MARKER = 0x07 #"\a"
31
- AMF3_DATE_MARKER = 0x08 #"\b"
32
- AMF3_ARRAY_MARKER = 0x09 #"\t"
33
- AMF3_OBJECT_MARKER = 0x0A #"\n"
34
- AMF3_XML_MARKER = 0x0B #"\v"
35
- AMF3_BYTE_ARRAY_MARKER = 0x0C #"\f"
36
- AMF3_VECTOR_INT_MARKER = 0x0D #"\r"
37
- AMF3_VECTOR_UINT_MARKER = 0x0E #"\016"
38
- AMF3_VECTOR_DOUBLE_MARKER = 0x0F #"\017"
39
- AMF3_VECTOR_OBJECT_MARKER = 0x10 #"\020"
40
- AMF3_DICT_MARKER = 0x11 #"\021"
23
+ AMF3_UNDEFINED_MARKER = 0x00 #"\000"
24
+ AMF3_NULL_MARKER = 0x01 #"\001"
25
+ AMF3_FALSE_MARKER = 0x02 #"\002"
26
+ AMF3_TRUE_MARKER = 0x03 #"\003"
27
+ AMF3_INTEGER_MARKER = 0x04 #"\004"
28
+ AMF3_DOUBLE_MARKER = 0x05 #"\005"
29
+ AMF3_STRING_MARKER = 0x06 #"\006"
30
+ AMF3_XML_DOC_MARKER = 0x07 #"\a"
31
+ AMF3_DATE_MARKER = 0x08 #"\b"
32
+ AMF3_ARRAY_MARKER = 0x09 #"\t"
33
+ AMF3_OBJECT_MARKER = 0x0A #"\n"
34
+ AMF3_XML_MARKER = 0x0B #"\v"
35
+ AMF3_BYTE_ARRAY_MARKER = 0x0C #"\f"
36
+ AMF3_VECTOR_INT_MARKER = 0x0D #"\r"
37
+ AMF3_VECTOR_UINT_MARKER = 0x0E #"\016"
38
+ AMF3_VECTOR_DOUBLE_MARKER = 0x0F #"\017"
39
+ AMF3_VECTOR_OBJECT_MARKER = 0x10 #"\020"
40
+ AMF3_DICT_MARKER = 0x11 #"\021"
41
41
 
42
42
  # Other AMF3 Markers
43
43
  AMF3_EMPTY_STRING = 0x01
@@ -45,6 +45,6 @@ module RocketAMF
45
45
  AMF3_CLOSE_DYNAMIC_ARRAY = 0x01
46
46
 
47
47
  # Other Constants
48
- MAX_INTEGER = 268435455
49
- MIN_INTEGER = -268435456
48
+ MAX_INTEGER = 268_435_455
49
+ MIN_INTEGER = -268_435_456
50
50
  end