ext/qparser.rb in bunny-0.7.13 vs ext/qparser.rb in bunny-0.8.0
- old
+ new
@@ -3,21 +3,18 @@
require 'json'
require 'erb'
require 'pathname'
require 'yaml'
-def spec_v8_0_0?(spec)
- spec['major'] == '8' && spec['minor'] == '0' && spec['revision'] == '0'
-end
-
def spec_details(spec)
meta = {}
meta['major'] = spec['major-version']
meta['minor'] = spec['minor-version']
- meta['revision'] = spec['revision'] || '0'
+ meta['revision'] = spec['revision']
meta['port'] = spec['port']
+ meta['ssl_port'] = spec['ssl_port']
meta['comment'] = "AMQ Protocol version #{meta['major']}.#{meta['minor']}.#{meta['revision']}"
meta
end
@@ -39,13 +36,11 @@
[frame_constants.sort, other_constants.sort]
end
def domain_types(spec, major, minor, revision)
# AMQP domain types
-
- # add types that may be missing in the spec version
- dt_arr = add_types(spec)
+ dt_arr = []
spec["domains"].each do |domain|
# JSON spec gives domain types as two element arrays like ["channel-id", "longstr"]
dt_arr << domain.last
end
@@ -61,16 +56,12 @@
cls_hash[:index] = amqp_class['id']
# Get fields for class
cls_hash[:fields] = fields(amqp_class) # are these amqp_class["properties"] ?
# Get methods for class
meth_arr = class_methods(amqp_class)
- # Add missing methods
- add_arr =[]
- add_arr = add_methods(spec) if cls_hash[:name] == 'queue'
- method_arr = meth_arr + add_arr
# Add array to class hash
- cls_hash[:methods] = method_arr
+ cls_hash[:methods] = meth_arr
cls_hash
end
end
# Get methods for class
@@ -100,45 +91,10 @@
field_hash
end
end
-def add_types(spec)
- spec_v8_0_0?(spec) ? ['long', 'longstr', 'octet', 'timestamp'] : []
-end
-
-def add_methods(spec)
- meth_arr = []
-
- if spec_v8_0_0?(spec)
- # Add Queue Unbind method
- meth_hash = {:name => 'unbind',
- :index => '50',
- :fields => [{:name => 'ticket', :domain => 'short'},
- {:name => 'queue', :domain => 'shortstr'},
- {:name => 'exchange', :domain => 'shortstr'},
- {:name => 'routing_key', :domain => 'shortstr'},
- {:name => 'arguments', :domain => 'table'}
- ]
- }
-
- meth_arr << meth_hash
-
- # Add Queue Unbind-ok method
- meth_hash = {:name => 'unbind-ok',
- :index => '51',
- :fields => []
- }
-
- meth_arr << meth_hash
- end
-
- # Return methods
- meth_arr
-
-end
-
def convert_type(name)
type_arr = @type_conversion.select {|k,v| k == name}.flatten
end
# Start of Main program
@@ -217,11 +173,11 @@
spec_rb = File.open(CONFIG[:spec_out], 'w')
spec_rb.puts(
ERB.new(%q[
# encoding: utf-8
-
+
#:stopdoc:
# this file was autogenerated on <%= Time.now.to_s %>
# using <%= specfile.ljust(16) %> (mtime: <%= File.mtime(specpath) %>)
#
# DO NOT EDIT! (edit ext/qparser.rb and config.yml instead, and run 'ruby qparser.rb')
@@ -231,10 +187,11 @@
HEADER = "AMQP".freeze
VERSION_MAJOR = <%= spec_info['major'] %>
VERSION_MINOR = <%= spec_info['minor'] %>
REVISION = <%= spec_info['revision'] %>
PORT = <%= spec_info['port'] %>
+ SSL_PORT = <%= spec_info['ssl_port'] %>
RESPONSES = {
<%- other_constants.each do |value, name| -%>
<%= value %> => :<%= name.gsub(/\s|-/, '_').upcase -%>,
<%- end -%>
@@ -367,11 +324,11 @@
frame_rb = File.open(CONFIG[:frame_out], 'w')
frame_rb.puts(
ERB.new(%q[
# encoding: utf-8
-
+
#:stopdoc:
# this file was autogenerated on <%= Time.now.to_s %>
#
# DO NOT EDIT! (edit ext/qparser.rb and config.yml instead, and run 'ruby qparser.rb')
@@ -416,13 +373,13 @@
[ :id, :channel, :payload ].inject(true) do |eql, field|
eql and __send__(field) == frame.__send__(field)
end
end
- def self.parse buf
+ def self.parse(buf, cancellator = nil)
buf = Transport::Buffer.new(buf) unless buf.is_a? Transport::Buffer
buf.extract do
- id, channel, payload, footer = buf.read(:octet, :short, :longstr, :octet)
+ id, channel, payload, footer = buf.read(cancellator, :octet, :short, :longstr, :octet)
Qrack::Transport.const_get(@types[id]).new(payload, channel) if footer == FOOTER
end
end
end