birddog 0.0.9.p1 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/birddog/birddog.rb +1 -1
- data/lib/birddog/field_conditions.rb +12 -18
- data/lib/birddog/version.rb +1 -1
- data/specs/birddog_spec.rb +5 -0
- metadata +23 -20
data/lib/birddog/birddog.rb
CHANGED
@@ -188,7 +188,7 @@ module Birddog
|
|
188
188
|
|
189
189
|
case field[:type]
|
190
190
|
when :string then
|
191
|
-
conditions_for_string_search(current_scope, field,
|
191
|
+
conditions_for_string_search(current_scope, field, value)
|
192
192
|
when :float, :decimal, :integer then
|
193
193
|
conditions_for_numeric(current_scope, field, condition, value, field[:type])
|
194
194
|
when :date, :datetime, :time then
|
@@ -2,25 +2,19 @@ module Birddog
|
|
2
2
|
|
3
3
|
module FieldConditions
|
4
4
|
|
5
|
-
def conditions_for_string_search(current_scope, field,
|
6
|
-
search_con =
|
7
|
-
|
8
|
-
value_to_search = (value ? value.dup : nil)
|
5
|
+
def conditions_for_string_search(current_scope, field, value)
|
6
|
+
search_con = "=~"
|
7
|
+
value_to_search = value.dup
|
9
8
|
|
10
|
-
if
|
11
|
-
|
12
|
-
|
13
|
-
value_to_search = "%#{value_to_search}%"
|
14
|
-
end
|
9
|
+
if field[:match_substring]
|
10
|
+
value_to_search = "%#{value_to_search}%"
|
11
|
+
end
|
15
12
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
search_con = "=~"
|
22
|
-
value_to_search.gsub!(/[\*]/, "%")
|
23
|
-
end
|
13
|
+
if field[:regex] && regexed?(value)
|
14
|
+
# TODO check db driver to determine regex operator for DB (current is Postgres)
|
15
|
+
value_to_search = value[1..value.size-2]
|
16
|
+
elsif field[:wildcard] && value_to_search.include?("*")
|
17
|
+
value_to_search.gsub!(/[\*]/, "%")
|
24
18
|
end
|
25
19
|
|
26
20
|
conditionally_scoped(current_scope, field[:attribute], search_con, value_to_search, field[:aggregate])
|
@@ -60,7 +54,7 @@ module Birddog
|
|
60
54
|
current_scope.__send__(having_or_where, field.lteq(value))
|
61
55
|
when :>=, ">=", "=>" then
|
62
56
|
current_scope.__send__(having_or_where, field.gteq(value))
|
63
|
-
when "="
|
57
|
+
when "=" then
|
64
58
|
current_scope.__send__(having_or_where, field.eq(value))
|
65
59
|
else
|
66
60
|
raise "#{condition} not defined for #{field}"
|
data/lib/birddog/version.rb
CHANGED
data/specs/birddog_spec.rb
CHANGED
@@ -36,6 +36,11 @@ describe Birddog::Birddog do ####################
|
|
36
36
|
User.scopes_for_query("last_name:Doe").size.must_equal(1)
|
37
37
|
end
|
38
38
|
|
39
|
+
it "can find using case insensitive search" do
|
40
|
+
User.scopes_for_query("insensitive_last_name:doe").must_include(@john)
|
41
|
+
User.scopes_for_query("insensitive_last_name:doe").size.must_equal(1)
|
42
|
+
end
|
43
|
+
|
39
44
|
it "can find matching substrings" do
|
40
45
|
User.scopes_for_query("substringed_last_name:oe").must_include(@john)
|
41
46
|
User.scopes_for_query("substringed_last_name:oe").size.must_equal(1)
|
metadata
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: birddog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.9
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.9
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Brandon Dewitt
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-03-
|
12
|
+
date: 2012-03-04 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|
16
|
-
requirement: &
|
16
|
+
requirement: &11416560 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *11416560
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &11415800 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *11415800
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: sqlite3-ruby
|
38
|
-
requirement: &
|
38
|
+
requirement: &11415160 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *11415160
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: pry
|
49
|
-
requirement: &
|
49
|
+
requirement: &11414280 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *11414280
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: chronic
|
60
|
-
requirement: &
|
60
|
+
requirement: &11413760 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *11413760
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: activerecord
|
71
|
-
requirement: &
|
71
|
+
requirement: &11413240 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *11413240
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: activesupport
|
82
|
-
requirement: &
|
82
|
+
requirement: &11399120 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,7 +87,7 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :runtime
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *11399120
|
91
91
|
description: Seeeeeeeee Readme
|
92
92
|
email:
|
93
93
|
- brandonsdewitt@gmail.com
|
@@ -129,13 +129,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
129
129
|
version: '0'
|
130
130
|
segments:
|
131
131
|
- 0
|
132
|
-
hash:
|
132
|
+
hash: 789401553101841617
|
133
133
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
134
|
none: false
|
135
135
|
requirements:
|
136
|
-
- - ! '
|
136
|
+
- - ! '>='
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version:
|
138
|
+
version: '0'
|
139
|
+
segments:
|
140
|
+
- 0
|
141
|
+
hash: 789401553101841617
|
139
142
|
requirements: []
|
140
143
|
rubyforge_project: birddog
|
141
144
|
rubygems_version: 1.8.10
|