class GroongaQueryLog::Command::CheckCommandVersionCompatibility

Public Class Methods

new() click to toggle source
# File lib/groonga-query-log/command/check-command-version-compatibility.rb, line 24
def initialize
  @options = CommandVersionCompatibilityChecker::Options.new
end

Public Instance Methods

run(command_line) click to toggle source
# File lib/groonga-query-log/command/check-command-version-compatibility.rb, line 28
def run(command_line)
  input_paths = create_parser.parse(command_line)
  checker = CommandVersionCompatibilityChecker.new(@options)
  checker.start do
    compatible = true
    if input_paths.empty?
      compatible = false unless checker.check($stdin)
    else
      input_paths.each do |input_path|
        File.open(input_path) do |input|
          compatible = false unless checker.check(input)
        end
      end
    end
    compatible
  end
end

Private Instance Methods

create_parser() click to toggle source
# File lib/groonga-query-log/command/check-command-version-compatibility.rb, line 47
def create_parser
  parser = OptionParser.new
  parser.version = VERSION
  parser.banner += " QUERY_LOG1 QUERY_LOG2 ..."

  parser.separator("")
  parser.separator("Options:")

  parser.on("--target-version=VERSION", Integer,
            "Check incompatibility against command version VERSION",
            "[#{@options.target_version}]") do |version|
    @options.target_version = version
  end

  parser.on("--output=PATH",
            "Output results to PATH",
            "[stdout]") do |path|
    @options.output_path = path
  end
end