feedcellar 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 51ea5cd90472416d725cd56331eed41d118068a7
4
- data.tar.gz: 49485354cc51a62bd6de68d3415d40829dd7e76d
3
+ metadata.gz: 58a404df36eb150c74d2839d8a8fd71d726a9fe9
4
+ data.tar.gz: fd4f0979f0ad248b6959c3bd7e63165f3477eaef
5
5
  SHA512:
6
- metadata.gz: 49fb61eb5b7dd8b6dd09cff3d81b8e7ba03dab46ec7e78b9b378432cea67816660edecd7c76bbef3db5dea2d39773052e8779a706955cbaf2a3078944bd05017
7
- data.tar.gz: ca2e4666fefdf69db4badd5da346fd254a45fd74d697e04b63310906c9d90a30e31edad8d7083e8514fa495de28299a5eecffea987ce41eefdacd182b7279649
6
+ metadata.gz: 16678eb5c430288bf6475f0d7c9aa420932b4c1a5651fdad40d87785441740bdbfa2a329be8cf78325898c7d16010a1206027b9c1972cbabd7c99f6644a60bc4
7
+ data.tar.gz: 9f9505a627c30efe42802a1dc0111fe943d89e82c5931f78636045ba98d0d69bb10b75018e3af9e3964768ea7ed6bdc010d308d0adf5a099a755c923d4ea42dd
data/NEWS.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # NEWS
2
2
 
3
+ ## 0.7.1: 2016-02-17
4
+
5
+ ### Changes
6
+
7
+ #### Improvements
8
+
9
+ * Supported "OR" operator.
10
+
3
11
  ## 0.7.0: 2016-02-17
4
12
 
5
13
  Speed up.
@@ -1,6 +1,6 @@
1
1
  # class Feedcellar::GroongaSearcher
2
2
  #
3
- # Copyright (C) 2013-2015 Masafumi Yokoyama <myokoym@gmail.com>
3
+ # Copyright (C) 2013-2016 Masafumi Yokoyama <myokoym@gmail.com>
4
4
  #
5
5
  # This library is free software; you can redistribute it and/or
6
6
  # modify it under the terms of the GNU Lesser General Public
@@ -56,9 +56,21 @@ module Feedcellar
56
56
  expression_builder = feed
57
57
 
58
58
  if (!words.nil? && !words.empty?)
59
+ or_flag = false
59
60
  words.each do |word|
60
- expression_builder &= (feed.title =~ word) |
61
- (feed.description =~ word)
61
+ if word == "OR"
62
+ or_flag = true
63
+ next
64
+ end
65
+
66
+ if or_flag
67
+ expression_builder |= (feed.title =~ word) |
68
+ (feed.description =~ word)
69
+ or_flag = false
70
+ else
71
+ expression_builder &= (feed.title =~ word) |
72
+ (feed.description =~ word)
73
+ end
62
74
  end
63
75
  end
64
76
 
@@ -17,5 +17,5 @@
17
17
  # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
18
 
19
19
  module Feedcellar
20
- VERSION = "0.7.0"
20
+ VERSION = "0.7.1"
21
21
  end
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # class GroongaSearcherTest
4
4
  #
5
- # Copyright (C) 2015 Masafumi Yokoyama <myokoym@gmail.com>
5
+ # Copyright (C) 2015-2016 Masafumi Yokoyama <myokoym@gmail.com>
6
6
  #
7
7
  # This library is free software; you can redistribute it and/or
8
8
  # modify it under the terms of the GNU Lesser General Public
@@ -39,24 +39,45 @@ class GroongaSearcherTest < Test::Unit::TestCase
39
39
  class SearchTest < self
40
40
  def setup
41
41
  super
42
- resource_key = "http://null.myokoym.net/rss"
43
- title = "Test"
44
- link = "http://null.myokoym.net/"
45
- description = "The site is fiction."
46
- date = Time.new(2014, 2, 5)
47
- @database.add(resource_key, title, link, description, date)
42
+ @database.add("key1",
43
+ "Title1",
44
+ "http://null.myokoym.net/1",
45
+ "The site is fiction.",
46
+ Time.new(2014, 2, 5))
47
+ @database.add("key2",
48
+ "Title2",
49
+ "http://null.myokoym.net/2",
50
+ "The site is fiction.",
51
+ Time.new(2015, 3, 6))
48
52
  end
49
53
 
50
54
  def test_all_records
51
55
  feeds = Feedcellar::GroongaSearcher.search(@database, [])
52
- assert_equal(1, feeds.size)
56
+ assert_equal(2, feeds.size)
53
57
  end
54
58
 
55
59
  def test_found
56
60
  words = []
57
61
  words << "fiction"
58
62
  feeds = Feedcellar::GroongaSearcher.search(@database, words)
59
- assert_equal(1, feeds.size)
63
+ assert_equal(2, feeds.size)
64
+ end
65
+
66
+ def test_and
67
+ words = []
68
+ words << "fiction"
69
+ words << "Title1"
70
+ feeds = Feedcellar::GroongaSearcher.search(@database, words)
71
+ assert_equal(["Title1"], feeds.map(&:title))
72
+ end
73
+
74
+ def test_or
75
+ words = []
76
+ words << "Title1"
77
+ words << "OR"
78
+ words << "Title2"
79
+ feeds = Feedcellar::GroongaSearcher.search(@database, words)
80
+ assert_equal(["Title1", "Title2"], feeds.map(&:title).sort)
60
81
  end
61
82
 
62
83
  def test_year_found
@@ -64,7 +85,7 @@ class GroongaSearcherTest < Test::Unit::TestCase
64
85
  :year => 2014,
65
86
  }
66
87
  feeds = Feedcellar::GroongaSearcher.search(@database, [], options)
67
- assert_equal(1, feeds.size)
88
+ assert_equal(["Title1"], feeds.map(&:title))
68
89
  end
69
90
 
70
91
  def test_year_not_found
@@ -73,6 +94,7 @@ class GroongaSearcherTest < Test::Unit::TestCase
73
94
  }
74
95
  feeds = Feedcellar::GroongaSearcher.search(@database, [], options)
75
96
  assert_equal(0, feeds.size)
97
+ assert_equal([], feeds.map(&:title))
76
98
  end
77
99
 
78
100
  def test_month_found
@@ -81,6 +103,7 @@ class GroongaSearcherTest < Test::Unit::TestCase
81
103
  }
82
104
  feeds = Feedcellar::GroongaSearcher.search(@database, [], options)
83
105
  assert_equal(1, feeds.size)
106
+ assert_equal(["Title1"], feeds.map(&:title))
84
107
  end
85
108
 
86
109
  def test_month_not_found
@@ -89,6 +112,7 @@ class GroongaSearcherTest < Test::Unit::TestCase
89
112
  }
90
113
  feeds = Feedcellar::GroongaSearcher.search(@database, [], options)
91
114
  assert_equal(0, feeds.size)
115
+ assert_equal([], feeds.map(&:title))
92
116
  end
93
117
 
94
118
  def test_year_and_month
@@ -97,7 +121,7 @@ class GroongaSearcherTest < Test::Unit::TestCase
97
121
  :month => 2,
98
122
  }
99
123
  feeds = Feedcellar::GroongaSearcher.search(@database, [], options)
100
- assert_equal(1, feeds.size)
124
+ assert_equal(["Title1"], feeds.map(&:title))
101
125
  end
102
126
  end
103
127
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feedcellar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masafumi Yokoyama