amq-protocol 1.0.0.pre7 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitmodules +2 -2
- data/ChangeLog.md +23 -0
- data/LICENSE +1 -0
- data/README.md +21 -10
- data/{__init__.py → codegen/__init__.py} +0 -0
- data/{amqp_0.9.1_changes.json → codegen/amqp_0.9.1_changes.json} +0 -0
- data/{codegen.py → codegen/codegen.py} +3 -3
- data/{codegen_helpers.py → codegen/codegen_helpers.py} +0 -0
- data/{protocol.rb.pytemplate → codegen/protocol.rb.pytemplate} +4 -2
- data/generate.rb +3 -3
- data/lib/amq/protocol/client.rb +234 -97
- data/lib/amq/protocol/frame.rb +2 -1
- data/lib/amq/protocol/version.rb +1 -1
- data/lib/amq/settings.rb +132 -0
- data/spec/amq/protocol/constants_spec.rb +14 -0
- data/spec/amq/settings_spec.rb +116 -0
- metadata +66 -80
- data/irb.rb +0 -98
- data/post-processing.rb +0 -25
data/irb.rb
DELETED
@@ -1,98 +0,0 @@
|
|
1
|
-
#!/usr/bin/env bundle exec ruby
|
2
|
-
# encoding: binary
|
3
|
-
|
4
|
-
# This file is supposed to make inspecting AMQ protocol easier.
|
5
|
-
|
6
|
-
# How does it work:
|
7
|
-
# 1) This file is executed.
|
8
|
-
# 2) We load irb, redefine where IRB looks for .irbrc and start IRB.
|
9
|
-
# 3) IRB loads .irbrc, which we redefined, so it loads this file again.
|
10
|
-
# However now the second branch of "if __FILE__ == $0" gets executed,
|
11
|
-
# so it runs our custom code which loads the original .irbrc and then
|
12
|
-
# it redefines some IRB settings. In this case it add IRB hook which
|
13
|
-
# is executed after IRB is started.
|
14
|
-
|
15
|
-
# Although it looks unnecessarily complicated, I can't see any easier
|
16
|
-
# solution to this problem in case that you need to patch original settings.
|
17
|
-
# Obviously in case you don't have the need, you'll be happy with simple:
|
18
|
-
|
19
|
-
# require "irb"
|
20
|
-
#
|
21
|
-
# require_relative "lib/amq/protocol/client.rb"
|
22
|
-
# include AMQ::Protocol
|
23
|
-
#
|
24
|
-
# IRB.start(__FILE__)
|
25
|
-
|
26
|
-
require "irb"
|
27
|
-
|
28
|
-
if __FILE__ == $0
|
29
|
-
puts "~ Using #{__FILE__} as an executable ..."
|
30
|
-
|
31
|
-
|
32
|
-
def IRB.rc_file_generators
|
33
|
-
yield Proc.new { |_| __FILE__ }
|
34
|
-
end
|
35
|
-
|
36
|
-
IRB.start(__FILE__)
|
37
|
-
else
|
38
|
-
begin
|
39
|
-
irbrc = File.join(ENV["HOME"], ".irbrc")
|
40
|
-
puts "~ Using #{__FILE__} as a custom .irbrc .."
|
41
|
-
puts "~ Loading original #{irbrc} ..."
|
42
|
-
load irbrc
|
43
|
-
|
44
|
-
# TODO: Don't generate constants in all.rb multiple
|
45
|
-
# times, then we can remove this craziness with $VERBOSE.
|
46
|
-
old_verbose, $VERBOSE = $VERBOSE, nil
|
47
|
-
begin
|
48
|
-
require_relative "lib/amq/protocol/all.rb"
|
49
|
-
rescue LoadError
|
50
|
-
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."
|
51
|
-
end
|
52
|
-
$VERBOSE = old_verbose
|
53
|
-
|
54
|
-
include AMQ::Protocol
|
55
|
-
|
56
|
-
begin
|
57
|
-
require "amq/client/framing/string/frame"
|
58
|
-
|
59
|
-
class AMQ::Protocol::Frame
|
60
|
-
def self.decode(string)
|
61
|
-
AMQ::Client::Framing::String::Frame.decode(string)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
rescue LoadError
|
65
|
-
warn "~ AMQ Client isn't available."
|
66
|
-
end
|
67
|
-
|
68
|
-
# "0123456789".chunks(1, 1, 2, 3)
|
69
|
-
# => ["0", "1", "23", "456"]
|
70
|
-
class String
|
71
|
-
def chunks(*parts)
|
72
|
-
offset = 0
|
73
|
-
parts.map do |number_of_characters|
|
74
|
-
self[offset..(offset + number_of_characters - 1)].tap do
|
75
|
-
offset += number_of_characters
|
76
|
-
end
|
77
|
-
end << self[offset..-1]
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
def fd(data)
|
82
|
-
Frame.decode(data)
|
83
|
-
end
|
84
|
-
|
85
|
-
puts <<-EOF
|
86
|
-
|
87
|
-
This is an AMQP #{AMQ::Protocol::PROTOCOL_VERSION} console. You can:
|
88
|
-
|
89
|
-
- Decode data via: fd(frame_data).
|
90
|
-
- Encode data using AMQP classes directly:
|
91
|
-
frame = Connection::Open.encode("/")
|
92
|
-
frame.encode
|
93
|
-
|
94
|
-
EOF
|
95
|
-
rescue Exception => exception # it just discards all the exceptions!
|
96
|
-
abort exception.message + "\n - " + exception.backtrace.join("\n - ")
|
97
|
-
end
|
98
|
-
end
|
data/post-processing.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# encoding: utf-8
|
3
|
-
|
4
|
-
# helpers
|
5
|
-
def pass; end
|
6
|
-
|
7
|
-
# main
|
8
|
-
buffer = ARGF.inject(String.new) do |buffer, line|
|
9
|
-
# line filters
|
10
|
-
line.gsub!(/\s*\n$/, "\n")
|
11
|
-
line.gsub!("'", '"')
|
12
|
-
line.gsub!('u"', '"') if line =~ /^\s*# \[/
|
13
|
-
|
14
|
-
buffer += line
|
15
|
-
end
|
16
|
-
|
17
|
-
# buffer filters
|
18
|
-
buffer.gsub!(/\n{2,}/m, "\n\n")
|
19
|
-
pass while buffer.gsub!(/(\n( *) end)\n{2,}(\2end)/m, "\\1\n\\3")
|
20
|
-
|
21
|
-
# Make sure there's only one \n at the end
|
22
|
-
pass while buffer.chomp!
|
23
|
-
buffer += "\n"
|
24
|
-
|
25
|
-
puts buffer
|