searchlogic 1.6.6 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (178) hide show
  1. data/.gitignore +6 -0
  2. data/CHANGELOG.rdoc +17 -0
  3. data/{MIT-LICENSE → LICENSE} +2 -2
  4. data/README.rdoc +128 -379
  5. data/Rakefile +56 -20
  6. data/VERSION.yml +4 -0
  7. data/init.rb +1 -1
  8. data/lib/searchlogic.rb +18 -98
  9. data/lib/searchlogic/core_ext/object.rb +33 -13
  10. data/lib/searchlogic/core_ext/proc.rb +11 -0
  11. data/lib/searchlogic/named_scopes/alias_scope.rb +63 -0
  12. data/lib/searchlogic/named_scopes/associations.rb +126 -0
  13. data/lib/searchlogic/named_scopes/conditions.rb +215 -0
  14. data/lib/searchlogic/named_scopes/ordering.rb +53 -0
  15. data/lib/searchlogic/rails_helpers.rb +69 -0
  16. data/lib/searchlogic/search.rb +146 -0
  17. data/rails/init.rb +1 -0
  18. data/searchlogic.gemspec +69 -0
  19. data/spec/core_ext/object_spec.rb +7 -0
  20. data/spec/core_ext/proc_spec.rb +9 -0
  21. data/spec/named_scopes/alias_scope_spec.rb +15 -0
  22. data/spec/named_scopes/associations_spec.rb +120 -0
  23. data/spec/named_scopes/conditions_spec.rb +253 -0
  24. data/spec/named_scopes/ordering_spec.rb +23 -0
  25. data/spec/search_spec.rb +283 -0
  26. data/spec/spec_helper.rb +78 -0
  27. metadata +40 -231
  28. data/Manifest.txt +0 -158
  29. data/TODO.rdoc +0 -4
  30. data/lib/searchlogic/active_record/associations.rb +0 -52
  31. data/lib/searchlogic/active_record/base.rb +0 -224
  32. data/lib/searchlogic/active_record/connection_adapters/mysql_adapter.rb +0 -176
  33. data/lib/searchlogic/active_record/connection_adapters/postgresql_adapter.rb +0 -172
  34. data/lib/searchlogic/active_record/connection_adapters/sqlite_adapter.rb +0 -80
  35. data/lib/searchlogic/condition/base.rb +0 -165
  36. data/lib/searchlogic/condition/begins_with.rb +0 -17
  37. data/lib/searchlogic/condition/blank.rb +0 -24
  38. data/lib/searchlogic/condition/child_of.rb +0 -11
  39. data/lib/searchlogic/condition/descendant_of.rb +0 -11
  40. data/lib/searchlogic/condition/ends_with.rb +0 -17
  41. data/lib/searchlogic/condition/equals.rb +0 -33
  42. data/lib/searchlogic/condition/greater_than.rb +0 -15
  43. data/lib/searchlogic/condition/greater_than_or_equal_to.rb +0 -15
  44. data/lib/searchlogic/condition/inclusive_descendant_of.rb +0 -10
  45. data/lib/searchlogic/condition/keywords.rb +0 -52
  46. data/lib/searchlogic/condition/less_than.rb +0 -15
  47. data/lib/searchlogic/condition/less_than_or_equal_to.rb +0 -15
  48. data/lib/searchlogic/condition/like.rb +0 -15
  49. data/lib/searchlogic/condition/nested_set.rb +0 -17
  50. data/lib/searchlogic/condition/nil.rb +0 -21
  51. data/lib/searchlogic/condition/not_begin_with.rb +0 -20
  52. data/lib/searchlogic/condition/not_blank.rb +0 -19
  53. data/lib/searchlogic/condition/not_end_with.rb +0 -20
  54. data/lib/searchlogic/condition/not_equal.rb +0 -27
  55. data/lib/searchlogic/condition/not_have_keywords.rb +0 -20
  56. data/lib/searchlogic/condition/not_like.rb +0 -20
  57. data/lib/searchlogic/condition/not_nil.rb +0 -19
  58. data/lib/searchlogic/condition/sibling_of.rb +0 -14
  59. data/lib/searchlogic/conditions/any_or_all.rb +0 -42
  60. data/lib/searchlogic/conditions/base.rb +0 -244
  61. data/lib/searchlogic/conditions/groups.rb +0 -74
  62. data/lib/searchlogic/conditions/magic_methods.rb +0 -286
  63. data/lib/searchlogic/conditions/multiparameter_attributes.rb +0 -105
  64. data/lib/searchlogic/conditions/protection.rb +0 -36
  65. data/lib/searchlogic/config.rb +0 -31
  66. data/lib/searchlogic/config/helpers.rb +0 -338
  67. data/lib/searchlogic/config/search.rb +0 -53
  68. data/lib/searchlogic/core_ext/hash.rb +0 -75
  69. data/lib/searchlogic/helpers/control_types/link.rb +0 -310
  70. data/lib/searchlogic/helpers/control_types/links.rb +0 -242
  71. data/lib/searchlogic/helpers/control_types/remote_link.rb +0 -87
  72. data/lib/searchlogic/helpers/control_types/remote_links.rb +0 -72
  73. data/lib/searchlogic/helpers/control_types/remote_select.rb +0 -36
  74. data/lib/searchlogic/helpers/control_types/select.rb +0 -82
  75. data/lib/searchlogic/helpers/form.rb +0 -208
  76. data/lib/searchlogic/helpers/utilities.rb +0 -197
  77. data/lib/searchlogic/modifiers/absolute.rb +0 -15
  78. data/lib/searchlogic/modifiers/acos.rb +0 -11
  79. data/lib/searchlogic/modifiers/asin.rb +0 -11
  80. data/lib/searchlogic/modifiers/atan.rb +0 -11
  81. data/lib/searchlogic/modifiers/avg.rb +0 -15
  82. data/lib/searchlogic/modifiers/base.rb +0 -27
  83. data/lib/searchlogic/modifiers/ceil.rb +0 -15
  84. data/lib/searchlogic/modifiers/char_length.rb +0 -15
  85. data/lib/searchlogic/modifiers/cos.rb +0 -15
  86. data/lib/searchlogic/modifiers/cot.rb +0 -15
  87. data/lib/searchlogic/modifiers/count.rb +0 -11
  88. data/lib/searchlogic/modifiers/day_of_month.rb +0 -15
  89. data/lib/searchlogic/modifiers/day_of_week.rb +0 -15
  90. data/lib/searchlogic/modifiers/day_of_year.rb +0 -15
  91. data/lib/searchlogic/modifiers/degrees.rb +0 -11
  92. data/lib/searchlogic/modifiers/exp.rb +0 -15
  93. data/lib/searchlogic/modifiers/floor.rb +0 -15
  94. data/lib/searchlogic/modifiers/hex.rb +0 -11
  95. data/lib/searchlogic/modifiers/hour.rb +0 -11
  96. data/lib/searchlogic/modifiers/log.rb +0 -15
  97. data/lib/searchlogic/modifiers/log10.rb +0 -11
  98. data/lib/searchlogic/modifiers/log2.rb +0 -11
  99. data/lib/searchlogic/modifiers/lower.rb +0 -15
  100. data/lib/searchlogic/modifiers/ltrim.rb +0 -15
  101. data/lib/searchlogic/modifiers/md5.rb +0 -11
  102. data/lib/searchlogic/modifiers/microseconds.rb +0 -11
  103. data/lib/searchlogic/modifiers/milliseconds.rb +0 -11
  104. data/lib/searchlogic/modifiers/minute.rb +0 -15
  105. data/lib/searchlogic/modifiers/month.rb +0 -15
  106. data/lib/searchlogic/modifiers/octal.rb +0 -15
  107. data/lib/searchlogic/modifiers/radians.rb +0 -11
  108. data/lib/searchlogic/modifiers/round.rb +0 -11
  109. data/lib/searchlogic/modifiers/rtrim.rb +0 -15
  110. data/lib/searchlogic/modifiers/second.rb +0 -15
  111. data/lib/searchlogic/modifiers/sign.rb +0 -11
  112. data/lib/searchlogic/modifiers/sin.rb +0 -11
  113. data/lib/searchlogic/modifiers/square_root.rb +0 -15
  114. data/lib/searchlogic/modifiers/sum.rb +0 -11
  115. data/lib/searchlogic/modifiers/tan.rb +0 -15
  116. data/lib/searchlogic/modifiers/trim.rb +0 -15
  117. data/lib/searchlogic/modifiers/upper.rb +0 -15
  118. data/lib/searchlogic/modifiers/week.rb +0 -11
  119. data/lib/searchlogic/modifiers/year.rb +0 -11
  120. data/lib/searchlogic/search/base.rb +0 -148
  121. data/lib/searchlogic/search/conditions.rb +0 -53
  122. data/lib/searchlogic/search/ordering.rb +0 -244
  123. data/lib/searchlogic/search/pagination.rb +0 -121
  124. data/lib/searchlogic/search/protection.rb +0 -89
  125. data/lib/searchlogic/search/searching.rb +0 -32
  126. data/lib/searchlogic/shared/utilities.rb +0 -57
  127. data/lib/searchlogic/shared/virtual_classes.rb +0 -39
  128. data/lib/searchlogic/version.rb +0 -79
  129. data/test/active_record_tests/associations_test.rb +0 -94
  130. data/test/active_record_tests/base_test.rb +0 -115
  131. data/test/condition_tests/base_test.rb +0 -62
  132. data/test/condition_tests/begins_with_test.rb +0 -11
  133. data/test/condition_tests/blank_test.rb +0 -31
  134. data/test/condition_tests/child_of_test.rb +0 -17
  135. data/test/condition_tests/descendant_of_test.rb +0 -12
  136. data/test/condition_tests/ends_with_test.rb +0 -11
  137. data/test/condition_tests/equals_test.rb +0 -28
  138. data/test/condition_tests/greater_than_or_equal_to_test.rb +0 -11
  139. data/test/condition_tests/greater_than_test.rb +0 -11
  140. data/test/condition_tests/inclusive_descendant_of_test.rb +0 -12
  141. data/test/condition_tests/keywords_test.rb +0 -23
  142. data/test/condition_tests/less_than_or_equal_to_test.rb +0 -11
  143. data/test/condition_tests/less_than_test.rb +0 -11
  144. data/test/condition_tests/like_test.rb +0 -11
  145. data/test/condition_tests/nil_test.rb +0 -31
  146. data/test/condition_tests/not_begin_with_test.rb +0 -8
  147. data/test/condition_tests/not_blank_test.rb +0 -8
  148. data/test/condition_tests/not_end_with_test.rb +0 -8
  149. data/test/condition_tests/not_equal_test.rb +0 -19
  150. data/test/condition_tests/not_have_keywords_test.rb +0 -8
  151. data/test/condition_tests/not_like_test.rb +0 -8
  152. data/test/condition_tests/not_nil_test.rb +0 -13
  153. data/test/condition_tests/sibling_of_test.rb +0 -15
  154. data/test/conditions_tests/any_or_all_test.rb +0 -23
  155. data/test/conditions_tests/base_test.rb +0 -185
  156. data/test/conditions_tests/groups_test.rb +0 -68
  157. data/test/conditions_tests/magic_methods_test.rb +0 -36
  158. data/test/conditions_tests/multiparameter_attributes_test.rb +0 -15
  159. data/test/conditions_tests/protection_test.rb +0 -18
  160. data/test/config_test.rb +0 -23
  161. data/test/fixtures/accounts.yml +0 -12
  162. data/test/fixtures/animals.yml +0 -7
  163. data/test/fixtures/orders.yml +0 -12
  164. data/test/fixtures/user_groups.yml +0 -5
  165. data/test/fixtures/users.yml +0 -45
  166. data/test/libs/awesome_nested_set.rb +0 -545
  167. data/test/libs/awesome_nested_set/.autotest +0 -13
  168. data/test/libs/awesome_nested_set/compatability.rb +0 -29
  169. data/test/libs/awesome_nested_set/helper.rb +0 -40
  170. data/test/libs/awesome_nested_set/named_scope.rb +0 -140
  171. data/test/libs/rexml_fix.rb +0 -14
  172. data/test/modifier_tests/day_of_month_test.rb +0 -16
  173. data/test/search_tests/base_test.rb +0 -241
  174. data/test/search_tests/conditions_test.rb +0 -21
  175. data/test/search_tests/ordering_test.rb +0 -167
  176. data/test/search_tests/pagination_test.rb +0 -74
  177. data/test/search_tests/protection_test.rb +0 -26
  178. data/test/test_helper.rb +0 -122
