irb.rb in amq-protocol-0.7.0.alpha6 vs irb.rb in amq-protocol-0.7.0.alpha7

- old
+ new

@@ -1,6 +1,6 @@ -#!/usr/bin/env ruby +#!/usr/bin/env bundle exec ruby # encoding: binary # This file is supposed to make inspecting AMQ protocol easier. # How does it work: @@ -39,20 +39,28 @@ irbrc = File.join(ENV["HOME"], ".irbrc") puts "~ Using #{__FILE__} as a custom .irbrc .." puts "~ Loading original #{irbrc} ..." load irbrc - file = ENV["FILE"] || "client" - require_relative "lib/amq/protocol/#{file}.rb" + # TODO: Don't generate constants in all.rb multiple + # times, then we can remove this craziness with $VERBOSE. + old_verbose, $VERBOSE = $VERBOSE, nil + begin + require_relative "lib/amq/protocol/all.rb" + rescue LoadError + abort "File lib/amq/protocol/all.rb doesn't exist! You have to generate it using ./tasks.rb generate --targets=all, executed from the root of AMQ Protocol repository." + end + $VERBOSE = old_verbose + include AMQ::Protocol begin - require "amq/client/io/string" + require "amq/client/framing/string/frame" class AMQ::Protocol::Frame def self.decode(string) - AMQ::Client::StringAdapter::Frame.decode(string) + AMQ::Client::Framing::String::Frame.decode(string) end end rescue LoadError warn "~ AMQ Client isn't available." end @@ -68,14 +76,23 @@ end end << self[offset..-1] end end - require "stringio" - def fd(data) - Frame.decode(StringIO.new(data)) + Frame.decode(data) end + + puts <<-EOF + +This is an AMQP #{AMQ::Protocol::PROTOCOL_VERSION} console. You can: + + - Decode data via: fd(frame_data). + - Encode data using AMQP classes directly: + frame = Connection::Open.encode("/") + frame.encode + + EOF rescue Exception => exception # it just discards all the exceptions! abort exception.message + "\n - " + exception.backtrace.join("\n - ") end end