lib/flapjack/patches.rb in flapjack-1.6.0 vs lib/flapjack/patches.rb in flapjack-2.0.0b1

- old
+ new

@@ -1,67 +1,14 @@ #!/usr/bin/env ruby -require 'thin' -require 'redis' +require 'gli' +require 'logger' -# we don't want to stop the entire EM reactor when we stop a web server -# & @connections data type changed in thin 1.5.1 -module Thin +# fix for webrick's assuming 1.8.7 Logger syntax +class ::Logger; alias_method :write, :<<; end - # see https://github.com/flapjack/flapjack/issues/169 - class Request - class EqlTempfile < ::Tempfile - def eql?(obj) - obj.equal?(self) && (obj == self) - end - end - - def move_body_to_tempfile - current_body = @body - current_body.rewind - @body = Thin::Request::EqlTempfile.new(BODY_TMPFILE) - @body.binmode - @body << current_body.read - @env[RACK_INPUT] = @body - end - end - - module Backends - class Base - def stop! - @running = false - @stopping = false - - # EventMachine.stop if EventMachine.reactor_running? - - case @connections - when Array - @connections.each { |connection| connection.close_connection } - when Hash - @connections.each_value { |connection| connection.close_connection } - end - close - end - end - end -end - -# As Redis::Future objects inherit from BasicObject, it's difficult to -# distinguish between them and other objects in collected data from -# pipelined queries. -# -# (One alternative would be to put other values in Futures ourselves, and -# evaluate everything...) -class Redis - class Future - def class - ::Redis::Future - end - end -end - -module GLI +module ::GLI class Command attr_accessor :passthrough def _action @action end @@ -83,24 +30,22 @@ arguments = parsing_result.arguments arguments = option_block_parser.parse!(arguments) parsed_command_options[command] = option_parser_factory.options_hash_with_defaults_set! - command_finder = CommandFinder.new(command.commands,command.get_default_command) + command_finder = CommandFinder.new(command.commands, :default_command => command.get_default_command) next_command_name = arguments.shift - gli_major_version, gli_minor_version = GLI::VERSION.split('.') - required_options = [command.flags, parsing_result.command, parsed_command_options[command]] - verify_required_options!(*required_options) + verify_required_options!(command.flags, command, parsed_command_options[command]) begin command = command_finder.find_command(next_command_name) rescue AmbiguousCommand arguments.unshift(next_command_name) break rescue UnknownCommand arguments.unshift(next_command_name) - # Although command finder could certainy know if it should use + # Although command finder could certainly know if it should use # the default command, it has no way to put the "unknown command" # back into the argument stack. UGH. unless command.get_default_command.nil? command = command_finder.find_command(command.get_default_command) end