@@ -0,0 +1,23 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe "Ordering" do
4
+ it "should be dynamically created and then cached" do
5
+ User.should_not respond_to(:ascend_by_username)
6
+ User.ascend_by_username
7
+ User.should respond_to(:ascend_by_username)
8
+ end
9
+
10
+ it "should have ascending" do
11
+ %w(bjohnson thunt).each { |username| User.create(:username => username) }
12
+ User.ascend_by_username.all.should == User.all(:order => "username ASC")
13
+ end
14
+
15
+ it "should have descending" do
16
+ %w(bjohnson thunt).each { |username| User.create(:username => username) }
17
+ User.descend_by_username.all.should == User.all(:order => "username DESC")
18
+ end
19
+
20
+ it "should have order" do
21
+ User.order("ascend_by_username").proxy_options.should == User.ascend_by_username.proxy_options
22
+ end
23
+ end
@@ -0,0 +1,283 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/spec_helper")
2
+
3
+ describe "Search" do
4
+ context "implementation" do
5
+ it "should create a search proxy" do
6
+ User.search(:username => "joe").should be_kind_of(Searchlogic::Search)
7
+ end
8
+
9
+ it "should create a search proxy using the same class" do
10
+ User.search.klass.should == User
11
+ end
12
+
13
+ it "should pass on the current scope to the proxy" do
14
+ company = Company.create
15
+ user = company.users.create
16
+ search = company.users.search
17
+ search.current_scope.should == company.users.scope(:find)
18
+ end
19
+ end
20
+
21
+ context "initialization" do
22
+ it "should require a class" do
23
+ lambda { Searchlogic::Search.new }.should raise_error(ArgumentError)
24
+ end
25
+
26
+ it "should set the conditions" do
27
+ search = User.search(:username => "bjohnson")
28
+ search.conditions.should == {:username => "bjohnson"}
29
+ end
30
+ end
31
+
32
+ it "should clone properly" do
33
+ company = Company.create
34
+ user1 = company.users.create(:age => 5)
35
+ user2 = company.users.create(:age => 25)
36
+ search1 = company.users.search(:age_gt => 10)
37
+ search2 = search1.clone
38
+ search2.age_gt = 1
39
+ search2.all.should == User.all
40
+ search1.all.should == [user2]
41
+ end
42
+
43
+ it "should delete the condition" do
44
+ search = User.search(:username_like => "bjohnson")
45
+ search.delete("username_like")
46
+ search.username_like.should be_nil
47
+ end
48
+
49
+ context "conditions" do
50
+ it "should set the conditions and be accessible individually" do
51
+ search = User.search
52
+ search.conditions = {:username => "bjohnson"}
53
+ search.username.should == "bjohnson"
54
+ end
55
+
56
+ it "should set the conditions and allow string keys" do
57
+ search = User.search
58
+ search.conditions = {"username" => "bjohnson"}
59
+ search.username.should == "bjohnson"
60
+ end
61
+
62
+ it "should ignore blank values" do
63
+ search = User.search
64
+ search.conditions = {"username" => ""}
65
+ search.username.should be_nil
66
+ end
67
+
68
+ it "should ignore blank values in arrays" do
69
+ search = User.search
70
+ search.conditions = {"username_equals_any" => [""]}
71
+ search.username_equals_any.should be_blank
72
+ end
73
+ end
74
+
75
+ context "condition accessors" do
76
+ it "should allow setting exact columns individually" do
77
+ search = User.search
78
+ search.username = "bjohnson"
79
+ search.username.should == "bjohnson"
80
+ end
81
+
82
+ it "should allow setting local column conditions individually" do
83
+ search = User.search
84
+ search.username_gt = "bjohnson"
85
+ search.username_gt.should == "bjohnson"
86
+ end
87
+
88
+ it "should allow chainging conditions" do
89
+ user = User.create(:username => "bjohnson", :age => 20)
90
+ User.create(:username => "bjohnson", :age => 5)
91
+ search = User.search
92
+ search.username_equals("bjohnson").age_gt(10)
93
+ search.all.should == [user]
94
+ end
95
+
96
+ it "should allow setting association conditions" do
97
+ search = User.search
98
+ search.orders_total_gt = 10
99
+ search.orders_total_gt.should == 10
100
+ end
101
+
102
+ it "should allow using custom conditions" do
103
+ User.named_scope(:four_year_olds, { :conditions => { :age => 4 } })
104
+ search = User.search
105
+ search.four_year_olds = true
106
+ search.four_year_olds.should == true
107
+ search.proxy_options.should == User.four_year_olds.proxy_options
108
+ end
109
+
110
+ it "should not merge conflicting conditions into one value" do
111
+ # This class should JUST be a proxy. It should not do anything more than that.
112
+ # A user would be allowed to call both named scopes if they wanted.
113
+ search = User.search
114
+ search.username_greater_than = "bjohnson1"
115
+ search.username_gt = "bjohnson2"
116
+ search.username_greater_than.should == "bjohnson1"
117
+ search.username_gt.should == "bjohnson2"
118
+ end
119
+
120
+ it "should allow setting custom conditions individually with an arity of 0" do
121
+ User.named_scope(:four_year_olds, :conditions => {:age => 4})
122
+ search = User.search
123
+ search.four_year_olds = true
124
+ search.four_year_olds.should == true
125
+ end
126
+
127
+ it "should allow setting custom conditions individually with an arity of 1" do
128
+ User.named_scope(:username_should_be, lambda { |u| {:conditions => {:username => u}} })
129
+ search = User.search
130
+ search.username_should_be = "bjohnson"
131
+ search.username_should_be.should == "bjohnson"
132
+ end
133
+
134
+ it "should not allow setting conditions that are not scopes" do
135
+ search = User.search
136
+ lambda { search.unknown = true }.should raise_error(Searchlogic::Search::UnknownConditionError)
137
+ end
138
+
139
+ context "type casting" do
140
+ it "should be a Boolean given true" do
141
+ search = User.search
142
+ search.id_nil = true
143
+ search.id_nil.should == true
144
+ end
145
+
146
+ it "should be a Boolean given 'true'" do
147
+ search = User.search
148
+ search.id_nil = "true"
149
+ search.id_nil.should == true
150
+ end
151
+
152
+ it "should be a Boolean given '1'" do
153
+ search = User.search
154
+ search.id_nil = "1"
155
+ search.id_nil.should == true
156
+ end
157
+
158
+ it "should be a Boolean given false" do
159
+ search = User.search
160
+ search.id_nil = false
161
+ search.id_nil.should == false
162
+ end
163
+
164
+ it "should be a Boolean given 'false'" do
165
+ search = User.search
166
+ search.id_nil = "false"
167
+ search.id_nil.should == false
168
+ end
169
+
170
+ it "should be a Boolean given '0'" do
171
+ search = User.search
172
+ search.id_nil = "0"
173
+ search.id_nil.should == false
174
+ end
175
+
176
+ it "should be an Integer given 1" do
177
+ search = User.search
178
+ search.id_gt = 1
179
+ search.id_gt.should == 1
180
+ end
181
+
182
+ it "should be an Integer given '1'" do
183
+ search = User.search
184
+ search.id_gt = "1"
185
+ search.id_gt.should == 1
186
+ end
187
+
188
+ it "should be a Float given 1.0" do
189
+ search = Order.search
190
+ search.total_gt = 1.0
191
+ search.total_gt.should == 1.0
192
+ end
193
+
194
+ it "should be a Float given '1'" do
195
+ search = Order.search
196
+ search.total_gt = "1"
197
+ search.total_gt.should == 1.0
198
+ end
199
+
200
+ it "should be a Float given '1.5'" do
201
+ search = Order.search
202
+ search.total_gt = "1.5"
203
+ search.total_gt.should == 1.5
204
+ end
205
+
206
+ it "should be a Date given 'Jan 1, 2009'" do
207
+ search = Order.search
208
+ search.shipped_on_after = "Jan 1, 2009"
209
+ search.shipped_on_after.should == Date.parse("Jan 1, 2009")
210
+ end
211
+
212
+ it "should be a Time given 'Jan 1, 2009'" do
213
+ search = Order.search
214
+ search.created_at_after = "Jan 1, 2009"
215
+ search.created_at_after.should == Time.parse("Jan 1, 2009")
216
+ end
217
+
218
+ it "should be a Time given 'Jan 1, 2009 9:33AM'" do
219
+ search = Order.search
220
+ search.created_at_after = "Jan 1, 2009 9:33AM"
221
+ search.created_at_after.should == Time.parse("Jan 1, 2009 9:33AM")
222
+ end
223
+
224
+ it "should be an Array and cast it's values given ['1', '2', '3']" do
225
+ search = Order.search
226
+ search.id_equals_any = ["1", "2", "3"]
227
+ search.id_equals_any.should == [1, 2, 3]
228
+ end
229
+
230
+ it "should type cast association conditions" do
231
+ search = User.search
232
+ search.orders_total_gt = "10"
233
+ search.orders_total_gt.should == 10
234
+ end
235
+
236
+ it "should type cast deep association conditions" do
237
+ search = Company.search
238
+ search.users_orders_total_gt = "10"
239
+ search.users_orders_total_gt.should == 10
240
+ end
241
+ end
242
+ end
243
+
244
+ context "taking action" do
245
+ it "should return all when not given any conditions" do
246
+ 3.times { User.create }
247
+ User.search.all.length.should == 3
248
+ end
249
+
250
+ it "should implement the current scope based on an association" do
251
+ User.create
252
+ company = Company.create
253
+ user = company.users.create
254
+ company.users.search.all.should == [user]
255
+ end
256
+
257
+ it "should implement the current scope based on a named scope" do
258
+ User.named_scope(:four_year_olds, :conditions => {:age => 4})
259
+ (3..5).each { |age| User.create(:age => age) }
260
+ User.four_year_olds.search.all.should == User.find_all_by_age(4)
261
+ end
262
+
263
+ it "should call named scopes for conditions" do
264
+ User.search(:age_less_than => 5).proxy_options.should == User.age_less_than(5).proxy_options
265
+ end
266
+
267
+ it "should alias exact column names to use equals" do
268
+ User.search(:username => "joe").proxy_options.should == User.username_equals("joe").proxy_options
269
+ end
270
+
271
+ it "should recognize conditions with a value of true where the named scope has an arity of 0" do
272
+ User.search(:username_nil => true).proxy_options.should == User.username_nil.proxy_options
273
+ end
274
+
275
+ it "should ignore conditions with a value of false where the named scope has an arity of 0" do
276
+ User.search(:username_nil => false).proxy_options.should == {}
277
+ end
278
+
279
+ it "should recognize the order condition" do
280
+ User.search(:order => "ascend_by_username").proxy_options.should == User.ascend_by_username.proxy_options
281
+ end
282
+ end
283
+ end
@@ -0,0 +1,78 @@
1
+ require 'spec'
2
+ require 'rubygems'
3
+ require 'ruby-debug'
4
+ require 'activerecord'
5
+
6
+ ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :dbfile => ":memory:")
7
+ ActiveRecord::Base.configurations = true
8
+
9
+ ActiveRecord::Schema.verbose = false
10
+ ActiveRecord::Schema.define(:version => 1) do
11
+ create_table :companies do |t|
12
+ t.datetime :created_at
13
+ t.datetime :updated_at
14
+ end
15
+
16
+ create_table :users do |t|
17
+ t.datetime :created_at
18
+ t.datetime :updated_at
19
+ t.integer :company_id
20
+ t.string :username
21
+ t.integer :age
22
+ end
23
+
24
+ create_table :orders do |t|
25
+ t.datetime :created_at
26
+ t.datetime :updated_at
27
+ t.integer :user_id
28
+ t.date :shipped_on
29
+ t.float :taxes
30
+ t.float :total
31
+ end
32
+
33
+ create_table :line_items do |t|
34
+ t.datetime :created_at
35
+ t.datetime :updated_at
36
+ t.integer :order_id
37
+ t.float :price
38
+ end
39
+ end
40
+
41
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
42
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
43
+ require 'searchlogic'
44
+
45
+ Spec::Runner.configure do |config|
46
+ config.before(:each) do
47
+ class Company < ActiveRecord::Base
48
+ has_many :users, :dependent => :destroy
49
+ end
50
+
51
+ class User < ActiveRecord::Base
52
+ belongs_to :company
53
+ has_many :orders, :dependent => :destroy
54
+ alias_scope :username_has, lambda { |value| username_like(value) }
55
+ end
56
+
57
+ class Order < ActiveRecord::Base
58
+ belongs_to :user
59
+ has_many :line_items, :dependent => :destroy
60
+ end
61
+
62
+ class LineItem < ActiveRecord::Base
63
+ belongs_to :order
64
+ end
65
+
66
+ Company.destroy_all
67
+ User.destroy_all
68
+ Order.destroy_all
69
+ LineItem.destroy_all
70
+ end
71
+
72
+ config.after(:each) do
73
+ Object.send(:remove_const, :Company)
74
+ Object.send(:remove_const, :User)
75
+ Object.send(:remove_const, :Order)
76
+ Object.send(:remove_const, :LineItem)
77
+ end
78
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: searchlogic
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.6
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Johnson of Binary Logic
@@ -9,214 +9,53 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-20 00:00:00 -04:00
12
+ date: 2009-06-27 00:00:00 -04:00
13
13
  default_executable:
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: activesupport
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: "0"
24
- version:
25
- - !ruby/object:Gem::Dependency
26
- name: activerecord
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: "0"
34
- version:
35
- - !ruby/object:Gem::Dependency
36
- name: hoe
37
- type: :development
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- version: 1.12.1
44
- version:
45
- description: Object based ActiveRecord searching, ordering, pagination, and more!
14
+ dependencies: []
15
+
16
+ description:
46
17
  email: bjohnson@binarylogic.com
