Class: GroongaQueryLog::CommandVersionCompatibilityChecker::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/groonga-query-log/command-version-compatibility-checker.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeOptions

Returns a new instance of Options.



72
73
74
75
# File 'lib/groonga-query-log/command-version-compatibility-checker.rb', line 72

def initialize
  @target_version = 2
  @output_path = nil
end

Instance Attribute Details

#output_pathObject

Returns the value of attribute output_path.



71
72
73
# File 'lib/groonga-query-log/command-version-compatibility-checker.rb', line 71

def output_path
  @output_path
end

#target_versionObject

Returns the value of attribute target_version.



70
71
72
# File 'lib/groonga-query-log/command-version-compatibility-checker.rb', line 70

def target_version
  @target_version
end

Instance Method Details

#create_incompatibility_detectorObject



77
78
79
80
81
82
83
84
85
86
# File 'lib/groonga-query-log/command-version-compatibility-checker.rb', line 77

def create_incompatibility_detector
  case @target_version
  when 1
    IncompatibilityDetector::Version1.new
  when 2
    IncompatibilityDetector::Version2.new
  else
    raise ArgumentError, "Unsupported version: #{@target_version}"
  end
end

#create_output(&block) ⇒ Object



88
89
90
91
92
93
94
95
# File 'lib/groonga-query-log/command-version-compatibility-checker.rb', line 88

def create_output(&block)
  if @output_path
    FileUtils.mkdir_p(File.dirname(@output_path))
    File.open(@output_path, "w", &block)
  else
    yield($stdout)
  end
end