query_string_filter 0.1.5 → 0.1.6
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/VERSION +1 -1
- data/lib/filter.treetop +37 -7
- data/query_string_filter.gemspec +2 -2
- data/spec/query_string_filter_spec.rb +12 -0
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.6
|
data/lib/filter.treetop
CHANGED
@@ -16,17 +16,43 @@ grammar Filter
|
|
16
16
|
rule simple
|
17
17
|
fuzzy / equality / inequality
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
rule fuzzy
|
21
|
+
fuzzy_with_strings / fuzzy_with_string
|
22
|
+
end
|
23
|
+
|
24
|
+
rule fuzzy_with_strings
|
21
25
|
key ospace ':' ospace strings
|
22
26
|
{
|
23
27
|
def eval
|
24
|
-
{ key.eval => /#{strings.eval}/ }
|
28
|
+
{ key.eval => /#{strings.eval('|')}/ }
|
25
29
|
end
|
26
30
|
}
|
27
31
|
end
|
28
|
-
|
32
|
+
|
33
|
+
rule fuzzy_with_string
|
34
|
+
key ospace ':' ospace string
|
35
|
+
{
|
36
|
+
def eval
|
37
|
+
{ key.eval => /#{string.eval}/ }
|
38
|
+
end
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
29
42
|
rule equality
|
43
|
+
equality_with_strings / equality_with_value
|
44
|
+
end
|
45
|
+
|
46
|
+
rule equality_with_strings
|
47
|
+
key ospace '=' ospace strings
|
48
|
+
{
|
49
|
+
def eval
|
50
|
+
{ key.eval => strings.eval(',') }
|
51
|
+
end
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
rule equality_with_value
|
30
56
|
key ospace '=' ospace value
|
31
57
|
{
|
32
58
|
def eval
|
@@ -39,6 +65,7 @@ grammar Filter
|
|
39
65
|
gt / gte / lt / lte
|
40
66
|
end
|
41
67
|
|
68
|
+
# greater than
|
42
69
|
rule gt
|
43
70
|
key ospace '>' ospace value
|
44
71
|
{
|
@@ -48,6 +75,7 @@ grammar Filter
|
|
48
75
|
}
|
49
76
|
end
|
50
77
|
|
78
|
+
# greater than or equal
|
51
79
|
rule gte
|
52
80
|
key ospace '>=' ospace value
|
53
81
|
{
|
@@ -57,6 +85,7 @@ grammar Filter
|
|
57
85
|
}
|
58
86
|
end
|
59
87
|
|
88
|
+
# less than
|
60
89
|
rule lt
|
61
90
|
key ospace '<' ospace value
|
62
91
|
{
|
@@ -65,7 +94,8 @@ grammar Filter
|
|
65
94
|
end
|
66
95
|
}
|
67
96
|
end
|
68
|
-
|
97
|
+
|
98
|
+
# less than or equal
|
69
99
|
rule lte
|
70
100
|
key ospace '<=' ospace value
|
71
101
|
{
|
@@ -89,10 +119,10 @@ grammar Filter
|
|
89
119
|
end
|
90
120
|
|
91
121
|
rule strings
|
92
|
-
string more:(ospace ',' ospace string)
|
122
|
+
string more:(ospace ',' ospace string)+
|
93
123
|
{
|
94
|
-
def eval
|
95
|
-
strings.map { |e| e.eval }.join(
|
124
|
+
def eval(separator)
|
125
|
+
strings.map { |e| e.eval }.join(separator)
|
96
126
|
end
|
97
127
|
|
98
128
|
def strings
|
data/query_string_filter.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{query_string_filter}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.6"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["David James"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-04-13}
|
13
13
|
s.description = %q{Convert a filter param in a query string to a conditions hash useful for MongoMapper searching}
|
14
14
|
s.email = %q{djames@sunlightfoundation.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -131,6 +131,18 @@ describe "QueryStringFilter" do
|
|
131
131
|
end
|
132
132
|
|
133
133
|
describe "compound" do
|
134
|
+
it "= with 2 strings" do
|
135
|
+
expected = {
|
136
|
+
"title" => 'election,texas'
|
137
|
+
}
|
138
|
+
[
|
139
|
+
"title=election,texas",
|
140
|
+
"title = election , texas"
|
141
|
+
].each do |s|
|
142
|
+
@filter.parse(s).should == expected
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
134
146
|
it ": with 2 strings" do
|
135
147
|
expected = {
|
136
148
|
"title" => /election|texas/
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 6
|
9
|
+
version: 0.1.6
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- David James
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-04-13 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|