searchlogic 2.4.32 → 2.5.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +7 -0
  3. data/.ruby-version +1 -0
  4. data/Appraisals +6 -0
  5. data/Gemfile +2 -10
  6. data/Gemfile.lock +29 -29
  7. data/README.rdoc +2 -0
  8. data/Rakefile +4 -21
  9. data/gemfiles/ar2.3.10.gemfile +7 -0
  10. data/gemfiles/ar2.3.10.gemfile.lock +28 -0
  11. data/gemfiles/ar2.3.11.gemfile +7 -0
  12. data/gemfiles/ar2.3.11.gemfile.lock +28 -0
  13. data/gemfiles/ar2.3.12.gemfile +7 -0
  14. data/gemfiles/ar2.3.12.gemfile.lock +28 -0
  15. data/gemfiles/ar2.3.14.gemfile +7 -0
  16. data/gemfiles/ar2.3.14.gemfile.lock +28 -0
  17. data/gemfiles/ar2.3.9.gemfile +7 -0
  18. data/gemfiles/ar2.3.9.gemfile.lock +28 -0
  19. data/lib/searchlogic/active_record/consistency.rb +4 -4
  20. data/lib/searchlogic/active_record/named_scope_tools.rb +7 -7
  21. data/lib/searchlogic/active_record/scope.rb +30 -0
  22. data/lib/searchlogic/core_ext/proc.rb +1 -1
  23. data/lib/searchlogic/named_scopes/alias_scope.rb +15 -14
  24. data/lib/searchlogic/named_scopes/association_conditions.rb +16 -16
  25. data/lib/searchlogic/named_scopes/association_ordering.rb +8 -9
  26. data/lib/searchlogic/named_scopes/base.rb +16 -0
  27. data/lib/searchlogic/named_scopes/{conditions.rb → column_conditions.rb} +47 -28
  28. data/lib/searchlogic/named_scopes/or_conditions.rb +65 -37
  29. data/lib/searchlogic/named_scopes/ordering.rb +9 -10
  30. data/lib/searchlogic/rails_helpers.rb +5 -1
  31. data/lib/searchlogic/search/conditions.rb +4 -4
  32. data/lib/searchlogic/search/method_missing.rb +7 -12
  33. data/lib/searchlogic/search/ordering.rb +5 -1
  34. data/lib/searchlogic/search/to_yaml.rb +2 -2
  35. data/lib/searchlogic/version.rb +3 -0
  36. data/lib/searchlogic.rb +9 -9
  37. data/searchlogic.gemspec +21 -92
  38. data/spec/searchlogic/active_record/association_proxy_spec.rb +1 -1
  39. data/spec/searchlogic/active_record/consistency_spec.rb +1 -1
  40. data/spec/searchlogic/core_ext/object_spec.rb +1 -1
  41. data/spec/searchlogic/core_ext/proc_spec.rb +1 -1
  42. data/spec/searchlogic/named_scopes/alias_scope_spec.rb +9 -2
  43. data/spec/searchlogic/named_scopes/association_conditions_spec.rb +34 -1
  44. data/spec/searchlogic/named_scopes/association_ordering_spec.rb +1 -1
  45. data/spec/searchlogic/named_scopes/{conditions_spec.rb → column_conditions_spec.rb} +16 -5
  46. data/spec/searchlogic/named_scopes/or_conditions_spec.rb +33 -15
  47. data/spec/searchlogic/named_scopes/ordering_spec.rb +4 -10
  48. data/spec/searchlogic/search_spec.rb +105 -74
  49. data/spec/spec_helper.rb +10 -12
  50. metadata +136 -60
  51. data/VERSION.yml +0 -5
  52. data/lib/searchlogic/active_record/association_proxy.rb +0 -20
@@ -8,7 +8,7 @@ module Searchlogic
8
8
  # Notice the constants in this class, they define which conditions Searchlogic provides.
9
9
  #
10
10
  # See the README for a more detailed explanation.
