searchlogic 2.5.8 → 2.5.9
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/.gitignore +6 -0
- data/Appraisals +6 -0
- data/Gemfile +2 -10
- data/Gemfile.lock +19 -29
- data/README.rdoc +2 -0
- data/Rakefile +4 -21
- data/gemfiles/ar2.3.10.gemfile +7 -0
- data/gemfiles/ar2.3.10.gemfile.lock +28 -0
- data/gemfiles/ar2.3.11.gemfile +7 -0
- data/gemfiles/ar2.3.11.gemfile.lock +28 -0
- data/gemfiles/ar2.3.12.gemfile +7 -0
- data/gemfiles/ar2.3.12.gemfile.lock +28 -0
- data/gemfiles/ar2.3.14.gemfile +7 -0
- data/gemfiles/ar2.3.14.gemfile.lock +28 -0
- data/gemfiles/ar2.3.9.gemfile +7 -0
- data/gemfiles/ar2.3.9.gemfile.lock +28 -0
- data/lib/searchlogic.rb +2 -0
- data/lib/searchlogic/active_record/scope.rb +8 -1
- data/lib/searchlogic/named_scopes/alias_scope.rb +2 -2
- data/lib/searchlogic/named_scopes/association_conditions.rb +1 -1
- data/lib/searchlogic/named_scopes/column_conditions.rb +2 -2
- data/lib/searchlogic/search/conditions.rb +1 -1
- data/lib/searchlogic/search/method_missing.rb +1 -1
- data/lib/searchlogic/version.rb +3 -0
- data/searchlogic.gemspec +19 -79
- data/spec/searchlogic/named_scopes/alias_scope_spec.rb +7 -0
- data/spec/searchlogic/named_scopes/association_conditions_spec.rb +6 -0
- data/spec/searchlogic/named_scopes/column_conditions_spec.rb +7 -0
- data/spec/searchlogic/named_scopes/or_conditions_spec.rb +10 -0
- data/spec/spec_helper.rb +8 -11
- metadata +96 -17
data/.gitignore
ADDED
data/Appraisals
ADDED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,38 +1,28 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
searchlogic (2.5.8)
|
|
5
|
+
activerecord (~> 2.3.12)
|
|
6
|
+
activesupport (~> 2.3.12)
|
|
7
|
+
|
|
1
8
|
GEM
|
|
2
|
-
remote:
|
|
9
|
+
remote: https://rubygems.org/
|
|
3
10
|
specs:
|
|
4
|
-
activerecord (2.3.
|
|
5
|
-
activesupport (= 2.3.
|
|
6
|
-
activesupport (2.3.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
git (1.2.5)
|
|
10
|
-
jeweler (1.6.4)
|
|
11
|
-
bundler (~> 1.0)
|
|
12
|
-
git (>= 1.2.5)
|
|
11
|
+
activerecord (2.3.18)
|
|
12
|
+
activesupport (= 2.3.18)
|
|
13
|
+
activesupport (2.3.18)
|
|
14
|
+
appraisal (0.4.1)
|
|
15
|
+
bundler
|
|
13
16
|
rake
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
rspec (1.3.1)
|
|
18
|
-
ruby-debug-base19 (0.11.25)
|
|
19
|
-
columnize (>= 0.3.1)
|
|
20
|
-
linecache19 (>= 0.5.11)
|
|
21
|
-
ruby_core_source (>= 0.1.4)
|
|
22
|
-
ruby-debug19 (0.11.6)
|
|
23
|
-
columnize (>= 0.3.1)
|
|
24
|
-
linecache19 (>= 0.5.11)
|
|
25
|
-
ruby-debug-base19 (>= 0.11.19)
|
|
26
|
-
ruby_core_source (0.1.5)
|
|
27
|
-
archive-tar-minitar (>= 0.5.2)
|
|
28
|
-
sqlite3 (1.3.4)
|
|
17
|
+
rake (10.0.4)
|
|
18
|
+
rspec (1.3.2)
|
|
19
|
+
sqlite3 (1.3.7)
|
|
29
20
|
|
|
30
21
|
PLATFORMS
|
|
31
22
|
ruby
|
|
32
23
|
|
|
33
24
|
DEPENDENCIES
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
ruby-debug19
|
|
25
|
+
appraisal (= 0.4.1)
|
|
26
|
+
rspec (~> 1.3.1)
|
|
27
|
+
searchlogic!
|
|
38
28
|
sqlite3
|
data/README.rdoc
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Searchlogic makes using ActiveRecord named scopes easier and less repetitive. It helps keep your code DRY, clean, and simple.
|
|
4
4
|
|
|
5
|
+
The specs pass with ActiveRecord 2.3.9 - 2.3.14 on Ruby 1.9.3-p125, 1.9.2-p318, and 1.8.7-p358
|
|
6
|
+
|
|
5
7
|
== Helpful links
|
|
6
8
|
|
|
7
9
|
* <b>Documentation:</b> http://rdoc.info/projects/binarylogic/searchlogic
|
data/Rakefile
CHANGED
|
@@ -1,26 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
require
|
|
3
|
-
require 'bundler'
|
|
4
|
-
|
|
1
|
+
#!/usr/bin/env rake
|
|
2
|
+
require "bundler/gem_tasks"
|
|
5
3
|
Bundler.setup
|
|
6
|
-
|
|
7
|
-
begin
|
|
8
|
-
require 'jeweler'
|
|
9
|
-
Jeweler::Tasks.new do |gem|
|
|
10
|
-
gem.name = "searchlogic"
|
|
11
|
-
gem.summary = "Searchlogic makes using ActiveRecord named scopes easier and less repetitive."
|
|
12
|
-
gem.description = "Searchlogic makes using ActiveRecord named scopes easier and less repetitive."
|
|
13
|
-
gem.email = "bjohnson@binarylogic.com"
|
|
14
|
-
gem.homepage = "http://github.com/binarylogic/searchlogic"
|
|
15
|
-
gem.authors = ["Ben Johnson of Binary Logic"]
|
|
16
|
-
gem.add_bundler_dependencies
|
|
17
|
-
end
|
|
18
|
-
Jeweler::GemcutterTasks.new
|
|
19
|
-
rescue LoadError
|
|
20
|
-
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
|
21
|
-
end
|
|
22
|
-
|
|
4
|
+
require 'appraisal'
|
|
23
5
|
require 'spec/rake/spectask'
|
|
6
|
+
|
|
24
7
|
Spec::Rake::SpecTask.new(:spec) do |spec|
|
|
25
8
|
spec.libs << 'lib' << 'spec'
|
|
26
9
|
spec.spec_files = FileList['spec/**/*_spec.rb']
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: /Users/john/code/searchlogic
|
|
3
|
+
specs:
|
|
4
|
+
searchlogic (2.5.8)
|
|
5
|
+
activerecord (~> 2.3.8)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: http://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
activerecord (2.3.10)
|
|
11
|
+
activesupport (= 2.3.10)
|
|
12
|
+
activesupport (2.3.10)
|
|
13
|
+
appraisal (0.4.1)
|
|
14
|
+
bundler
|
|
15
|
+
rake
|
|
16
|
+
rake (0.9.2.2)
|
|
17
|
+
rspec (1.3.2)
|
|
18
|
+
sqlite3 (1.3.5)
|
|
19
|
+
|
|
20
|
+
PLATFORMS
|
|
21
|
+
ruby
|
|
22
|
+
|
|
23
|
+
DEPENDENCIES
|
|
24
|
+
activerecord (= 2.3.10)
|
|
25
|
+
appraisal (= 0.4.1)
|
|
26
|
+
rspec (~> 1.3.1)
|
|
27
|
+
searchlogic!
|
|
28
|
+
sqlite3
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: /Users/john/code/searchlogic
|
|
3
|
+
specs:
|
|
4
|
+
searchlogic (2.5.8)
|
|
5
|
+
activerecord (~> 2.3.8)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: http://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
activerecord (2.3.11)
|
|
11
|
+
activesupport (= 2.3.11)
|
|
12
|
+
activesupport (2.3.11)
|
|
13
|
+
appraisal (0.4.1)
|
|
14
|
+
bundler
|
|
15
|
+
rake
|
|
16
|
+
rake (0.9.2.2)
|
|
17
|
+
rspec (1.3.2)
|
|
18
|
+
sqlite3 (1.3.5)
|
|
19
|
+
|
|
20
|
+
PLATFORMS
|
|
21
|
+
ruby
|
|
22
|
+
|
|
23
|
+
DEPENDENCIES
|
|
24
|
+
activerecord (= 2.3.11)
|
|
25
|
+
appraisal (= 0.4.1)
|
|
26
|
+
rspec (~> 1.3.1)
|
|
27
|
+
searchlogic!
|
|
28
|
+
sqlite3
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: /Users/john/code/searchlogic
|
|
3
|
+
specs:
|
|
4
|
+
searchlogic (2.5.8)
|
|
5
|
+
activerecord (~> 2.3.8)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: http://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
activerecord (2.3.12)
|
|
11
|
+
activesupport (= 2.3.12)
|
|
12
|
+
activesupport (2.3.12)
|
|
13
|
+
appraisal (0.4.1)
|
|
14
|
+
bundler
|
|
15
|
+
rake
|
|
16
|
+
rake (0.9.2.2)
|
|
17
|
+
rspec (1.3.2)
|
|
18
|
+
sqlite3 (1.3.5)
|
|
19
|
+
|
|
20
|
+
PLATFORMS
|
|
21
|
+
ruby
|
|
22
|
+
|
|
23
|
+
DEPENDENCIES
|
|
24
|
+
activerecord (= 2.3.12)
|
|
25
|
+
appraisal (= 0.4.1)
|
|
26
|
+
rspec (~> 1.3.1)
|
|
27
|
+
searchlogic!
|
|
28
|
+
sqlite3
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: /Users/john/code/searchlogic
|
|
3
|
+
specs:
|
|
4
|
+
searchlogic (2.5.8)
|
|
5
|
+
activerecord (~> 2.3.8)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: http://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
activerecord (2.3.14)
|
|
11
|
+
activesupport (= 2.3.14)
|
|
12
|
+
activesupport (2.3.14)
|
|
13
|
+
appraisal (0.4.1)
|
|
14
|
+
bundler
|
|
15
|
+
rake
|
|
16
|
+
rake (0.9.2.2)
|
|
17
|
+
rspec (1.3.2)
|
|
18
|
+
sqlite3 (1.3.5)
|
|
19
|
+
|
|
20
|
+
PLATFORMS
|
|
21
|
+
ruby
|
|
22
|
+
|
|
23
|
+
DEPENDENCIES
|
|
24
|
+
activerecord (= 2.3.14)
|
|
25
|
+
appraisal (= 0.4.1)
|
|
26
|
+
rspec (~> 1.3.1)
|
|
27
|
+
searchlogic!
|
|
28
|
+
sqlite3
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: /Users/john/code/searchlogic
|
|
3
|
+
specs:
|
|
4
|
+
searchlogic (2.5.8)
|
|
5
|
+
activerecord (~> 2.3.8)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: http://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
activerecord (2.3.9)
|
|
11
|
+
activesupport (= 2.3.9)
|
|
12
|
+
activesupport (2.3.9)
|
|
13
|
+
appraisal (0.4.1)
|
|
14
|
+
bundler
|
|
15
|
+
rake
|
|
16
|
+
rake (0.9.2.2)
|
|
17
|
+
rspec (1.3.2)
|
|
18
|
+
sqlite3 (1.3.5)
|
|
19
|
+
|
|
20
|
+
PLATFORMS
|
|
21
|
+
ruby
|
|
22
|
+
|
|
23
|
+
DEPENDENCIES
|
|
24
|
+
activerecord (= 2.3.9)
|
|
25
|
+
appraisal (= 0.4.1)
|
|
26
|
+
rspec (~> 1.3.1)
|
|
27
|
+
searchlogic!
|
|
28
|
+
sqlite3
|
data/lib/searchlogic.rb
CHANGED
|
@@ -8,14 +8,21 @@ module Searchlogic
|
|
|
8
8
|
module Scope
|
|
9
9
|
def scopes
|
|
10
10
|
read_inheritable_attribute(:scopes) || write_inheritable_attribute(:scopes, {}.tap do |h|
|
|
11
|
+
|
|
12
|
+
class << h
|
|
13
|
+
attr_accessor :active_record_class
|
|
14
|
+
end
|
|
15
|
+
h.active_record_class = self
|
|
16
|
+
|
|
11
17
|
h.instance_eval <<-eval
|
|
12
18
|
def include?(key)
|
|
13
19
|
result = super
|
|
14
20
|
return result if result
|
|
15
|
-
|
|
21
|
+
active_record_class.respond_to?(key)
|
|
16
22
|
super
|
|
17
23
|
end
|
|
18
24
|
eval
|
|
25
|
+
|
|
19
26
|
end)
|
|
20
27
|
end
|
|
21
28
|
end
|
|
@@ -8,7 +8,7 @@ module Searchlogic
|
|
|
8
8
|
# or represents a named scope procedure. Ex:
|
|
9
9
|
#
|
|
10
10
|
# class User
|
|
11
|
-
# def teenager
|
|
11
|
+
# def self.teenager
|
|
12
12
|
# age_gte(13).age_lte(19)
|
|
13
13
|
# end
|
|
14
14
|
# end
|
|
@@ -37,7 +37,7 @@ module Searchlogic
|
|
|
37
37
|
define_method name do |*args|
|
|
38
38
|
case options
|
|
39
39
|
when Symbol
|
|
40
|
-
send(options)
|
|
40
|
+
send(options, *args)
|
|
41
41
|
else
|
|
42
42
|
options.call(*args)
|
|
43
43
|
end
|
|
@@ -32,7 +32,7 @@ module Searchlogic
|
|
|
32
32
|
poly_type = nil
|
|
33
33
|
condition = nil
|
|
34
34
|
|
|
35
|
-
if name_with_condition.to_s =~ /^(#{non_poly_assocs.collect(&:name).join("|")})_(\w+)$/
|
|
35
|
+
if name_with_condition.to_s =~ /^(#{non_poly_assocs.collect(&:name).join("|")})_(\w+)$/ && non_poly_assocs.present?
|
|
36
36
|
association_name = $1
|
|
37
37
|
condition = $2
|
|
38
38
|
elsif name_with_condition.to_s =~ /^(#{poly_assocs.collect(&:name).join("|")})_(\w+?)_type_(\w+)$/
|
|
@@ -59,7 +59,7 @@ module Searchlogic
|
|
|
59
59
|
|
|
60
60
|
# We want to return true for any conditions that can be called, and while we're at it. We might as well
|
|
61
61
|
# create the condition so we don't have to do it again.
|
|
62
|
-
def
|
|
62
|
+
def respond_to_missing?(*args)
|
|
63
63
|
super || (self != ::ActiveRecord::Base && !self.abstract_class? && !create_condition(args.first).blank?)
|
|
64
64
|
end
|
|
65
65
|
|
|
@@ -113,7 +113,7 @@ module Searchlogic
|
|
|
113
113
|
column = columns_hash[column_name.to_s]
|
|
114
114
|
column_type = column.type
|
|
115
115
|
skip_conversion = skip_time_zone_conversion_for_attributes.include?(column.name.to_sym)
|
|
116
|
-
match_keyword =
|
|
116
|
+
match_keyword = self.connection.adapter_name == "PostgreSQL" ? "ILIKE" : "LIKE"
|
|
117
117
|
|
|
118
118
|
scope_options = case condition.to_s
|
|
119
119
|
when /^equals/
|
data/searchlogic.gemspec
CHANGED
|
@@ -1,86 +1,26 @@
|
|
|
1
|
-
# Generated by jeweler
|
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
|
4
1
|
# -*- encoding: utf-8 -*-
|
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
|
3
|
+
require File.expand_path('../lib/searchlogic/version', __FILE__)
|
|
5
4
|
|
|
6
5
|
Gem::Specification.new do |s|
|
|
7
|
-
s.name
|
|
8
|
-
s.version
|
|
9
|
-
|
|
10
|
-
s.
|
|
11
|
-
s.
|
|
12
|
-
s.
|
|
6
|
+
s.name = "searchlogic"
|
|
7
|
+
s.version = Searchlogic::VERSION
|
|
8
|
+
s.platform = Gem::Platform::RUBY
|
|
9
|
+
s.authors = ["Ben Johnson"]
|
|
10
|
+
s.email = ["bjohnson@binarylogic.com"]
|
|
11
|
+
s.homepage = "http://github.com/binarylogic/searchlogic"
|
|
12
|
+
s.summary = %q{Searchlogic makes using ActiveRecord named scopes easier and less repetitive.}
|
|
13
13
|
s.description = %q{Searchlogic makes using ActiveRecord named scopes easier and less repetitive.}
|
|
14
|
-
s.email = %q{bjohnson@binarylogic.com}
|
|
15
|
-
s.extra_rdoc_files = [
|
|
16
|
-
"LICENSE",
|
|
17
|
-
"README.rdoc"
|
|
18
|
-
]
|
|
19
|
-
s.files = [
|
|
20
|
-
"Gemfile",
|
|
21
|
-
"Gemfile.lock",
|
|
22
|
-
"LICENSE",
|
|
23
|
-
"README.rdoc",
|
|
24
|
-
"Rakefile",
|
|
25
|
-
"VERSION.yml",
|
|
26
|
-
"init.rb",
|
|
27
|
-
"lib/searchlogic.rb",
|
|
28
|
-
"lib/searchlogic/active_record/consistency.rb",
|
|
29
|
-
"lib/searchlogic/active_record/named_scope_tools.rb",
|
|
30
|
-
"lib/searchlogic/active_record/scope.rb",
|
|
31
|
-
"lib/searchlogic/core_ext/object.rb",
|
|
32
|
-
"lib/searchlogic/core_ext/proc.rb",
|
|
33
|
-
"lib/searchlogic/named_scopes/alias_scope.rb",
|
|
34
|
-
"lib/searchlogic/named_scopes/association_conditions.rb",
|
|
35
|
-
"lib/searchlogic/named_scopes/association_ordering.rb",
|
|
36
|
-
"lib/searchlogic/named_scopes/base.rb",
|
|
37
|
-
"lib/searchlogic/named_scopes/column_conditions.rb",
|
|
38
|
-
"lib/searchlogic/named_scopes/or_conditions.rb",
|
|
39
|
-
"lib/searchlogic/named_scopes/ordering.rb",
|
|
40
|
-
"lib/searchlogic/rails_helpers.rb",
|
|
41
|
-
"lib/searchlogic/search.rb",
|
|
42
|
-
"lib/searchlogic/search/base.rb",
|
|
43
|
-
"lib/searchlogic/search/conditions.rb",
|
|
44
|
-
"lib/searchlogic/search/date_parts.rb",
|
|
45
|
-
"lib/searchlogic/search/implementation.rb",
|
|
46
|
-
"lib/searchlogic/search/method_missing.rb",
|
|
47
|
-
"lib/searchlogic/search/ordering.rb",
|
|
48
|
-
"lib/searchlogic/search/scopes.rb",
|
|
49
|
-
"lib/searchlogic/search/to_yaml.rb",
|
|
50
|
-
"lib/searchlogic/search/unknown_condition_error.rb",
|
|
51
|
-
"rails/init.rb",
|
|
52
|
-
"searchlogic.gemspec",
|
|
53
|
-
"spec/searchlogic/active_record/association_proxy_spec.rb",
|
|
54
|
-
"spec/searchlogic/active_record/consistency_spec.rb",
|
|
55
|
-
"spec/searchlogic/core_ext/object_spec.rb",
|
|
56
|
-
"spec/searchlogic/core_ext/proc_spec.rb",
|
|
57
|
-
"spec/searchlogic/named_scopes/alias_scope_spec.rb",
|
|
58
|
-
"spec/searchlogic/named_scopes/association_conditions_spec.rb",
|
|
59
|
-
"spec/searchlogic/named_scopes/association_ordering_spec.rb",
|
|
60
|
-
"spec/searchlogic/named_scopes/column_conditions_spec.rb",
|
|
61
|
-
"spec/searchlogic/named_scopes/or_conditions_spec.rb",
|
|
62
|
-
"spec/searchlogic/named_scopes/ordering_spec.rb",
|
|
63
|
-
"spec/searchlogic/search_spec.rb",
|
|
64
|
-
"spec/spec_helper.rb"
|
|
65
|
-
]
|
|
66
|
-
s.homepage = %q{http://github.com/binarylogic/searchlogic}
|
|
67
|
-
s.require_paths = [%q{lib}]
|
|
68
|
-
s.rubygems_version = %q{1.8.6}
|
|
69
|
-
s.summary = %q{Searchlogic makes using ActiveRecord named scopes easier and less repetitive.}
|
|
70
14
|
|
|
71
|
-
|
|
72
|
-
|
|
15
|
+
s.add_dependency 'activerecord', '~> 2.3.12'
|
|
16
|
+
s.add_dependency 'activesupport', '~> 2.3.12'
|
|
17
|
+
s.add_development_dependency 'rspec', '~> 1.3.1'
|
|
18
|
+
s.add_development_dependency 'sqlite3'
|
|
19
|
+
s.add_development_dependency 'appraisal', '0.4.1'
|
|
73
20
|
|
|
74
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
|
75
|
-
s.add_runtime_dependency(%q<activerecord>, ["~> 2.3.12"])
|
|
76
|
-
s.add_runtime_dependency(%q<activerecord>, ["~> 2.3.12"])
|
|
77
|
-
else
|
|
78
|
-
s.add_dependency(%q<activerecord>, ["~> 2.3.12"])
|
|
79
|
-
s.add_dependency(%q<activerecord>, ["~> 2.3.12"])
|
|
80
|
-
end
|
|
81
|
-
else
|
|
82
|
-
s.add_dependency(%q<activerecord>, ["~> 2.3.12"])
|
|
83
|
-
s.add_dependency(%q<activerecord>, ["~> 2.3.12"])
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
21
|
|
|
22
|
+
s.files = `git ls-files`.split("\n")
|
|
23
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
24
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
25
|
+
s.require_paths = ["lib"]
|
|
26
|
+
end
|
|
@@ -11,6 +11,13 @@ describe Searchlogic::NamedScopes::AliasScope do
|
|
|
11
11
|
User.username_has("bjohnson").all.should == User.find_all_by_username("bjohnson")
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
+
it "should allow alias scopes with symbols" do
|
|
15
|
+
User.alias_scope :login_has, :username_has
|
|
16
|
+
User.create(:username => "bjohnson")
|
|
17
|
+
User.create(:username => "thunt")
|
|
18
|
+
User.login_has("bjohnson").all.should == User.find_all_by_username("bjohnson")
|
|
19
|
+
end
|
|
20
|
+
|
|
14
21
|
it "should allow alias scopes from the search object" do
|
|
15
22
|
search = User.search
|
|
16
23
|
search.username_has = "bjohnson"
|
|
@@ -217,4 +217,10 @@ describe Searchlogic::NamedScopes::AssociationConditions do
|
|
|
217
217
|
user.orders.id_equals(order1.id).count.should == 1
|
|
218
218
|
user.orders.id_equals(order1.id).total_equals(2).count.should == 1
|
|
219
219
|
end
|
|
220
|
+
|
|
221
|
+
it "should allow Marshal.dump on objects that only have polymorphic associations where a polymorphic association is loaded" do
|
|
222
|
+
audit = Audit.create
|
|
223
|
+
audit.auditable = User.create
|
|
224
|
+
lambda { Marshal.dump(audit) }.should_not raise_error
|
|
225
|
+
end
|
|
220
226
|
end
|
|
@@ -26,6 +26,9 @@ describe Searchlogic::NamedScopes::ColumnConditions do
|
|
|
26
26
|
it "should have does not equal" do
|
|
27
27
|
(5..7).each { |age| User.create(:age => age) }
|
|
28
28
|
User.age_does_not_equal(6).all.should == User.find_all_by_age([5,7])
|
|
29
|
+
|
|
30
|
+
User.create!(:age => nil)
|
|
31
|
+
User.age_does_not_equal(nil).all.size.should == 3
|
|
29
32
|
end
|
|
30
33
|
|
|
31
34
|
it "should have less than" do
|
|
@@ -326,4 +329,8 @@ describe Searchlogic::NamedScopes::ColumnConditions do
|
|
|
326
329
|
count2 = User.id_ne(10).username_not_like("root").count
|
|
327
330
|
count1.should == count2
|
|
328
331
|
end
|
|
332
|
+
|
|
333
|
+
it "should produce left outer joins" do
|
|
334
|
+
User.left_outer_joins(:orders).should == [" LEFT OUTER JOIN \"orders\" ON orders.user_id = users.id "]
|
|
335
|
+
end
|
|
329
336
|
end
|
|
@@ -39,6 +39,12 @@ describe Searchlogic::NamedScopes::OrConditions do
|
|
|
39
39
|
{:conditions => "((users.username LIKE '%ben') OR (users.name LIKE '%ben')) AND ((users.age IS NOT NULL) AND ((users.id > 10) AND (users.username LIKE 'ben%')))"}
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
+
it "should work with boolean conditions" do
|
|
43
|
+
User.male_or_name_eq("susan").proxy_options.should == {:conditions => %Q{("users"."male" = 't') OR (users.name = 'susan')}}
|
|
44
|
+
User.not_male_or_name_eq("susan").proxy_options.should == {:conditions => %Q{("users"."male" = 'f') OR (users.name = 'susan')}}
|
|
45
|
+
lambda { User.male_or_name_eq("susan").all }.should_not raise_error
|
|
46
|
+
end
|
|
47
|
+
|
|
42
48
|
it "should play nice with scopes on associations" do
|
|
43
49
|
lambda { User.name_or_company_name_like("ben") }.should_not raise_error(Searchlogic::NamedScopes::OrConditions::NoConditionSpecifiedError)
|
|
44
50
|
User.name_or_company_name_like("ben").proxy_options.should == {:joins => :company, :conditions => "(users.name LIKE '%ben%') OR (companies.name LIKE '%ben%')"}
|
|
@@ -47,6 +53,10 @@ describe Searchlogic::NamedScopes::OrConditions do
|
|
|
47
53
|
Cart.user_company_name_or_user_company_name_like("ben").proxy_options.should == {:joins => {:user=>:company}, :conditions => "(companies.name LIKE '%ben%') OR (companies.name LIKE '%ben%')"}
|
|
48
54
|
end
|
|
49
55
|
|
|
56
|
+
it "should raise an error on missing condition" do
|
|
57
|
+
lambda { User.id_or_age(123) }.should raise_error(Searchlogic::NamedScopes::OrConditions::NoConditionSpecifiedError)
|
|
58
|
+
end
|
|
59
|
+
|
|
50
60
|
it "should not get confused by the 'or' in find_or_create_by_* methods" do
|
|
51
61
|
User.create(:name => "Fred")
|
|
52
62
|
User.find_or_create_by_name("Fred").should be_a_kind_of User
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
require '
|
|
3
|
-
require 'ruby-debug'
|
|
4
|
-
require "active_record"
|
|
1
|
+
Bundler.setup
|
|
2
|
+
require 'searchlogic'
|
|
5
3
|
|
|
6
4
|
ENV['TZ'] = 'UTC'
|
|
7
5
|
Time.zone = 'Eastern Time (US & Canada)'
|
|
@@ -76,9 +74,6 @@ ActiveRecord::Schema.define(:version => 1) do
|
|
|
76
74
|
end
|
|
77
75
|
end
|
|
78
76
|
|
|
79
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
80
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
81
|
-
require 'searchlogic'
|
|
82
77
|
|
|
83
78
|
Spec::Runner.configure do |config|
|
|
84
79
|
config.before(:each) do
|
|
@@ -130,9 +125,11 @@ Spec::Runner.configure do |config|
|
|
|
130
125
|
end
|
|
131
126
|
|
|
132
127
|
config.after(:each) do
|
|
133
|
-
Object
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
128
|
+
class ::Object
|
|
129
|
+
remove_const :Company rescue nil
|
|
130
|
+
remove_const :User rescue nil
|
|
131
|
+
remove_const :Order rescue nil
|
|
132
|
+
remove_const :LineItem rescue nil
|
|
133
|
+
end
|
|
137
134
|
end
|
|
138
135
|
end
|
metadata
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: searchlogic
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.5.
|
|
4
|
+
version: 2.5.9
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
8
|
-
- Ben Johnson
|
|
8
|
+
- Ben Johnson
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2013-04-05 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: activerecord
|
|
16
|
-
requirement:
|
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
|
17
17
|
none: false
|
|
18
18
|
requirements:
|
|
19
19
|
- - ~>
|
|
@@ -21,10 +21,15 @@ dependencies:
|
|
|
21
21
|
version: 2.3.12
|
|
22
22
|
type: :runtime
|
|
23
23
|
prerelease: false
|
|
24
|
-
version_requirements:
|
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
+
none: false
|
|
26
|
+
requirements:
|
|
27
|
+
- - ~>
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: 2.3.12
|
|
25
30
|
- !ruby/object:Gem::Dependency
|
|
26
|
-
name:
|
|
27
|
-
requirement:
|
|
31
|
+
name: activesupport
|
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
|
28
33
|
none: false
|
|
29
34
|
requirements:
|
|
30
35
|
- - ~>
|
|
@@ -32,21 +37,85 @@ dependencies:
|
|
|
32
37
|
version: 2.3.12
|
|
33
38
|
type: :runtime
|
|
34
39
|
prerelease: false
|
|
35
|
-
version_requirements:
|
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
41
|
+
none: false
|
|
42
|
+
requirements:
|
|
43
|
+
- - ~>
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: 2.3.12
|
|
46
|
+
- !ruby/object:Gem::Dependency
|
|
47
|
+
name: rspec
|
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
|
49
|
+
none: false
|
|
50
|
+
requirements:
|
|
51
|
+
- - ~>
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: 1.3.1
|
|
54
|
+
type: :development
|
|
55
|
+
prerelease: false
|
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
57
|
+
none: false
|
|
58
|
+
requirements:
|
|
59
|
+
- - ~>
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: 1.3.1
|
|
62
|
+
- !ruby/object:Gem::Dependency
|
|
63
|
+
name: sqlite3
|
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
|
65
|
+
none: false
|
|
66
|
+
requirements:
|
|
67
|
+
- - ! '>='
|
|
68
|
+
- !ruby/object:Gem::Version
|
|
69
|
+
version: '0'
|
|
70
|
+
type: :development
|
|
71
|
+
prerelease: false
|
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
73
|
+
none: false
|
|
74
|
+
requirements:
|
|
75
|
+
- - ! '>='
|
|
76
|
+
- !ruby/object:Gem::Version
|
|
77
|
+
version: '0'
|
|
78
|
+
- !ruby/object:Gem::Dependency
|
|
79
|
+
name: appraisal
|
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
|
81
|
+
none: false
|
|
82
|
+
requirements:
|
|
83
|
+
- - '='
|
|
84
|
+
- !ruby/object:Gem::Version
|
|
85
|
+
version: 0.4.1
|
|
86
|
+
type: :development
|
|
87
|
+
prerelease: false
|
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
89
|
+
none: false
|
|
90
|
+
requirements:
|
|
91
|
+
- - '='
|
|
92
|
+
- !ruby/object:Gem::Version
|
|
93
|
+
version: 0.4.1
|
|
36
94
|
description: Searchlogic makes using ActiveRecord named scopes easier and less repetitive.
|
|
37
|
-
email:
|
|
95
|
+
email:
|
|
96
|
+
- bjohnson@binarylogic.com
|
|
38
97
|
executables: []
|
|
39
98
|
extensions: []
|
|
40
|
-
extra_rdoc_files:
|
|
41
|
-
- LICENSE
|
|
42
|
-
- README.rdoc
|
|
99
|
+
extra_rdoc_files: []
|
|
43
100
|
files:
|
|
101
|
+
- .gitignore
|
|
102
|
+
- Appraisals
|
|
44
103
|
- Gemfile
|
|
45
104
|
- Gemfile.lock
|
|
46
105
|
- LICENSE
|
|
47
106
|
- README.rdoc
|
|
48
107
|
- Rakefile
|
|
49
108
|
- VERSION.yml
|
|
109
|
+
- gemfiles/ar2.3.10.gemfile
|
|
110
|
+
- gemfiles/ar2.3.10.gemfile.lock
|
|
111
|
+
- gemfiles/ar2.3.11.gemfile
|
|
112
|
+
- gemfiles/ar2.3.11.gemfile.lock
|
|
113
|
+
- gemfiles/ar2.3.12.gemfile
|
|
114
|
+
- gemfiles/ar2.3.12.gemfile.lock
|
|
115
|
+
- gemfiles/ar2.3.14.gemfile
|
|
116
|
+
- gemfiles/ar2.3.14.gemfile.lock
|
|
117
|
+
- gemfiles/ar2.3.9.gemfile
|
|
118
|
+
- gemfiles/ar2.3.9.gemfile.lock
|
|
50
119
|
- init.rb
|
|
51
120
|
- lib/searchlogic.rb
|
|
52
121
|
- lib/searchlogic/active_record/consistency.rb
|
|
@@ -72,6 +141,7 @@ files:
|
|
|
72
141
|
- lib/searchlogic/search/scopes.rb
|
|
73
142
|
- lib/searchlogic/search/to_yaml.rb
|
|
74
143
|
- lib/searchlogic/search/unknown_condition_error.rb
|
|
144
|
+
- lib/searchlogic/version.rb
|
|
75
145
|
- rails/init.rb
|
|
76
146
|
- searchlogic.gemspec
|
|
77
147
|
- spec/searchlogic/active_record/association_proxy_spec.rb
|
|
@@ -98,9 +168,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
98
168
|
- - ! '>='
|
|
99
169
|
- !ruby/object:Gem::Version
|
|
100
170
|
version: '0'
|
|
101
|
-
segments:
|
|
102
|
-
- 0
|
|
103
|
-
hash: -4287621832088109185
|
|
104
171
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
172
|
none: false
|
|
106
173
|
requirements:
|
|
@@ -109,8 +176,20 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
109
176
|
version: '0'
|
|
110
177
|
requirements: []
|
|
111
178
|
rubyforge_project:
|
|
112
|
-
rubygems_version: 1.8.
|
|
179
|
+
rubygems_version: 1.8.25
|
|
113
180
|
signing_key:
|
|
114
181
|
specification_version: 3
|
|
115
182
|
summary: Searchlogic makes using ActiveRecord named scopes easier and less repetitive.
|
|
116
|
-
test_files:
|
|
183
|
+
test_files:
|
|
184
|
+
- spec/searchlogic/active_record/association_proxy_spec.rb
|
|
185
|
+
- spec/searchlogic/active_record/consistency_spec.rb
|
|
186
|
+
- spec/searchlogic/core_ext/object_spec.rb
|
|
187
|
+
- spec/searchlogic/core_ext/proc_spec.rb
|
|
188
|
+
- spec/searchlogic/named_scopes/alias_scope_spec.rb
|
|
189
|
+
- spec/searchlogic/named_scopes/association_conditions_spec.rb
|
|
190
|
+
- spec/searchlogic/named_scopes/association_ordering_spec.rb
|
|
191
|
+
- spec/searchlogic/named_scopes/column_conditions_spec.rb
|
|
192
|
+
- spec/searchlogic/named_scopes/or_conditions_spec.rb
|
|
193
|
+
- spec/searchlogic/named_scopes/ordering_spec.rb
|
|
194
|
+
- spec/searchlogic/search_spec.rb
|
|
195
|
+
- spec/spec_helper.rb
|