module RCI::Commands

Constants

COMMANDS_WITH_SUBCOMMANDS

As of Redis 3.0 there isn’t any indication from the COMMAND return info as to which commands accept a subcommand so we’re tracking them here

Command

Attributes

commands[R]
read_command_names[R]
read_commands[R]

Public Class Methods

command_type(command_array) click to toggle source
# File lib/rci/commands.rb, line 17
def self.command_type(command_array)
  @read_command_names.include?(command_array.first) ? :read : :write
end
discover!(client) click to toggle source
# File lib/rci/commands.rb, line 21
def self.discover!(client)
  return @commands if @commands
  @commands = client.command.map{ |command_description|
    command_name = command_description.shift.to_sym
    Command.new(command_name, *command_description)
  }
  @read_commands = @commands.select { |command| command.flags.include?('readonly') }
  @read_command_names = @read_commands.map(&:name).to_set
  @commands
end
extract_command(command_array) click to toggle source
# File lib/rci/commands.rb, line 32
def self.extract_command(command_array)
  command = command_array[0]
  info = {command: command}
  if COMMANDS_WITH_SUBCOMMANDS.include?(command)
    subcommand = command_array[1]
    info[:subcommand] = subcommand unless subcommand.nil?
  end
  info
end