11
- module Conditions
11
+ module ColumnConditions
12
12
  COMPARISON_CONDITIONS = {
13
13
  :equals => [:is, :eq],
14
14
  :does_not_equal => [:not_equal_to, :is_not, :not, :ne],
@@ -54,14 +54,19 @@ module Searchlogic
54
54
 
55
55
  # Is the name of the method a valid condition that can be dynamically created?
56
56
  def condition?(name)
57
- local_condition?(name)
57
+ super || column_condition?(name)
58
+ end
59
+
60
+ # We want to return true for any conditions that can be called, and while we're at it. We might as well
61
+ # create the condition so we don't have to do it again.
62
+ def respond_to_missing?(*args)
63
+ super || (self != ::ActiveRecord::Base && !self.abstract_class? && !create_condition(args.first).blank?)
58
64
  end
59
65
 
60
66
  private
61
- def local_condition?(name)
67
+ def column_condition?(name)
62
68
  return false if name.blank?
63
- scope_names = scopes.keys.reject { |k| k == :scoped }
64
- scope_names.include?(name.to_sym) || !condition_details(name).nil? || boolean_condition?(name)
69
+ !condition_details(name).nil? || boolean_condition?(name)
65
70
  end
66
71
 
67
72
  def boolean_condition?(name)
@@ -70,13 +75,8 @@ module Searchlogic
70
75
  end
71
76
 
72
77
  def method_missing(name, *args, &block)
73
- if details = condition_details(name)
74
- create_condition(details[:column], details[:condition], args)
75
- send(name, *args)
76
- elsif boolean_condition?(name)
77
- column = name.to_s.gsub(/^not_/, "")
78
- named_scope name, :conditions => {column => (name.to_s =~ /^not_/).nil?}
79
- send(name)
78
+ if create_condition(name)
79
+ send(name, *args, &block)
80
80
  else
81
81
  super
82
82
  end
@@ -91,11 +91,21 @@ module Searchlogic
91
91
  end
92
92
  end
93
93
 
94
- def create_condition(column_name, condition, args)
95
- if PRIMARY_CONDITIONS.include?(condition.to_sym)
96
- create_primary_condition(column_name, condition)
97
- elsif ALIAS_CONDITIONS.include?(condition.to_sym)
98
- create_alias_condition(column_name, condition, args)
94
+ def create_condition(name)
95
+ @conditions_already_tried ||= []
96
+ return nil if @conditions_already_tried.include?(name.to_s)
97
+ @conditions_already_tried << name.to_s
98
+
99
+ if details = condition_details(name)
100
+ if PRIMARY_CONDITIONS.include?(details[:condition].to_sym)
101
+ create_primary_condition(details[:column], details[:condition])
102
+ elsif ALIAS_CONDITIONS.include?(details[:condition].to_sym)
103
+ create_alias_condition(details[:column], details[:condition])
104
+ end
105
+
106
+ elsif boolean_condition?(name)
107
+ column = name.to_s.gsub(/^not_/, "")
108
+ named_scope name, :conditions => {column => (name.to_s =~ /^not_/).nil?}
99
109
  end
100
110
  end
101
111
 
@@ -103,11 +113,11 @@ module Searchlogic
103
113
  column = columns_hash[column_name.to_s]
104
114
  column_type = column.type
105
115
  skip_conversion = skip_time_zone_conversion_for_attributes.include?(column.name.to_sym)
106
- match_keyword = ::ActiveRecord::Base.connection.adapter_name == "PostgreSQL" ? "ILIKE" : "LIKE"
116
+ match_keyword = self.connection.adapter_name == "PostgreSQL" ? "ILIKE" : "LIKE"
107
117
 
108
118
  scope_options = case condition.to_s
109
119
  when /^equals/
110
- scope_options(condition, column, lambda { |a| attribute_condition("#{table_name}.#{column.name}", a) }, :skip_conversion => skip_conversion)
120
+ scope_options(condition, column, "#{table_name}.#{column.name} = ?", :skip_conversion => skip_conversion)
111
121
  when /^does_not_equal/
112
122
  scope_options(condition, column, "#{table_name}.#{column.name} != ?", :skip_conversion => skip_conversion)
113
123
  when /^less_than_or_equal_to/
@@ -149,11 +159,13 @@ module Searchlogic
149
159
  # Kepp in mind that the lambdas get cached in a method, so you want to keep the contents of the lambdas as
150
160
  # fast as possible, which is why I didn't do the case statement inside of the lambda.
151
161
  def scope_options(condition, column, sql, options = {})
162
+ equals = !(condition.to_s =~ /^equals/).nil?
163
+ does_not_equal = !(condition.to_s =~ /^does_not_equal/).nil?
164
+
152
165
  case condition.to_s
153
166
  when /_(any|all)$/
154
167
  any = $1 == "any"
155
168
  join_word = any ? " OR " : " AND "
156
- equals = condition.to_s =~ /^equals_/
157
169
  searchlogic_lambda(column.type, :skip_conversion => options[:skip_conversion]) { |*values|
158
170
  unless values.empty?
159
171
  if equals && any
@@ -172,9 +184,9 @@ module Searchlogic
172
184
  values.flatten!
173
185
  values.collect! { |value| value_with_modifier(value, options[:value_modifier]) }
174
186
 
175
- scope_sql = values.collect { |value| sql.is_a?(Proc) ? sql.call(value) : sql }.join(join_word)
187
+ scope_sql = values.collect { |value| sql }.join(join_word)
176
188
 
177
- {:conditions => [scope_sql, *expand_range_bind_variables(values)]}
189
+ {:conditions => [scope_sql, *values]}
178
190
  end
179
191
  else
180
192
  {}
@@ -184,9 +196,15 @@ module Searchlogic
184
196
  searchlogic_lambda(column.type, :skip_conversion => options[:skip_conversion]) { |*values|
185
197
  values.collect! { |value| value_with_modifier(value, options[:value_modifier]) }
186
198
 
187
- scope_sql = sql.is_a?(Proc) ? sql.call(*values) : sql
199
+ new_sql = if does_not_equal && values == [nil]
200
+ sql.gsub('!=', 'IS NOT')
201
+ elsif equals && values == [nil]
202
+ sql.gsub('=', 'IS')
203
+ else
204
+ sql
205
+ end
188
206
 
189
- {:conditions => [scope_sql, *expand_range_bind_variables(values)]}
207
+ {:conditions => [new_sql, *values]}
190
208
  }
191
209
  end
192
210
  end
@@ -204,12 +222,13 @@ module Searchlogic
204
222
  end
205
223
  end
206
224
 
207
- def create_alias_condition(column_name, condition, args)
225
+ def create_alias_condition(column_name, condition)
208
226
  primary_condition = primary_condition(condition)
209
227
  alias_name = "#{column_name}_#{condition}"
210
228
  primary_name = "#{column_name}_#{primary_condition}"
211
- send(primary_name, *args) # go back to method_missing and make sure we create the method
212
- (class << self; self; end).class_eval { alias_method alias_name, primary_name }
229
+ if respond_to?(primary_name)
230
+ (class << self; self; end).class_eval { alias_method alias_name, primary_name }
231
+ end
213
232
  end
214
233
 
215
234
  # Returns the primary condition for the given alias. Ex:
@@ -238,4 +257,4 @@ module Searchlogic
238
257
  end
239
258
  end
240
259
  end
241
- end
260
+ end
@@ -5,30 +5,30 @@ module Searchlogic
5
5
  module OrConditions
6
6
  class NoConditionSpecifiedError < StandardError; end
7
7
  class UnknownConditionError < StandardError; end
8
-
8
+
9
9
  def condition?(name) # :nodoc:
10
10
  super || or_condition?(name)
11
11
  end
12
-
12
+
13
13
  def named_scope_options(name) # :nodoc:
14
14
  super || super(or_conditions(name).try(:join, "_or_"))
15
15
  end
16
-
16
+
17
17
  private
18
18
  def or_condition?(name)
19
19
  !or_conditions(name).nil?
20
20
  end
21
-
22
- def method_missing(name, *args, &block)
21
+
22
+ def create_condition(name)
23
23
  if conditions = or_conditions(name)
24
- create_or_condition(conditions, args)
25
- (class << self; self; end).class_eval { alias_method name, conditions.join("_or_") } if !respond_to?(name)
26
- send(name, *args)
24
+ create_or_condition(conditions)
25
+ alias_name = conditions.join("_or_")
26
+ (class << self; self; end).class_eval { alias_method name, conditions.join("_or_") } if name != alias_name
27
27
  else
28
28
  super
29
29
  end
30
30
  end
31
-
31
+
32
32
  def or_conditions(name)
33
33
  # First determine if we should even work on the name, we want to be as quick as possible
34
34
  # with this.
@@ -41,7 +41,7 @@ module Searchlogic
41
41
  end
42
42
  end
43
43
  end
44
-
44
+
45
45
  def split_or_condition(name)
46
46
  parts = name.to_s.split("_or_")
47
47
  new_parts = []
@@ -54,7 +54,7 @@ module Searchlogic
54
54
  end
55
55
  new_parts
56
56
  end
57
-
57
+
58
58
  # The purpose of this method is to convert the method name parts into actual condition names.
59
59
  #
60
60
  # Example:
@@ -81,7 +81,7 @@ module Searchlogic
81
81
  path = full_association_path(part, last_condition, association_details[:association])
82
82
  conditions << "#{path[:path].join("_").to_sym}_#{path[:column]}_#{path[:condition]}"
83
83
  last_condition = path[:condition] || nil
84
- elsif local_condition?(part)
84
+ elsif column_condition?(part)
85
85
  # We are a custom scope
86
86
  conditions << part
87
87
  elsif column_names.include?(part)
@@ -90,34 +90,34 @@ module Searchlogic
90
90
  raise NoConditionSpecifiedError.new("The '#{part}' column doesn't know which condition to use, if you use an exact column " +
91
91
  "name you need to specify a condition sometime after (ex: id_or_created_at_lt), where id would use the 'lt' condition.")
92
92
  end
93
-
93
+
94
94
  conditions << "#{part}_#{last_condition}"
95
95
  else
96
96
  raise UnknownConditionError.new("The condition '#{part}' is not a valid condition, we could not find any scopes that match this.")
97
97
  end
98
98
  end
99
-
99
+
100
100
  conditions.reverse
101
101
  end
102
102
 
103
103
  def full_association_path(part, last_condition, given_assoc)
104
- path = [given_assoc.name]
105
- part.sub!(/^#{given_assoc.name}_/, "")
106
- klass = self
107
- while klass = klass.send(:reflect_on_association, given_assoc.name)
108
- klass = klass.klass
109
- if details = klass.send(:association_condition_details, part, last_condition)
110
- path << details[:association]
111
- part = details[:condition]
112
- given_assoc = details[:association]
113
- elsif details = klass.send(:condition_details, part)
114
- return { :path => path, :column => details[:column], :condition => details[:condition] }
115
- end
104
+ path = [given_assoc.name]
105
+ part.sub!(/^#{given_assoc.name}_/, "")
106
+ klass = self
107
+ while klass = klass.send(:reflect_on_association, given_assoc.name)
108
+ klass = klass.klass
109
+ if details = klass.send(:association_condition_details, part, last_condition)
110
+ path << details[:association].name
111
+ part = details[:condition]
112
+ given_assoc = details[:association]
113
+ elsif details = klass.send(:condition_details, part)
114
+ return { :path => path, :column => details[:column], :condition => details[:condition] }
116
115
  end
117
- { :path => path, :column => part, :condition => last_condition }
116
+ end
117
+ {:path => path, :column => part, :condition => last_condition}
118
118
  end
119
-
120
- def create_or_condition(scopes, args)
119
+
120
+ def create_or_condition(scopes)
121
121
  scopes_options = scopes.collect { |scope, *args| send(scope, *args).proxy_options }
122
122
  # We're using first scope to determine column's type
123
123
  scope = named_scope_options(scopes.first)
@@ -126,15 +126,43 @@ module Searchlogic
126
126
  merge_scopes_with_or(scopes.collect { |scope| clone.send(scope, *args) })
127
127
  }
128
128
  end
129
-
129
+
130
130
  def merge_scopes_with_or(scopes)
131
- scopes_options = scopes.collect { |scope| scope.scope(:find) }
132
- conditions = scopes_options.reject { |o| o[:conditions].nil? }.collect { |o| sanitize_sql(o[:conditions]) }
133
- scope = scopes_options.inject(scoped({})) { |current_scope, options| current_scope.scoped(options) }
134
- options = {}
135
- in_searchlogic_delegation { options = scope.scope(:find) }
136
- options.delete(:readonly) unless scopes.any? { |scope| scope.proxy_options.key?(:readonly) }
137
- options.merge(:conditions => "(" + conditions.join(") OR (") + ")")
131
+ options = scopes_options(scopes)
132
+ merged_options = merge_options(options)
133
+ merged_options.delete(:readonly)
134
+ if !merged_options[:joins].blank?
135
+ merged_options[:joins] = convert_joins_to_optional(merged_options[:joins])
136
+ else
137
+ merged_options.delete(:joins)
138
+ end
139
+ conditions = normalized_conditions(options)
140
+ if conditions.any?
141
+ merged_options[:conditions] = "(" + conditions.join(") OR (") + ")"
142
+ end
143
+ merged_options
144
+ end
145
+
146
+ def scopes_options(scopes)
147
+ scopes.collect { |scope| with_exclusive_scope { scope.scope(:find) } }
148
+ end
149
+
150
+ def convert_joins_to_optional(joins)
151
+ joins ||= []
152
+
153
+ (joins || []).collect { |join| join.gsub(/INNER JOIN/, 'LEFT OUTER JOIN') }
154
+ end
155
+
156
+ def merge_options(options)
157
+ with_exclusive_scope do
158
+ options.inject(scoped({:joins => "", :conditions => ""})) do |current_scope, option|
159
+ current_scope.scoped(option)
160
+ end.scope(:find)
161
+ end
162
+ end
163
+
164
+ def normalized_conditions(options)
165
+ options.collect { |option| option[:conditions] && sanitize_sql(option[:conditions]) }.compact
138
166
  end
139
167
  end
140
168
  end
@@ -10,35 +10,34 @@ module Searchlogic
10
10
  def condition?(name) # :nodoc:
11
11
  super || ordering_condition?(name)
12
12
  end
13
-
13
+
14
14
  private
15
15
  def ordering_condition?(name) # :nodoc:
16
16
  !ordering_condition_details(name).nil?
17
17
  end
18
-
19
- def method_missing(name, *args, &block)
18
+
19
+ def create_condition(name)
20
20
  if name == :order
21
- named_scope name, lambda { |scope_name|
22
- return {} if !condition?(scope_name)
23
- send(scope_name).proxy_options
21
+ alias_scope name, lambda { |scope_name|
22
+ return scoped({}) if !condition?(scope_name)
23
+ send(scope_name)
24
24
  }
25
- send(name, *args)
26
25
  elsif details = ordering_condition_details(name)
27
26
  create_ordering_conditions(details[:column])
28
- send(name, *args)
29
27
  else
30
28
  super
31
29
  end
32
30
  end
33
-
31
+
34
32
  def ordering_condition_details(name)
35
33
  if name.to_s =~ /^(ascend|descend)_by_(#{column_names.join("|")})$/
36
34
  {:order_as => $1, :column => $2}
37
35
  elsif name.to_s =~ /^order$/
38
36
  {}
39
37
  end
38
+ rescue ::ActiveRecord::StatementInvalid
40
39
  end
41
-
40
+
42
41
  def create_ordering_conditions(column)
43
42
  named_scope("ascend_by_#{column}".to_sym, {:order => "#{table_name}.#{column} ASC"})
44
43
  named_scope("descend_by_#{column}".to_sym, {:order => "#{table_name}.#{column} DESC"})
@@ -69,7 +69,11 @@ module Searchlogic
69
69
  def fields_for(*args, &block)
70
70
  if search_obj = args.find { |arg| arg.is_a?(Searchlogic::Search) }
71
71
  args.unshift(:search) if args.first == search_obj
72
- concat(content_tag("div", hidden_field_tag("#{args.first}[order]", search_obj.order)))
72
+ options = args.extract_options!
73
+ if !options[:skip_order_field]
74
+ concat(content_tag("div", hidden_field_tag("#{args.first}[order]", search_obj.order), :style => "display: inline"))
75
+ end
76
+ args << options
73
77
  super
74
78
  else
75
79
  super
@@ -7,7 +7,7 @@ module Searchlogic
7
7
  end
8
8
 
9
9
  def compact_conditions
10
- conditions.select { |k,v| !v.blank? }
10
+ Hash[conditions.select { |k,v| !v.blank? }]
11
11
  end
12
12
 
13
13
  # Accepts a hash of conditions.
@@ -31,13 +31,13 @@ module Searchlogic
31
31
  end
32
32
  self
33
33
  end
34
-
34
+
35
35
  private
36
36
  # This is here as a hook to allow people to modify the order in which the conditions are called, for whatever reason.
37
37
  def conditions_array
38
38
  @conditions.to_a
39
39
  end
40
-
40
+
41
41
  def write_condition(name, value)
42
42
  @conditions[name] = value
43
43
  end
@@ -49,7 +49,7 @@ module Searchlogic
49
49
  def mass_conditions
50
50
  @mass_conditions ||= {}
51
51
  end
52
-
52
+
53
53
  def ignore_value?(value)
54
54
  (value.is_a?(String) && value.blank?) || (value.is_a?(Array) && value.empty?)
55
55
  end
@@ -1,7 +1,7 @@
1
1
  module Searchlogic
2
2
  class Search
3
3
  module MethodMissing
4
- def respond_to?(*args)
4
+ def respond_to_missing?(*args)
5
5
  super || scope?(normalize_scope_name(args.first))
6
6
  rescue Searchlogic::NamedScopes::OrConditions::UnknownConditionError
7
7
  false
@@ -89,7 +89,7 @@ module Searchlogic
89
89
  def type_cast(value, type, options = {})
90
90
  case value
91
91
  when Array
92
- value.collect { |v| type_cast(v, type) }
92
+ value.collect { |v| type_cast(v, type) }.uniq
93
93
  when Range
94
94
  Range.new(type_cast(value.first, type), type_cast(value.last, type))
95
95
  else
@@ -101,17 +101,12 @@ module Searchlogic
101
101
 
102
102
  if Time.zone && casted_value.is_a?(Time)
103
103
  if value.is_a?(String)
104
- if options[:skip_conversion]
105
- casted_value.utc
106
- else
107
- (casted_value + (Time.zone.utc_offset * -1)).in_time_zone
108
- end
104
+ # if its a string, we should assume the user means the local time
105
+ # we need to update the object to include the proper time zone without changing
106
+ # the time
107
+ (casted_value + (Time.zone.utc_offset * -1)).in_time_zone(Time.zone)
109
108
  else
110
- if options[:skip_conversion]
111
- casted_value.utc
112
- else
113
- casted_value.in_time_zone
114
- end
109
+ casted_value.in_time_zone
115
110
  end
116
111
  else
117
112
  casted_value
@@ -3,7 +3,11 @@ module Searchlogic
3
3
  module Ordering
4
4
  # Returns the column we are currently ordering by
5
5
  def ordering_by
6
- order && order.to_s.gsub(/^(ascend|descend)_by_/, '')
6
+ @ordering_by ||= order && order.to_s.match(/^(ascend|descend)_by_(.*)$/).try(:[], 2)
7
+ end
8
+
9
+ def ordering_direction
10
+ @ordering_direction ||= order && order.to_s.match(/^(ascend|descend)_by_/).try(:[], 1)
7
11
  end
8
12
  end
9
13
  end
@@ -7,7 +7,7 @@ module Searchlogic
7
7
  include InstanceMethods
8
8
  end
9
9
  end
10
-
10
+
11
11
  module InstanceMethods
12
12
  def to_yaml( opts = {} )
13
13
  YAML::quick_emit( self, opts ) do |out|
@@ -18,7 +18,7 @@ module Searchlogic
18
18
  end
19
19
  end
20
20
  end
21
-
21
+
22
22
  def yaml_initialize(taguri, attributes = {})
23
23
  self.klass = attributes["class_name"].constantize
24
24
  self.current_scope = attributes["current_scope"]
@@ -0,0 +1,3 @@
1
+ module Searchlogic
2
+ VERSION = "2.5.19"
3
+ end
data/lib/searchlogic.rb CHANGED
@@ -1,9 +1,13 @@
1
+ require 'active_support'
2
+ require 'active_record'
3
+ require "searchlogic/version"
1
4
  require "searchlogic/core_ext/proc"
2
5
  require "searchlogic/core_ext/object"
3
- require "searchlogic/active_record/association_proxy"
4
6
  require "searchlogic/active_record/consistency"
5
7
  require "searchlogic/active_record/named_scope_tools"
6
- require "searchlogic/named_scopes/conditions"
8
+ require "searchlogic/active_record/scope"
9
+ require "searchlogic/named_scopes/base"
10
+ require "searchlogic/named_scopes/column_conditions"
7
11
  require "searchlogic/named_scopes/ordering"
8
12
  require "searchlogic/named_scopes/association_conditions"
9
13
  require "searchlogic/named_scopes/association_ordering"
@@ -24,19 +28,15 @@ Proc.send(:include, Searchlogic::CoreExt::Proc)
24
28
  Object.send(:include, Searchlogic::CoreExt::Object)
25
29
 
26
30
  module ActiveRecord # :nodoc: all
27
- module Associations
28
- class AssociationProxy
29
- include Searchlogic::ActiveRecord::AssociationProxy
30
- end
31
- end
32
-
33
31
  class Base
34
32
  class << self; include Searchlogic::ActiveRecord::Consistency; end
35
33
  end
36
34
  end
37
35
 
36
+ ActiveRecord::Base.extend(Searchlogic::ActiveRecord::Scope)
38
37
  ActiveRecord::Base.extend(Searchlogic::ActiveRecord::NamedScopeTools)
39
- ActiveRecord::Base.extend(Searchlogic::NamedScopes::Conditions)
38
+ ActiveRecord::Base.extend(Searchlogic::NamedScopes::Base)
39
+ ActiveRecord::Base.extend(Searchlogic::NamedScopes::ColumnConditions)
40
40
  ActiveRecord::Base.extend(Searchlogic::NamedScopes::AssociationConditions)
41
41
  ActiveRecord::Base.extend(Searchlogic::NamedScopes::AssociationOrdering)
42
42
  ActiveRecord::Base.extend(Searchlogic::NamedScopes::Ordering)
data/searchlogic.gemspec CHANGED
@@ -1,99 +1,28 @@
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 = %q{searchlogic}
8
- s.version = "2.4.32"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Ben Johnson of Binary Logic"]
12
- s.date = %q{2011-03-07}
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/association_proxy.rb",
29
- "lib/searchlogic/active_record/consistency.rb",
30
- "lib/searchlogic/active_record/named_scope_tools.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/conditions.rb",
37
- "lib/searchlogic/named_scopes/or_conditions.rb",
38
- "lib/searchlogic/named_scopes/ordering.rb",
39
- "lib/searchlogic/rails_helpers.rb",
40
- "lib/searchlogic/search.rb",
41
- "lib/searchlogic/search/base.rb",
42
- "lib/searchlogic/search/conditions.rb",
43
- "lib/searchlogic/search/date_parts.rb",
44
- "lib/searchlogic/search/implementation.rb",
45
- "lib/searchlogic/search/method_missing.rb",
46
- "lib/searchlogic/search/ordering.rb",
47
- "lib/searchlogic/search/scopes.rb",
48
- "lib/searchlogic/search/to_yaml.rb",
49
- "lib/searchlogic/search/unknown_condition_error.rb",
50
- "rails/init.rb",
51
- "searchlogic.gemspec",
52
- "spec/searchlogic/active_record/association_proxy_spec.rb",
53
- "spec/searchlogic/active_record/consistency_spec.rb",
54
- "spec/searchlogic/core_ext/object_spec.rb",
55
- "spec/searchlogic/core_ext/proc_spec.rb",
56
- "spec/searchlogic/named_scopes/alias_scope_spec.rb",
57
- "spec/searchlogic/named_scopes/association_conditions_spec.rb",
58
- "spec/searchlogic/named_scopes/association_ordering_spec.rb",
59
- "spec/searchlogic/named_scopes/conditions_spec.rb",
60
- "spec/searchlogic/named_scopes/or_conditions_spec.rb",
61
- "spec/searchlogic/named_scopes/ordering_spec.rb",
62
- "spec/searchlogic/search_spec.rb",
63
- "spec/spec_helper.rb"
64
- ]
65
- s.homepage = %q{http://github.com/binarylogic/searchlogic}
66
- s.require_paths = ["lib"]
67
- s.rubygems_version = %q{1.5.2}
68
- s.summary = %q{Searchlogic makes using ActiveRecord named scopes easier and less repetitive.}
69
- s.test_files = [
70
- "spec/searchlogic/active_record/association_proxy_spec.rb",
71
- "spec/searchlogic/active_record/consistency_spec.rb",
72
- "spec/searchlogic/core_ext/object_spec.rb",
73
- "spec/searchlogic/core_ext/proc_spec.rb",
74
- "spec/searchlogic/named_scopes/alias_scope_spec.rb",
75
- "spec/searchlogic/named_scopes/association_conditions_spec.rb",
76
- "spec/searchlogic/named_scopes/association_ordering_spec.rb",
77
- "spec/searchlogic/named_scopes/conditions_spec.rb",
78
- "spec/searchlogic/named_scopes/or_conditions_spec.rb",
79
- "spec/searchlogic/named_scopes/ordering_spec.rb",
80
- "spec/searchlogic/search_spec.rb",
81
- "spec/spec_helper.rb"
82
- ]
83
14
 
84
- if s.respond_to? :specification_version then
85
- s.specification_version = 3
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 'timecop', '~> 0.5.9.1'
19
+ s.add_development_dependency 'sqlite3', '~> 1.3.8'
20
+ s.add_development_dependency 'appraisal', '0.4.1'
21
+ s.add_development_dependency 'pry', '>= 0'
86
22
 
87
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
88
- s.add_runtime_dependency(%q<activerecord>, ["~> 2.3.11"])
89
- s.add_runtime_dependency(%q<activerecord>, ["~> 2.3.11"])
90
- else
91
- s.add_dependency(%q<activerecord>, ["~> 2.3.11"])
92
- s.add_dependency(%q<activerecord>, ["~> 2.3.11"])
93
- end
94
- else
95
- s.add_dependency(%q<activerecord>, ["~> 2.3.11"])
96
- s.add_dependency(%q<activerecord>, ["~> 2.3.11"])
97
- end
98
- end
99
23
 
24
+ s.files = `git ls-files`.split("\n")
25
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
26
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
27
+ s.require_paths = ["lib"]
28
+ end
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
1
+ require 'spec_helper'
2
2
 
3
3
  describe "Searchlogic::ActiveRecord::AssociationProxy" do
4
4
  it "should call location conditions" do