47
18
  executables: []
48
19
 
49
20
  extensions: []
50
21
 
51
22
  extra_rdoc_files:
52
- - Manifest.txt
53
- - CHANGELOG.rdoc
23
+ - LICENSE
54
24
  - README.rdoc
55
25
  files:
26
+ - .gitignore
56
27
  - CHANGELOG.rdoc
57
- - MIT-LICENSE
58
- - Manifest.txt
28
+ - LICENSE
59
29
  - README.rdoc
60
30
  - Rakefile
61
- - TODO.rdoc
31
+ - VERSION.yml
62
32
  - init.rb
63
33
  - lib/searchlogic.rb
64
- - lib/searchlogic/active_record/associations.rb
65
- - lib/searchlogic/active_record/base.rb
66
- - lib/searchlogic/active_record/connection_adapters/mysql_adapter.rb
67
- - lib/searchlogic/active_record/connection_adapters/postgresql_adapter.rb
68
- - lib/searchlogic/active_record/connection_adapters/sqlite_adapter.rb
69
- - lib/searchlogic/condition/base.rb
70
- - lib/searchlogic/condition/begins_with.rb
71
- - lib/searchlogic/condition/blank.rb
72
- - lib/searchlogic/condition/child_of.rb
73
- - lib/searchlogic/condition/descendant_of.rb
74
- - lib/searchlogic/condition/ends_with.rb
75
- - lib/searchlogic/condition/equals.rb
76
- - lib/searchlogic/condition/greater_than.rb
77
- - lib/searchlogic/condition/greater_than_or_equal_to.rb
78
- - lib/searchlogic/condition/inclusive_descendant_of.rb
79
- - lib/searchlogic/condition/keywords.rb
80
- - lib/searchlogic/condition/less_than.rb
81
- - lib/searchlogic/condition/less_than_or_equal_to.rb
82
- - lib/searchlogic/condition/like.rb
83
- - lib/searchlogic/condition/nested_set.rb
84
- - lib/searchlogic/condition/nil.rb
85
- - lib/searchlogic/condition/not_begin_with.rb
86
- - lib/searchlogic/condition/not_blank.rb
87
- - lib/searchlogic/condition/not_end_with.rb
88
- - lib/searchlogic/condition/not_equal.rb
89
- - lib/searchlogic/condition/not_have_keywords.rb
90
- - lib/searchlogic/condition/not_like.rb
91
- - lib/searchlogic/condition/not_nil.rb
92
- - lib/searchlogic/condition/sibling_of.rb
93
- - lib/searchlogic/conditions/any_or_all.rb
94
- - lib/searchlogic/conditions/base.rb
95
- - lib/searchlogic/conditions/groups.rb
96
- - lib/searchlogic/conditions/magic_methods.rb
97
- - lib/searchlogic/conditions/multiparameter_attributes.rb
98
- - lib/searchlogic/conditions/protection.rb
99
- - lib/searchlogic/config.rb
100
- - lib/searchlogic/config/helpers.rb
101
- - lib/searchlogic/config/search.rb
102
- - lib/searchlogic/core_ext/hash.rb
103
34
  - lib/searchlogic/core_ext/object.rb
