lib/picky/indexers/serial.rb in picky-2.7.0 vs lib/picky/indexers/serial.rb in picky-3.0.0.pre1
- old
+ new
@@ -1,55 +1,59 @@
# encoding: utf-8
#
-module Indexers
+module Picky
- # Uses a category to index its data.
- #
- # Note: It is called serial since it indexes each category separately.
- #
- class Serial < Base
+ module Indexers
- # Harvest the data from the source, tokenize,
- # and write to an intermediate "prepared index" file.
+ # Uses a category to index its data.
#
- # Parameters:
- # * categories: An enumerable of Category-s.
+ # Note: It is called serial since it indexes each category separately.
#
- def process categories
- comma = ?,
- newline = ?\n
+ class Serial < Base
- categories.each do |category|
+ # Harvest the data from the source, tokenize,
+ # and write to an intermediate "prepared index" file.
+ #
+ # Parameters:
+ # * categories: An enumerable of Category-s.
+ #
+ def process categories
+ comma = ?,
+ newline = ?\n
- tokenizer = category.tokenizer
+ categories.each do |category|
- category.prepared_index_file do |file|
- result = []
+ tokenizer = category.tokenizer
- source.harvest(category) do |indexed_id, text|
- tokenizer.tokenize(text).each do |token_text|
- next unless token_text
- result << indexed_id << comma << token_text << newline
+ category.prepared_index_file do |file|
+ result = []
+
+ source.harvest(category) do |indexed_id, text|
+ tokenizer.tokenize(text).each do |token_text|
+ next unless token_text
+ result << indexed_id << comma << token_text << newline
+ end
+ file.write(result.join) && result.clear if result.size > 100_000
end
- file.write(result.join) && result.clear if result.size > 100_000
- end
- timed_exclaim %Q{"#{@index_or_category.identifier}": => #{file.path}.}
+ timed_exclaim %Q{"#{@index_or_category.identifier}": => #{file.path}.}
- file.write result.join
+ file.write result.join
+ end
+
end
end
- end
+ #
+ #
+ def start_indexing_message # :nodoc:
+ timed_exclaim %Q{"#{@index_or_category.identifier}": Starting serial data preparation.}
+ end
+ def finish_indexing_message # :nodoc:
+ timed_exclaim %Q{"#{@index_or_category.identifier}": Finished serial data preparation.}
+ end
- #
- #
- def start_indexing_message # :nodoc:
- timed_exclaim %Q{"#{@index_or_category.identifier}": Starting serial data preparation.}
end
- def finish_indexing_message # :nodoc:
- timed_exclaim %Q{"#{@index_or_category.identifier}": Finished serial data preparation.}
- end
-
end
+
end
\ No newline at end of file