lib/rmpd/commands/generators.rb in rmpd-1.0.1 vs lib/rmpd/commands/generators.rb in rmpd-1.0.2
- old
+ new
@@ -19,12 +19,25 @@
block = lambda do |*a|
if args.include?(:min_version)
server_version_at_least(*args[:min_version])
end
send_command(name.to_s.gsub(/^_*/, ""), *quote(a))
- read_responses(args[:regexp]) unless @in_command_list
+ if @in_command_list
+ append_command_list_regexp(args[:regexp])
+ else
+ read_responses(args[:regexp])
+ end
end
send(:define_method, name, &block)
+ end
+
+ def append_command_list_regexp(regexp)
+ if @in_command_list_response_regexp
+ @in_command_list_response_regexp = \
+ Regexp.union(@in_command_list_response_regexp, regexp)
+ else
+ @in_command_list_response_regexp = regexp
+ end
end
def quote(args)
args.collect {|arg| "\"#{arg.to_s.gsub(/"/, "\\\"")}\""}
end