Class: GroongaClientModel::SchemaLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/groonga_client_model/schema_loader.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(schema) ⇒ SchemaLoader

Returns a new instance of SchemaLoader.



27
28
29
# File 'lib/groonga_client_model/schema_loader.rb', line 27

def initialize(schema)
  @schema = schema
end

Class Method Details

.default_pathObject



22
23
24
# File 'lib/groonga_client_model/schema_loader.rb', line 22

def default_path
  "db/schema.grn"
end

Instance Method Details

#loadObject



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/groonga_client_model/schema_loader.rb', line 31

def load
  Client.open do |client|
    parser = Groonga::Command::Parser.new
    parser.on_command do |command|
      client.execute(command)
    end
    @schema.each_line do |line|
      parser << line
    end
    parser.finish
  end
end