lib/feedcellar/groonga_searcher.rb in feedcellar-0.7.0 vs lib/feedcellar/groonga_searcher.rb in feedcellar-0.7.1
- old
+ new
@@ -1,8 +1,8 @@
# class Feedcellar::GroongaSearcher
#
-# Copyright (C) 2013-2015 Masafumi Yokoyama <myokoym@gmail.com>
+# Copyright (C) 2013-2016 Masafumi Yokoyama <myokoym@gmail.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
@@ -54,12 +54,24 @@
selected_feeds = feeds.select do |feed|
expression_builder = feed
if (!words.nil? && !words.empty?)
+ or_flag = false
words.each do |word|
- expression_builder &= (feed.title =~ word) |
- (feed.description =~ word)
+ if word == "OR"
+ or_flag = true
+ next
+ end
+
+ if or_flag
+ expression_builder |= (feed.title =~ word) |
+ (feed.description =~ word)
+ or_flag = false
+ else
+ expression_builder &= (feed.title =~ word) |
+ (feed.description =~ word)
+ end
end
end
if options[:mtime]
base_date = (Time.now - (options[:mtime] * 60 * 60 * 24))