Class: XMLPipe2::IndexBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/xml_pipe2/index_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(clazz) ⇒ IndexBuilder

Returns a new instance of IndexBuilder.



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/xml_pipe2/index_builder.rb', line 5

def initialize clazz
  @clazz = clazz

  @xml_schema = Tempfile.new('xml_schema.xml')
  @xml_schema.write(clazz.xml_schema)
  @xml_schema.close

  @sphinx_conf = Tempfile.new('sphinx.conf')
  xml_stream_path = @xml_schema.path
  @sphinx_conf.write(ERB.new(clazz.sphinx_conf).result(binding))
  @sphinx_conf.close
end

Instance Attribute Details

#clazzObject (readonly)

Returns the value of attribute clazz.



18
19
20
# File 'lib/xml_pipe2/index_builder.rb', line 18

def clazz
  @clazz
end

#sphinx_confObject (readonly)

Returns the value of attribute sphinx_conf.



18
19
20
# File 'lib/xml_pipe2/index_builder.rb', line 18

def sphinx_conf
  @sphinx_conf
end

#xml_schemaObject (readonly)

Returns the value of attribute xml_schema.



18
19
20
# File 'lib/xml_pipe2/index_builder.rb', line 18

def xml_schema
  @xml_schema
end

Instance Method Details

#buildObject



20
21
22
23
24
# File 'lib/xml_pipe2/index_builder.rb', line 20

def build
  system("$(which indexer) -c #{sphinx_conf.path} #{clazz.to_s.downcase}")
  sphinx_conf.unlink
  xml_schema.unlink
end