Module: Client
- Defined in:
- lib/client.rb,
lib/client.rb,
lib/client.rb,
lib/client.rb,
lib/client.rb,
lib/client.rb,
lib/client.rb,
lib/client.rb,
lib/client.rb,
lib/client.rb
Overview
The Client module
Defined Under Namespace
Modules: InitializationMethods, InstanceMethods, Listenable Classes: ArgumentsParser, ChannelInitializer, Console, ModularHandler, Monitor
Class Method Summary collapse
Instance Method Summary collapse
-
#main(args = parse_arguments) ⇒ Object
rubocop: disable Metrics/AbcSize rubocop: disable Metrics/MethodLength.
-
#parse_arguments(arguments_parser = ArgumentsParser.new) ⇒ Object
class ArgumentsParser.
Class Method Details
.client_config ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/client.rb', line 24 def client_config @client_config ||= { host: '0.0.0.0', port: 8080, ssl: false, log_level: Logger::INFO, quit_commands: %i[bye cease desist exit leave quit stop terminate], max_frame_length: 8192, delimiter: Java::io.netty.handler.codec.Delimiters.lineDelimiter }.freeze end |
Instance Method Details
#main(args = parse_arguments) ⇒ Object
rubocop: disable Metrics/AbcSize rubocop: disable Metrics/MethodLength
581 582 583 584 585 586 587 588 589 590 591 592 593 594 |
# File 'lib/client.rb', line 581 def main(args = parse_arguments) Logging.log_level = args[:log_level] ::TCP::Client.new(args, ::Client::Console.new, ::Client::Monitor.new) rescue Interrupt => e warn format("\r%<class>s", class: e.class) exit rescue RuntimeError => e ::Client.log.fatal e. exit 1 rescue StandardError => e ::Client.log.fatal "Unexpected error: #{e.class}: #{e.}" e.backtrace.each { |t| log.debug t } if Logging.log_level == Logger::DEBUG exit 1 end |
#parse_arguments(arguments_parser = ArgumentsParser.new) ⇒ Object
class ArgumentsParser
534 535 536 537 538 539 540 541 542 543 544 545 |
# File 'lib/client.rb', line 534 def parse_arguments(arguments_parser = ArgumentsParser.new) arguments_parser.parser.parse!(ARGV) arguments_parser.parse_positional_arguments! arguments_parser. rescue OptionParser::InvalidArgument, OptionParser::InvalidOption, OptionParser::MissingArgument, OptionParser::NeedlessArgument => e puts e. puts parser exit rescue OptionParser::AmbiguousOption => e abort e. end |