keyword_search 1.3.0 → 1.3.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.
- data/History.txt +6 -3
- data/README.txt +3 -5
- data/Rakefile +1 -1
- data/lib/keyword_search.rb +32 -16
- data/test/test_keyword_search.rb +24 -0
- metadata +2 -2
data/History.txt
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
= 1.3.1 / 2007-10-09
|
|
2
|
+
|
|
3
|
+
* Tests/README update for case sensitivity change
|
|
4
|
+
|
|
1
5
|
= 1.3.0 / 2007-10-09
|
|
2
6
|
|
|
3
7
|
* Conversion to Ragel-based parser (faster, less resource-intensive)
|
|
4
|
-
* Better support for other character sets, allow apostrophes in
|
|
5
|
-
unquoted words
|
|
8
|
+
* Better support for other character sets, allow apostrophes in unquoted words
|
|
6
9
|
* Test suite now uses test/spec
|
|
7
|
-
* API
|
|
10
|
+
* API is almost backwards compatible (though keywords/values are now case sensitive; downcase the input manually if you want the old behavior)
|
|
8
11
|
|
|
9
12
|
= 1.2.0 / 2007-05-09
|
|
10
13
|
|
data/README.txt
CHANGED
|
@@ -6,19 +6,17 @@ keyword_search
|
|
|
6
6
|
|
|
7
7
|
Generic library to parse GMail-style search strings for keyword/value pairs; supports definition of valid keywords and handling of quoted values.
|
|
8
8
|
|
|
9
|
-
== FEATURES
|
|
9
|
+
== FEATURES:
|
|
10
10
|
|
|
11
11
|
The library features a very simple, easy-to-use API.
|
|
12
12
|
* Define handlers for supported keywords with blocks
|
|
13
13
|
* Define the default keyword (values not part of a keyword/value pair)
|
|
14
14
|
|
|
15
|
-
Various notes:
|
|
16
|
-
* Quoted values are supported.
|
|
17
|
-
* Input is automatically downcased (both keywords and values should be assumed to be in lowercase)
|
|
18
|
-
|
|
19
15
|
Development Roadmap:
|
|
20
16
|
2.0:: Add negation and grouping (will break API backwards compatibility)
|
|
21
17
|
|
|
18
|
+
Note:: As of 1.3.0, input to KeywordSearch.search is no longer automatically downcased, allowing for case sensitive keyword and value pairs. If you want case insensitivity, downcase the input before you invoke the method.
|
|
19
|
+
|
|
22
20
|
== SYNOPSIS:
|
|
23
21
|
|
|
24
22
|
Here's an example of usage from Rails (though the library is generic, and could presumably be used for any Ruby project)
|
data/Rakefile
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
require 'rubygems'
|
|
4
4
|
require 'hoe'
|
|
5
5
|
|
|
6
|
-
Hoe.new('keyword_search', '1.3.
|
|
6
|
+
Hoe.new('keyword_search', '1.3.1') do |p|
|
|
7
7
|
p.rubyforge_name = 'codefluency'
|
|
8
8
|
p.summary = 'Generic support for extracting GMail-style search keywords/values from strings'
|
|
9
9
|
p.description = p.paragraphs_of('README.txt', 2..5).join("\n\n")
|
data/lib/keyword_search.rb
CHANGED
|
@@ -7,7 +7,8 @@ module KeywordSearch
|
|
|
7
7
|
|
|
8
8
|
class << self
|
|
9
9
|
|
|
10
|
-
# line
|
|
10
|
+
# line 48 "lib/keyword_search.rl"
|
|
11
|
+
|
|
11
12
|
|
|
12
13
|
def search(input_string, definition=nil, &block)
|
|
13
14
|
definition ||= Definition.new(&block)
|
|
@@ -31,8 +32,9 @@ class << self
|
|
|
31
32
|
private :_parser_actions, :_parser_actions=
|
|
32
33
|
end
|
|
33
34
|
self._parser_actions = [
|
|
34
|
-
0, 1, 3, 1,
|
|
35
|
-
2, 1, 0
|
|
35
|
+
0, 1, 3, 1, 5, 1, 6, 2,
|
|
36
|
+
0, 2, 2, 1, 0, 3, 0, 2,
|
|
37
|
+
4, 3, 1, 0, 4
|
|
36
38
|
]
|
|
37
39
|
|
|
38
40
|
class << self
|
|
@@ -97,9 +99,9 @@ class << self
|
|
|
97
99
|
private :_parser_trans_actions_wi, :_parser_trans_actions_wi=
|
|
98
100
|
end
|
|
99
101
|
self._parser_trans_actions_wi = [
|
|
100
|
-
5,
|
|
101
|
-
0, 0, 0,
|
|
102
|
-
0, 0, 0,
|
|
102
|
+
7, 5, 13, 13, 5, 7, 1, 0,
|
|
103
|
+
0, 0, 0, 17, 17, 0, 10, 1,
|
|
104
|
+
0, 0, 0, 3, 0, 1, 0, 3,
|
|
103
105
|
0, 1, 0, 0, 0, 0
|
|
104
106
|
]
|
|
105
107
|
|
|
@@ -121,22 +123,23 @@ class << self
|
|
|
121
123
|
end
|
|
122
124
|
self.parser_en_main = 1;
|
|
123
125
|
|
|
124
|
-
# line
|
|
126
|
+
# line 66 "lib/keyword_search.rl"
|
|
125
127
|
p = 0
|
|
126
128
|
pe = data.length
|
|
127
129
|
key = nil
|
|
128
130
|
tokstart = nil
|
|
129
131
|
results = {}
|
|
132
|
+
quotes = 0
|
|
130
133
|
|
|
131
|
-
# line
|
|
134
|
+
# line 135 "lib/keyword_search.rb"
|
|
132
135
|
begin
|
|
133
136
|
p ||= 0
|
|
134
137
|
pe ||= data.length
|
|
135
138
|
cs = parser_start
|
|
136
139
|
end
|
|
137
|
-
# line
|
|
140
|
+
# line 73 "lib/keyword_search.rl"
|
|
138
141
|
|
|
139
|
-
# line
|
|
142
|
+
# line 143 "lib/keyword_search.rb"
|
|
140
143
|
begin
|
|
141
144
|
_klen, _trans, _keys, _acts, _nacts = nil
|
|
142
145
|
if p != pe
|
|
@@ -235,11 +238,21 @@ when 3:
|
|
|
235
238
|
end
|
|
236
239
|
# line 26 "lib/keyword_search.rl"
|
|
237
240
|
when 4:
|
|
238
|
-
# line
|
|
241
|
+
# line 32 "lib/keyword_search.rl"
|
|
242
|
+
begin
|
|
243
|
+
quotes += 1 end
|
|
244
|
+
# line 32 "lib/keyword_search.rl"
|
|
245
|
+
when 5:
|
|
246
|
+
# line 34 "lib/keyword_search.rl"
|
|
247
|
+
begin
|
|
248
|
+
quotes -= 1 end
|
|
249
|
+
# line 34 "lib/keyword_search.rl"
|
|
250
|
+
when 6:
|
|
251
|
+
# line 46 "lib/keyword_search.rl"
|
|
239
252
|
begin
|
|
240
253
|
raise ParseError, "At offset #{p}, near: '#{data[p,10]}'" end
|
|
241
|
-
# line
|
|
242
|
-
# line
|
|
254
|
+
# line 46 "lib/keyword_search.rl"
|
|
255
|
+
# line 256 "lib/keyword_search.rb"
|
|
243
256
|
end # action switch
|
|
244
257
|
end
|
|
245
258
|
end while false
|
|
@@ -251,10 +264,13 @@ when 4:
|
|
|
251
264
|
end
|
|
252
265
|
end
|
|
253
266
|
end
|
|
254
|
-
# line
|
|
267
|
+
# line 74 "lib/keyword_search.rl"
|
|
255
268
|
|
|
256
|
-
# line
|
|
257
|
-
# line
|
|
269
|
+
# line 270 "lib/keyword_search.rb"
|
|
270
|
+
# line 75 "lib/keyword_search.rl"
|
|
271
|
+
unless quotes.zero?
|
|
272
|
+
raise ParseError, "Unclosed quotes"
|
|
273
|
+
end
|
|
258
274
|
results
|
|
259
275
|
end
|
|
260
276
|
|
data/test/test_keyword_search.rb
CHANGED
|
@@ -176,6 +176,30 @@ context "KeywordSearch" do
|
|
|
176
176
|
end
|
|
177
177
|
end
|
|
178
178
|
end
|
|
179
|
+
|
|
180
|
+
specify "keywords are case sensitive" do
|
|
181
|
+
result = nil
|
|
182
|
+
KeywordSearch.search(%<Text:justtesting>) do |with|
|
|
183
|
+
with.keyword :text do |values|
|
|
184
|
+
result = :small
|
|
185
|
+
end
|
|
186
|
+
with.keyword :Text do |values|
|
|
187
|
+
result = :big
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
assert_equal :big, result
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
specify "values are case sensitive" do
|
|
194
|
+
result = nil
|
|
195
|
+
KeywordSearch.search(%<text:Big>) do |with|
|
|
196
|
+
with.keyword :text do |values|
|
|
197
|
+
result = values.first
|
|
198
|
+
end
|
|
199
|
+
end
|
|
200
|
+
assert_equal 'Big', result
|
|
201
|
+
end
|
|
202
|
+
|
|
179
203
|
end
|
|
180
204
|
|
|
181
205
|
|
metadata
CHANGED
|
@@ -3,7 +3,7 @@ rubygems_version: 0.9.4
|
|
|
3
3
|
specification_version: 1
|
|
4
4
|
name: keyword_search
|
|
5
5
|
version: !ruby/object:Gem::Version
|
|
6
|
-
version: 1.3.
|
|
6
|
+
version: 1.3.1
|
|
7
7
|
date: 2007-10-09 00:00:00 -05:00
|
|
8
8
|
summary: Generic support for extracting GMail-style search keywords/values from strings
|
|
9
9
|
require_paths:
|
|
@@ -11,7 +11,7 @@ require_paths:
|
|
|
11
11
|
email: bruce@codefluency.com
|
|
12
12
|
homepage: " http://codefluency.rubyforge.org/keyword_search"
|
|
13
13
|
rubyforge_project: codefluency
|
|
14
|
-
description: "== FEATURES
|
|
14
|
+
description: "== FEATURES: The library features a very simple, easy-to-use API. * Define handlers for supported keywords with blocks * Define the default keyword (values not part of a keyword/value pair) Development Roadmap: 2.0:: Add negation and grouping (will break API backwards compatibility) Note:: As of 1.3.0, input to KeywordSearch.search is no longer automatically downcased, allowing for case sensitive keyword and value pairs. If you want case insensitivity, downcase the input before you invoke the method. == SYNOPSIS:"
|
|
15
15
|
autorequire:
|
|
16
16
|
default_executable:
|
|
17
17
|
bindir: bin
|