feedcellar 0.7.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/NEWS.md +8 -0
- data/lib/feedcellar/groonga_searcher.rb +15 -3
- data/lib/feedcellar/version.rb +1 -1
- data/test/test-groonga_searcher.rb +35 -11
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58a404df36eb150c74d2839d8a8fd71d726a9fe9
|
4
|
+
data.tar.gz: fd4f0979f0ad248b6959c3bd7e63165f3477eaef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16678eb5c430288bf6475f0d7c9aa420932b4c1a5651fdad40d87785441740bdbfa2a329be8cf78325898c7d16010a1206027b9c1972cbabd7c99f6644a60bc4
|
7
|
+
data.tar.gz: 9f9505a627c30efe42802a1dc0111fe943d89e82c5931f78636045ba98d0d69bb10b75018e3af9e3964768ea7ed6bdc010d308d0adf5a099a755c923d4ea42dd
|
data/NEWS.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# class Feedcellar::GroongaSearcher
|
2
2
|
#
|
3
|
-
# Copyright (C) 2013-
|
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
|
-
|
61
|
-
|
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
|
|
data/lib/feedcellar/version.rb
CHANGED
@@ -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
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
@database.add(
|
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(
|
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(
|
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(
|
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(
|
124
|
+
assert_equal(["Title1"], feeds.map(&:title))
|
101
125
|
end
|
102
126
|
end
|
103
127
|
end
|