Module: XMLPipe2

Defined in:
lib/xml_pipe2/xml_pipe2.rb,
lib/xml_pipe2/xml_schema.rb,
lib/xml_pipe2/xml_stream.rb,
lib/xml_pipe2/sphinx_conf.rb,
lib/xml_pipe2/configuration.rb,
lib/xml_pipe2/delta_indexer.rb,
lib/xml_pipe2/index_builder.rb

Defined Under Namespace

Classes: Configuration, DeltaIndexer, IndexBuilder, SphinxConf, XMLSchema, XMLStream

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#sphinx_attributesObject

Returns the value of attribute sphinx_attributes.



5
6
7
# File 'lib/xml_pipe2/xml_pipe2.rb', line 5

def sphinx_attributes
  @sphinx_attributes
end

#sphinx_index_optionsObject

Returns the value of attribute sphinx_index_options.



4
5
6
# File 'lib/xml_pipe2/xml_pipe2.rb', line 4

def sphinx_index_options
  @sphinx_index_options
end

#sphinx_indexesObject

Returns the value of attribute sphinx_indexes.



3
4
5
# File 'lib/xml_pipe2/xml_pipe2.rb', line 3

def sphinx_indexes
  @sphinx_indexes
end

Instance Method Details

#define_index(&block) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/xml_pipe2/xml_pipe2.rb', line 7

def define_index(&block)

  self.sphinx_indexes = []
  self.sphinx_attributes = []
  self.sphinx_index_options = {}

  block.call

  define_method :xml_stream do
    XMLStream.new(self).generate
  end

  define_method :index! do
    DeltaIndexer.new(self).run
  end

  class << self
    define_method :sphinx_conf do
      SphinxConf.new(self).generate
    end

    define_method :xml_schema do
      XMLSchema.new(self).generate
    end

    define_method :create_index! do
      IndexBuilder.new(self).build
    end

  end

end

#has(method, options = { }) ⇒ Object



44
45
46
# File 'lib/xml_pipe2/xml_pipe2.rb', line 44

def has method, options = { }
  self.sphinx_attributes << { method: method, options: options }
end

#index(method, options = { }) ⇒ Object



40
41
42
# File 'lib/xml_pipe2/xml_pipe2.rb', line 40

def index method, options = { }
  self.sphinx_indexes << { method: method, options: options }
end

#index_options(options = { }) ⇒ Object



48
49
50
# File 'lib/xml_pipe2/xml_pipe2.rb', line 48

def index_options options = { }
  self.sphinx_index_options = options
end

#sphinx_id(method) ⇒ Object



52
53
54
# File 'lib/xml_pipe2/xml_pipe2.rb', line 52

def sphinx_id method
  XMLStream.sphinx_id_method = method
end