104
- - lib/searchlogic/helpers/control_types/link.rb
105
- - lib/searchlogic/helpers/control_types/links.rb
106
- - lib/searchlogic/helpers/control_types/remote_link.rb
107
- - lib/searchlogic/helpers/control_types/remote_links.rb
108
- - lib/searchlogic/helpers/control_types/remote_select.rb
109
- - lib/searchlogic/helpers/control_types/select.rb
110
- - lib/searchlogic/helpers/form.rb
111
- - lib/searchlogic/helpers/utilities.rb
112
- - lib/searchlogic/modifiers/absolute.rb
113
- - lib/searchlogic/modifiers/acos.rb
114
- - lib/searchlogic/modifiers/asin.rb
115
- - lib/searchlogic/modifiers/atan.rb
116
- - lib/searchlogic/modifiers/avg.rb
117
- - lib/searchlogic/modifiers/base.rb
118
- - lib/searchlogic/modifiers/ceil.rb
119
- - lib/searchlogic/modifiers/char_length.rb
120
- - lib/searchlogic/modifiers/cos.rb
121
- - lib/searchlogic/modifiers/cot.rb
122
- - lib/searchlogic/modifiers/count.rb
123
- - lib/searchlogic/modifiers/day_of_month.rb
124
- - lib/searchlogic/modifiers/day_of_week.rb
125
- - lib/searchlogic/modifiers/day_of_year.rb
126
- - lib/searchlogic/modifiers/degrees.rb
127
- - lib/searchlogic/modifiers/exp.rb
128
- - lib/searchlogic/modifiers/floor.rb
129
- - lib/searchlogic/modifiers/hex.rb
130
- - lib/searchlogic/modifiers/hour.rb
131
- - lib/searchlogic/modifiers/log.rb
132
- - lib/searchlogic/modifiers/log10.rb
133
- - lib/searchlogic/modifiers/log2.rb
134
- - lib/searchlogic/modifiers/lower.rb
135
- - lib/searchlogic/modifiers/ltrim.rb
136
- - lib/searchlogic/modifiers/md5.rb
137
- - lib/searchlogic/modifiers/microseconds.rb
138
- - lib/searchlogic/modifiers/milliseconds.rb
139
- - lib/searchlogic/modifiers/minute.rb
140
- - lib/searchlogic/modifiers/month.rb
141
- - lib/searchlogic/modifiers/octal.rb
142
- - lib/searchlogic/modifiers/radians.rb
143
- - lib/searchlogic/modifiers/round.rb
144
- - lib/searchlogic/modifiers/rtrim.rb
145
- - lib/searchlogic/modifiers/second.rb
146
- - lib/searchlogic/modifiers/sign.rb
147
- - lib/searchlogic/modifiers/sin.rb
148
- - lib/searchlogic/modifiers/square_root.rb
149
- - lib/searchlogic/modifiers/sum.rb
150
- - lib/searchlogic/modifiers/tan.rb
151
- - lib/searchlogic/modifiers/trim.rb
152
- - lib/searchlogic/modifiers/upper.rb
153
- - lib/searchlogic/modifiers/week.rb
154
- - lib/searchlogic/modifiers/year.rb
155
- - lib/searchlogic/search/base.rb
156
- - lib/searchlogic/search/conditions.rb
157
- - lib/searchlogic/search/ordering.rb
158
- - lib/searchlogic/search/pagination.rb
159
- - lib/searchlogic/search/protection.rb
160
- - lib/searchlogic/search/searching.rb
161
- - lib/searchlogic/shared/utilities.rb
162
- - lib/searchlogic/shared/virtual_classes.rb
163
- - lib/searchlogic/version.rb
164
- - test/active_record_tests/associations_test.rb
165
- - test/active_record_tests/base_test.rb
166
- - test/condition_tests/base_test.rb
167
- - test/condition_tests/begins_with_test.rb
168
- - test/condition_tests/blank_test.rb
169
- - test/condition_tests/child_of_test.rb
170
- - test/condition_tests/descendant_of_test.rb
171
- - test/condition_tests/ends_with_test.rb
172
- - test/condition_tests/equals_test.rb
173
- - test/condition_tests/greater_than_or_equal_to_test.rb
174
- - test/condition_tests/greater_than_test.rb
175
- - test/condition_tests/inclusive_descendant_of_test.rb
176
- - test/condition_tests/keywords_test.rb
177
- - test/condition_tests/less_than_or_equal_to_test.rb
178
- - test/condition_tests/less_than_test.rb
179
- - test/condition_tests/like_test.rb
180
- - test/condition_tests/nil_test.rb
181
- - test/condition_tests/not_begin_with_test.rb
182
- - test/condition_tests/not_blank_test.rb
183
- - test/condition_tests/not_end_with_test.rb
184
- - test/condition_tests/not_equal_test.rb
185
- - test/condition_tests/not_have_keywords_test.rb
186
- - test/condition_tests/not_like_test.rb
187
- - test/condition_tests/not_nil_test.rb
188
- - test/condition_tests/sibling_of_test.rb
189
- - test/conditions_tests/any_or_all_test.rb
190
- - test/conditions_tests/base_test.rb
191
- - test/conditions_tests/groups_test.rb
192
- - test/conditions_tests/magic_methods_test.rb
193
- - test/conditions_tests/multiparameter_attributes_test.rb
194
- - test/conditions_tests/protection_test.rb
195
- - test/config_test.rb
196
- - test/fixtures/accounts.yml
197
- - test/fixtures/animals.yml
198
- - test/fixtures/orders.yml
199
- - test/fixtures/user_groups.yml
200
- - test/fixtures/users.yml
201
- - test/libs/awesome_nested_set.rb
202
- - test/libs/awesome_nested_set/.autotest
203
- - test/libs/awesome_nested_set/compatability.rb
204
- - test/libs/awesome_nested_set/helper.rb
205
- - test/libs/awesome_nested_set/named_scope.rb
206
- - test/libs/rexml_fix.rb
207
- - test/modifier_tests/day_of_month_test.rb
208
- - test/search_tests/base_test.rb
209
- - test/search_tests/conditions_test.rb
210
- - test/search_tests/ordering_test.rb
211
- - test/search_tests/pagination_test.rb
212
- - test/search_tests/protection_test.rb
213
- - test/test_helper.rb
35
+ - lib/searchlogic/core_ext/proc.rb
36
+ - lib/searchlogic/named_scopes/alias_scope.rb
37
+ - lib/searchlogic/named_scopes/associations.rb
38
+ - lib/searchlogic/named_scopes/conditions.rb
39
+ - lib/searchlogic/named_scopes/ordering.rb
40
+ - lib/searchlogic/rails_helpers.rb
41
+ - lib/searchlogic/search.rb
42
+ - rails/init.rb
43
+ - searchlogic.gemspec
44
+ - spec/core_ext/object_spec.rb
45
+ - spec/core_ext/proc_spec.rb
46
+ - spec/named_scopes/alias_scope_spec.rb
47
+ - spec/named_scopes/associations_spec.rb
48
+ - spec/named_scopes/conditions_spec.rb
49
+ - spec/named_scopes/ordering_spec.rb
50
+ - spec/search_spec.rb
51
+ - spec/spec_helper.rb
214
52
  has_rdoc: true
