Class: XMLPipe2::DeltaIndexer
- Inherits:
-
Object
- Object
- XMLPipe2::DeltaIndexer
- Defined in:
- lib/xml_pipe2/delta_indexer.rb
Instance Attribute Summary collapse
-
#instance ⇒ Object
readonly
Returns the value of attribute instance.
-
#sphinx_conf ⇒ Object
readonly
Returns the value of attribute sphinx_conf.
-
#xml_stream ⇒ Object
readonly
Returns the value of attribute xml_stream.
Instance Method Summary collapse
-
#initialize(instance) ⇒ DeltaIndexer
constructor
A new instance of DeltaIndexer.
- #run ⇒ Object
Constructor Details
#initialize(instance) ⇒ DeltaIndexer
Returns a new instance of DeltaIndexer.
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/xml_pipe2/delta_indexer.rb', line 5 def initialize instance @instance = instance @xml_stream = Tempfile.new('xml_stream.xml') @xml_stream.write(instance.xml_stream) @xml_stream.close @sphinx_conf = Tempfile.new('sphinx.conf') xml_stream_path = @xml_stream.path @sphinx_conf.write(ERB.new(instance.class.sphinx_conf).result(binding)) @sphinx_conf.close end |
Instance Attribute Details
#instance ⇒ Object (readonly)
Returns the value of attribute instance.
18 19 20 |
# File 'lib/xml_pipe2/delta_indexer.rb', line 18 def instance @instance end |
#sphinx_conf ⇒ Object (readonly)
Returns the value of attribute sphinx_conf.
18 19 20 |
# File 'lib/xml_pipe2/delta_indexer.rb', line 18 def sphinx_conf @sphinx_conf end |
#xml_stream ⇒ Object (readonly)
Returns the value of attribute xml_stream.
18 19 20 |
# File 'lib/xml_pipe2/delta_indexer.rb', line 18 def xml_stream @xml_stream end |
Instance Method Details
#run ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/xml_pipe2/delta_indexer.rb', line 20 def run config = '-c ' + sphinx_conf.path index = instance.class.to_s.downcase system("$(which indexer) #{config} #{index}_delta && $(which indexer) #{config} --merge #{index} #{index}_delta --rotate") sphinx_conf.unlink xml_stream.unlink end |