keyword_search 1.4.1 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,36 +0,0 @@
1
- = HEAD
2
-
3
- * codahale: Added support for ()-based grouping: name:(frank "mr. buttons" jim) #=> ["frank", "mr. buttons", "jim"]
4
-
5
- = 1.3.1 / 2007-10-09
6
-
7
- * Tests/README update for case sensitivity change
8
-
9
- = 1.3.0 / 2007-10-09
10
-
11
- * Conversion to Ragel-based parser (faster, less resource-intensive)
12
- * Better support for other character sets, allow apostrophes in unquoted words
13
- * Test suite now uses test/spec
14
- * API is almost backwards compatible (though keywords/values are now case sensitive; downcase the input manually if you want the old behavior)
15
-
16
- = 1.2.0 / 2007-05-09
17
-
18
- * Raises KeywordSearch::ParseError instead of returning an empty Hash if an error occurs during parsing
19
-
20
- = 1.1.0 / 2007-03-21
21
-
22
- * Updated to use Dhaka 2.1.0
23
-
24
- = 1.0.5 / 2007-01-29
25
-
26
- * Added single quoting support and nested quotes (apostrophes, etc)
27
- * Added a few more punctuation marks as valid input
28
-
29
- = 1.0.4 / 2007-01-15
30
-
31
- * Updated Dhaka dependency to lock to version 0.0.6 due to breakage of backwards compatibility in 1.0.0.
32
- Will update to allow 1.0.0+ once changes to Dhaka API stabilize (thanks to Dhaka author Mushfeq Khan for the tip)
33
-
34
- == 1.0.0 / 2007-01-08
35
-
36
- * Initial release
@@ -1,125 +0,0 @@
1
- # Keyword Search
2
-
3
- ## Description
4
-
5
- Generic library to parse GMail-style search strings for keyword/value pairs;
6
- supports definition of valid keywords and handling of quoted values.
7
-
8
- ## Requirements
9
-
10
- None.
11
-
12
- ## Features
13
-
14
- The library features a very simple, easy-to-use API.
15
-
16
- * Define handlers for supported keywords with blocks
17
- * Define the default keyword (values not part of a keyword/value pair)
18
- * Handle negation
19
-
20
- Please see the example provided below.
21
-
22
- ## Synopsis
23
-
24
- Here's an example using ActiveRecord (though the library is generic, and can
25
- be used for any Ruby project). The library isn't limited to search terms, as
26
- shown in this example; how you use it is up to you.
27
-
28
- First, let's build up some variables we'll be populating for a SQL query.
29
-
30
- clauses = []
31
- arguments = []
32
-
33
- Now let's set an example string to parse. Presumably you'd get this from
34
- a form (ie, `params[:terms]`) or some other form of input.
35
-
36
- terms = 'account has:attachment since:2006-12-03 -description:crazy'
37
-
38
- Now let's do the search, defining the handlers to deal with each keyword.
39
-
40
- KeywordSearch.search(terms) do |with|
41
-
42
- # This sets the keyword handler for bare words in the string,
43
- # ie "account" in our example search terms
44
- with.default_keyword :title
45
-
46
- # Here's what we do when we encounter a "title" keyword
47
- with.keyword :title do |values|
48
- clauses << "title like ?"
49
- arguments << "%#{values.join(' ')}%"
50
- end
51
-
52
- # For "has," we check the value provided (and only support "attachment")
53
- with.keyword :has do |values|
54
- clauses << 'has_attachment = true' if values.include?('attachment')
55
- end
56
-
57
- # Here we do some date parsing
58
- with.keyword :since do |values|
59
- date = Date.parse(values.first) # only support one
60
- clauses << 'created_on >= ?'
61
- arguments << date.to_s
62
- end
63
-
64
- # If a second parameter is defined for a block, you can handle negation.
65
- # In this example, we don't want results whose description includes
66
- # the word "crazy"
67
- with.keyword :description do |values, positive|
68
- clauses << "description #{'not' unless positive} like ?"
69
- arguments << "%#{values.join(' ')}%"
70
- end
71
-
72
- end
73
-
74
- Immediately after the block is defined, the string is parsed and handlers
75
- fire. Due to the magic of closures, we now have populated variables we can
76
- use to build a real SQL query.
77
-
78
- query = clauses.map { |c| "(#{c})" }.join(' AND ')
79
- conditions = [query, *arguments]
80
- results = Message.all(:conditions => conditions)
81
-
82
- ## Installation
83
-
84
- keyword_search is only released on gemcutter. To install, you can setup gemcutter as your default gem source.
85
-
86
- $ gem install gemcutter
87
- $ gem tumble
88
-
89
- Then you can install it:
90
-
91
- $ gem install keyword_search
92
-
93
- You can also just get it in one line:
94
-
95
- $ gem install keyword_search -s http://gemcutter.org
96
-
97
-
98
- ## License
99
-
100
- (The MIT License)
101
-
102
- Copyright (c) 2007 Bruce Williams
103
-
104
- Permission is hereby granted, free of charge, to any person obtaining
105
- a copy of this software and associated documentation files (the
106
- 'Software'), to deal in the Software without restriction, including
107
- without limitation the rights to use, copy, modify, merge, publish,
108
- distribute, sublicense, and/or sell copies of the Software, and to
109
- permit persons to whom the Software is furnished to do so, subject to
110
- the following conditions:
111
-
112
- The above copyright notice and this permission notice shall be
113
- included in all copies or substantial portions of the Software.
114
-
115
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
116
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
117
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
118
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
119
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
120
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
121
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
122
-
123
- ## Legal Notes
124
-
125
- GMail is copyright Google, Inc.
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 1.4.1