215
53
  homepage: http://github.com/binarylogic/searchlogic
54
+ licenses: []
55
+
216
56
  post_install_message:
217
57
  rdoc_options:
218
- - --main
219
- - README.rdoc
58
+ - --charset=UTF-8
220
59
  require_paths:
221
60
  - lib
222
61
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -234,46 +73,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
234
73
  requirements: []
235
74
 
236
75
  rubyforge_project: searchlogic
237
- rubygems_version: 1.3.1
76
+ rubygems_version: 1.3.4
238
77
  signing_key:
239
- specification_version: 2
240
- summary: Object based ActiveRecord searching, ordering, pagination, and more!
78
+ specification_version: 3
79
+ summary: Searchlogic provides common named scopes and object based searching for ActiveRecord.
241
80
  test_files:
242
- - test/config_test.rb
243
- - test/active_record_tests/associations_test.rb
244
- - test/active_record_tests/base_test.rb
245
- - test/condition_tests/base_test.rb
246
- - test/condition_tests/begins_with_test.rb
247
- - test/condition_tests/blank_test.rb
248
- - test/condition_tests/child_of_test.rb
249
- - test/condition_tests/descendant_of_test.rb
250
- - test/condition_tests/ends_with_test.rb
251
- - test/condition_tests/equals_test.rb
252
- - test/condition_tests/greater_than_or_equal_to_test.rb
253
- - test/condition_tests/greater_than_test.rb
254
- - test/condition_tests/inclusive_descendant_of_test.rb
255
- - test/condition_tests/keywords_test.rb
256
- - test/condition_tests/less_than_or_equal_to_test.rb
257
- - test/condition_tests/less_than_test.rb
258
- - test/condition_tests/like_test.rb
259
- - test/condition_tests/nil_test.rb
260
- - test/condition_tests/not_begin_with_test.rb
261
- - test/condition_tests/not_blank_test.rb
262
- - test/condition_tests/not_end_with_test.rb
263
- - test/condition_tests/not_equal_test.rb
264
- - test/condition_tests/not_have_keywords_test.rb
265
- - test/condition_tests/not_like_test.rb
266
- - test/condition_tests/not_nil_test.rb
267
- - test/condition_tests/sibling_of_test.rb
268
- - test/conditions_tests/any_or_all_test.rb
269
- - test/conditions_tests/base_test.rb
270
- - test/conditions_tests/groups_test.rb
271
- - test/conditions_tests/magic_methods_test.rb
272
- - test/conditions_tests/multiparameter_attributes_test.rb
273
- - test/conditions_tests/protection_test.rb
274
- - test/modifier_tests/day_of_month_test.rb
275
- - test/search_tests/base_test.rb
276
- - test/search_tests/conditions_test.rb
277
- - test/search_tests/ordering_test.rb
278
- - test/search_tests/pagination_test.rb
279
- - test/search_tests/protection_test.rb
81
+ - spec/core_ext/object_spec.rb
82
+ - spec/core_ext/proc_spec.rb
83
+ - spec/named_scopes/alias_scope_spec.rb
84
+ - spec/named_scopes/associations_spec.rb
85
+ - spec/named_scopes/conditions_spec.rb
86
+ - spec/named_scopes/ordering_spec.rb
87
+ - spec/search_spec.rb
88
+ - spec/spec_helper.rb