Class: GroongaClientModel::Test::GroongaServerRunner

Inherits:
Groonga::Client::Test::GroongaServerRunner
  • Object
show all
Defined in:
lib/groonga_client_model/test/groonga_server_runner.rb

Instance Method Summary collapse

Constructor Details

#initializeGroongaServerRunner



29
30
31
32
# File 'lib/groonga_client_model/test/groonga_server_runner.rb', line 29

def initialize
  super
  @client = Client.new
end

Instance Method Details

#runObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/groonga_client_model/test/groonga_server_runner.rb', line 34

def run
  super
  return if using_running_server?

  if defined?(Rails)
    base_dir = Rails.root
  else
    base_dir = Pathname.pwd
  end

  schema_path = base_dir + SchemaLoader.default_path
  migrate_path = base_dir + Migrator.default_search_path
  if schema_path.exist?
    schema_path.open do |schema_file|
      schema_loader = SchemaLoader.new(schema_file)
      schema_loader.load
    end
  elsif migrate_path.exist?
    output = StringIO.new
    migrator = Migrator.new(migrate_path)
    migrator.output = output
    migrator.migrate
  end
end

#urlObject



59
60
61
# File 'lib/groonga_client_model/test/groonga_server_runner.rb', line 59

def url
  @url ||= URI(@client.url)
end