searchgasm 1.4.1 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc CHANGED
@@ -1,9 +1,16 @@
1
- == 1.4.1 released 2008-10-08
1
+ == 1.5.0 released 2008-10-20
2
+
3
+ * Merge array of conditions with or or and where it makes sense. Begins with condition does not make sense to join with and, so instead join with or.
4
+ * Cleaned up html validity so it will pass W3C validators
5
+ * Restructure configuration to be more organized and allow for more configuration options.
6
+ * Added more configuration options, especially for class names.
7
+
8
+ == 1.4.1 released 2008-10-15
2
9
 
3
10
  * Extracted english text into configuration to support alternate languages. I18n support.
4
11
  * Improved method detection in add_joins to use respond_to? with the private method option set to true
5
12
 
6
- == 1.4.0 released 2008-10-08
13
+ == 1.4.0 released 2008-10-15
7
14
 
8
15
  * Fixed bug when duping or cloning to copy over instance vars instead of method values
9
16
  * Fixed bug with older versions of ActiveRecord and creating an alias method chain on find in AssociationCollection
data/Manifest CHANGED
@@ -32,6 +32,8 @@ lib/searchgasm/condition/sibling_of.rb
32
32
  lib/searchgasm/condition/tree.rb
33
33
  lib/searchgasm/conditions/base.rb
34
34
  lib/searchgasm/conditions/protection.rb
35
+ lib/searchgasm/config/helpers.rb
36
+ lib/searchgasm/config/search.rb
35
37
  lib/searchgasm/config.rb
36
38
  lib/searchgasm/core_ext/hash.rb
37
39
  lib/searchgasm/helpers/control_types/link.rb
data/Rakefile CHANGED
@@ -10,6 +10,6 @@ Echoe.new 'searchgasm' do |p|
10
10
  p.project = 'searchgasm'
11
11
  p.summary = "Object based ActiveRecord searching, ordering, pagination, and more!"
12
12
  p.url = "http://github.com/binarylogic/searchgasm"
13
- p.dependencies = %w(activerecord activesupport)
13
+ p.dependencies = %w(activerecord activesupport configatron)
14
14
  p.include_rakefile = true
15
15
  end
@@ -8,7 +8,7 @@ module Searchgasm
8
8
  include Shared::Utilities
9
9
 
10
10
  attr_accessor :column, :column_for_type_cast, :column_sql, :column_sql_format, :klass, :table_name
11
- class_inheritable_accessor :handle_array_value, :ignore_meaningless_value, :value_type
11
+ class_inheritable_accessor :handle_array_value, :ignore_meaningless_value, :join_arrays_with_or, :value_type
12
12
  self.ignore_meaningless_value = true
13
13
 
14
14
  class << self
@@ -25,6 +25,10 @@ module Searchgasm
25
25
  ignore_meaningless_value == true
26
26
  end
27
27
 
28
+ def join_arrays_with_or?
29
+ join_arrays_with_or == true
30
+ end
31
+
28
32
  # Determines what to call the condition for the model
29
33
  #
30
34
  # Searchgasm tries to create conditions on each model. Before it does this it passes the model to this method to see what to call the condition. If the condition type doesnt want to create a condition on
@@ -82,7 +86,7 @@ module Searchgasm
82
86
  return if value_is_meaningless?
83
87
  v = alt_value || value
84
88
  if v.is_a?(Array) && !self.class.handle_array_value?
85
- merge_conditions(*v.collect { |i| sanitize(i) })
89
+ merge_conditions(*v.collect { |i| sanitize(i) } << {:any => self.class.join_arrays_with_or?})
86
90
  else
87
91
  v = v.utc if column && v.respond_to?(:utc) && [:time, :timestamp, :datetime].include?(column.type) && klass.time_zone_aware_attributes && !klass.skip_time_zone_conversion_for_attributes.include?(column.name.to_sym)
88
92
  to_conditions(v)
@@ -1,6 +1,8 @@
1
1
  module Searchgasm
2
2
  module Condition
3
3
  class BeginsWith < Base
4
+ self.join_arrays_with_or = true
5
+
4
6
  class << self
5
7
  def condition_names_for_column
6
8
  super + ["bw", "sw", "starts_with", "start"]
@@ -1,6 +1,6 @@
1
1
  module Searchgasm
2
2
  module Condition
3
- class ChildOf < Tree
3
+ class ChildOf < Tree
4
4
  def to_conditions(value)
5
5
  parent_association = klass.reflect_on_association(:parent)
6
6
  foreign_key_name = (parent_association && parent_association.options[:foreign_key]) || "parent_id"
@@ -1,6 +1,6 @@
1
1
  module Searchgasm
2
2
  module Condition
3
- class DescendantOf < Tree
3
+ class DescendantOf < Tree
4
4
  def to_conditions(value)
5
5
  # Wish I knew how to do this in SQL
6
6
  root = (value.is_a?(klass) ? value : klass.find(value)) rescue return
@@ -1,6 +1,8 @@
1
1
  module Searchgasm
2
2
  module Condition
3
3
  class EndsWith < Base
4
+ self.join_arrays_with_or = true
5
+
4
6
  class << self
5
7
  def condition_names_for_column
6
8
  super + ["ew", "ends", "end"]
@@ -1,6 +1,6 @@
1
1
  module Searchgasm
2
2
  module Condition
3
- class InclusiveDescendantOf < Tree
3
+ class InclusiveDescendantOf < Tree
4
4
  def to_conditions(value)
5
5
  condition = DescendantOf.new(klass, options)
6
6
  condition.value = value
@@ -1,6 +1,9 @@
1
1
  module Searchgasm
2
2
  module Condition
3
3
  class Keywords < Base
4
+ # Because be default it joins with AND, so padding an array just gives you more options. Joining with and is no different than combining all of the words.
5
+ self.join_arrays_with_or = true
6
+
4
7
  BLACKLISTED_WORDS = ('a'..'z').to_a + ["about", "an", "are", "as", "at", "be", "by", "com", "de", "en", "for", "from", "how", "in", "is", "it", "la", "of", "on", "or", "that", "the", "the", "this", "to", "und", "was", "what", "when", "where", "who", "will", "with", "www"] # from ranks.nl
5
8
 
6
9
  class << self
@@ -1,6 +1,8 @@
1
1
  module Searchgasm
2
2
  module Condition
3
3
  class Tree < Base # :nodoc:
4
+ self.join_arrays_with_or = true
5
+
4
6
  class << self
5
7
  def condition_names_for_column
6
8
  []
@@ -0,0 +1,268 @@
1
+ module Searchgasm
2
+ class Config
3
+ # = Helpers Configuration
4
+ # Provide configuration for searchgasm's rails helpers
5
+ #
6
+ # === Example
7
+ # Searchgasm::Config.configure do |config|
8
+ # config.helpers.order_by_link_asc_indicator = "ASC"
9
+ # end
10
+ class Helpers
11
+ class << self
12
+ # Which hidden fields to automatically include when creating a form with a Searchgasm object. See Searchgasm::Helpers::Form for more info.
13
+ #
14
+ # * <tt>Default:</tt> [:order_by, :order_as, :per_page]
15
+ # * <tt>Accepts:</tt> Array, nil, false
16
+ def hidden_fields
17
+ @hidden_fields ||= (Searchgasm::Search::Base::SPECIAL_FIND_OPTIONS - [:page, :priority_order])
18
+ end
19
+ attr_writer :hidden_fields
20
+
21
+ # The class name for used in the order_as_link helper
22
+ #
23
+ # * <tt>Default:</tt> "order_as"
24
+ # * <tt>Accepts:</tt> String
25
+ def order_as_link_class_name
26
+ @order_as_link_class_name ||= "order_as"
27
+ end
28
+ attr_writer :order_as_link_class_name
29
+
30
+ # The class name for used in the order_as_select helper
31
+ #
32
+ # * <tt>Default:</tt> "order_as"
33
+ # * <tt>Accepts:</tt> String
34
+ def order_as_select_class_name
35
+ @order_as_select_class_name ||= "order_as"
36
+ end
37
+ attr_writer :order_as_select_class_name
38
+
39
+ # The indicator that is used when the sort of a column is ascending
40
+ #
41
+ # * <tt>Default:</tt> &nbsp;&#9650;
42
+ # * <tt>Accepts:</tt> String or a Proc.
43
+ #
44
+ # === Examples
45
+ #
46
+ # config.asc_indicator = "(ASC)"
47
+ # config.asc_indicator = Proc.new { |template| template.image_tag("asc.jpg") }
48
+ def order_by_link_asc_indicator
49
+ @order_by_link_asc_indicator ||= "&nbsp;&#9650;"
50
+ end
51
+ attr_writer :order_by_link_asc_indicator
52
+
53
+ # The class name for used in the order_by_link helper
54
+ #
55
+ # * <tt>Default:</tt> "order_by"
56
+ # * <tt>Accepts:</tt> String
57
+ def order_by_link_class_name
58
+ @order_by_link_class_name ||= "order_by"
59
+ end
60
+ attr_writer :order_by_link_class_name
61
+
62
+ # See order_by_link_asc_indicator=
63
+ def order_by_link_desc_indicator
64
+ @order_by_link_desc_indicator ||= "&nbsp;&#9660;"
65
+ end
66
+ attr_writer :order_by_link_desc_indicator
67
+
68
+ # The class name for used in the order_by_select helper
69
+ #
70
+ # * <tt>Default:</tt> "order_by"
71
+ # * <tt>Accepts:</tt> String
72
+ def order_by_select_class_name
73
+ @order_by_select_class_name ||= "order_by"
74
+ end
75
+ attr_writer :order_by_select_class_name
76
+
77
+ # The class name for used in the page_link helper
78
+ #
79
+ # * <tt>Default:</tt> "page"
80
+ # * <tt>Accepts:</tt> String
81
+ def page_link_class_name
82
+ @page_link_class_name ||= "page"
83
+ end
84
+ attr_writer :page_link_class_name
85
+
86
+ # The choices used in the per_page_links helper. Works just like per_page_select_choices.
87
+ def per_page_links_choices
88
+ @per_page_links_choices ||= per_page_select_choices
89
+ end
90
+ attr_writer :per_page_links_choices
91
+
92
+ # The class that the current page link gets.
93
+ #
94
+ # * <tt>Default:</tt> "current_page"
95
+ # * <tt>Accepts:</tt> String, set to nil to disable
96
+ def page_links_current_page_class_name
97
+ @page_links_current_page_class_name ||= "current_page"
98
+ end
99
+ attr_writer :page_links_current_page_class_name
100
+
101
+ # The class that disabled page links get. Including the current page, prev page, next page, first page, and last page.
102
+ #
103
+ # * <tt>Default:</tt> "disabled_page"
104
+ # * <tt>Accepts:</tt> String, set to nil to disable
105
+ def page_links_disabled_class_name
106
+ @page_links_disabled_class_name ||= "disabled_page"
107
+ end
108
+ attr_writer :page_links_disabled_class_name
109
+
110
+ # The default for the :first option for the page_links helper.
111
+ #
112
+ # * <tt>Default:</tt> nil
113
+ # * <tt>Accepts:</tt> Anything you want, text, html, etc. nil to disable
114
+ def page_links_first
115
+ @page_links_first
116
+ end
117
+ attr_writer :page_links_first
118
+
119
+ # The default for the :inner_spread option for the page_links helper.
120
+ #
121
+ # * <tt>Default:</tt> 3
122
+ # * <tt>Accepts:</tt> Any integer >= 1, set to nil to show all pages
123
+ def page_links_inner_spread
124
+ @page_links_inner_spread ||= 3
125
+ end
126
+ attr_writer :page_links_inner_spread
127
+
128
+ # The class for the first page link
129
+ #
130
+ # * <tt>Default:</tt> "first_page"
131
+ # * <tt>Accepts:</tt> String, nil to disable
132
+ def page_links_first_page_class_name
133
+ @page_links_first_page_class_name ||= "first_page"
134
+ end
135
+ attr_writer :page_links_first_page_class_name
136
+
137
+ # The default for the :last option for the page_links helper.
138
+ #
139
+ # * <tt>Default:</tt> nil
140
+ # * <tt>Accepts:</tt> Anything you want, text, html, etc. nil to disable
141
+ def page_links_last
142
+ @page_links_last
143
+ end
144
+ attr_writer :page_links_last
145
+
146
+ # The class for the last page link
147
+ #
148
+ # * <tt>Default:</tt> "last_page"
149
+ # * <tt>Accepts:</tt> String, nil to disable
150
+ def page_links_last_page_class_name
151
+ @page_links_last_page_class_name ||= "last_page"
152
+ end
153
+ attr_writer :page_links_last_page_class_name
154
+
155
+ # The default for the :next option for the page_links helper.
156
+ #
157
+ # * <tt>Default:</tt> "Next >"
158
+ # * <tt>Accepts:</tt> Anything you want, text, html, etc. nil to disable
159
+ def page_links_next
160
+ @page_links_next ||= "Next &gt;"
161
+ end
162
+ attr_writer :page_links_next
163
+
164
+ # The class for the next page link
165
+ #
166
+ # * <tt>Default:</tt> "next_page"
167
+ # * <tt>Accepts:</tt> String, nil to disable
168
+ def page_links_next_page_class_name
169
+ @page_links_next_page_class_name ||= "next_page"
170
+ end
171
+ attr_writer :page_links_next_page_class_name
172
+
173
+ # The default for the :outer_spread option for the page_links helper.
174
+ #
175
+ # * <tt>Default:</tt> 2
176
+ # * <tt>Accepts:</tt> Any integer >= 1, set to nil to display, 0 to only show the "..." separator
177
+ def page_links_outer_spread
178
+ @page_links_outer_spread ||= 1
179
+ end
180
+ attr_writer :page_links_outer_spread
181
+
182
+ # The class for the previous page link
183
+ #
184
+ # * <tt>Default:</tt> "prev_page"
185
+ # * <tt>Accepts:</tt> String, nil to disable
186
+ def page_links_prev_page_class_name
187
+ @page_links_prev_page_class_name ||= "prev_page"
188
+ end
189
+ attr_writer :page_links_prev_page_class_name
190
+
191
+ # The default for the :prev option for the page_links helper.
192
+ #
193
+ # * <tt>Default:</tt> "< Prev"
194
+ # * <tt>Accepts:</tt> Anything you want, text, html, etc. nil to disable
195
+ def page_links_prev
196
+ @page_links_prev ||= "&lt; Prev"
197
+ end
198
+ attr_writer :page_links_prev
199
+
200
+ # The class name for used in the page_seect helper
201
+ #
202
+ # * <tt>Default:</tt> "page"
203
+ # * <tt>Accepts:</tt> String
204
+ def page_select_class_name
205
+ @page_select_class_name ||= "page"
206
+ end
207
+ attr_writer :page_select_class_name
208
+
209
+ # The class name for used in the per_page_link helper
210
+ #
211
+ # * <tt>Default:</tt> "per_page"
212
+ # * <tt>Accepts:</tt> String
213
+ def per_page_link_class_name
214
+ @per_page_link_class_name ||= "per_page"
215
+ end
216
+ attr_writer :per_page_link_class_name
217
+
218
+ # The choices used in the per_page_select helper
219
+ #
220
+ # * <tt>Default:</tt> [["10 per page", 10], ["25 per page", 25], ["50 per page", 50], ["100 per page", 100], ["150 per page", 150], ["200 per page", 200], ["Show all", nil]]
221
+ # * <tt>Accepts:</tt> Array
222
+ def per_page_select_choices
223
+ return @per_page_select_choices if @per_page_select_choices
224
+ @per_page_select_choices = []
225
+ [10, 25, 50, 100, 150, 200].each { |choice| @per_page_select_choices << ["#{choice} per page", 25] }
226
+ @per_page_select_choices << ["Show all", nil]
227
+ end
228
+ attr_writer :per_page_select_choices
229
+
230
+ # The class name for used in the per_page_select helper
231
+ #
232
+ # * <tt>Default:</tt> "per_page"
233
+ # * <tt>Accepts:</tt> String
234
+ def per_page_select_class_name
235
+ @per_page_select_class_name ||= "per_page"
236
+ end
237
+ attr_writer :per_page_select_class_name
238
+
239
+ # The default value for the :activate_text option for priority_order_by_link
240
+ #
241
+ # * <tt>Default:</tt> "Show %s first"
242
+ # * <tt>Accepts:</tt> String with substitutions, using rubys % method for strings
243
+ def priority_order_by_link_activate_text
244
+ @priority_order_by_link_activate_text ||= "Show %s first"
245
+ end
246
+ attr_writer :priority_order_by_link_activate_text
247
+
248
+ # The class name for used in the priority_order_by_link helper
249
+ #
250
+ # * <tt>Default:</tt> "priority_order_by"
251
+ # * <tt>Accepts:</tt> String
252
+ def priority_order_by_link_class_name
253
+ @priority_order_by_link_class_name ||= "priority_order_by"
254
+ end
255
+ attr_writer :priority_order_by_link_class_name
256
+
257
+ # The default value for the :deactivate_text option for priority_order_by_link
258
+ #
259
+ # * <tt>Default:</tt> "Dont' show %s first"
260
+ # * <tt>Accepts:</tt> String with substitutions, using rubys % method for strings
261
+ def priority_order_by_link_deactivate_text
262
+ @priority_order_by_link_deactivate_text ||= "Don't show %s first"
263
+ end
264
+ attr_writer :priority_order_by_link_deactivate_text
265
+ end
266
+ end
267
+ end
268
+ end
@@ -0,0 +1,53 @@
1
+ module Searchgasm
2
+ class Config
3
+ # = Search Configuration
4
+ # Provides configuration for searchgasm
5
+ #
6
+ # === Example
7
+ # Searchgasm::Config.configure do |config|
8
+ # config.search.per_page = 50
9
+ # end
10
+ class Search
11
+ class << self
12
+ # The default for per page. This is only applicaple for protected searches. Meaning you start the search with new_search or new_conditions.
13
+ # The reason for this not to disturb regular queries such as Whatever.find(:all). You would not expect that to be limited.
14
+ #
15
+ # * <tt>Default:</tt> The 2nd option in your per_page_choices, default of 25
16
+ # * <tt>Accepts:</tt> Any value in your per_page choices, nil or a blank string means "show all"
17
+ def per_page
18
+ return @per_page if @set_per_page
19
+ per_page = Helpers.per_page_select_choices[1]
20
+ per_page = per_page.last if per_page.is_a?(Array)
21
+ @per_page = per_page
22
+ end
23
+
24
+ def per_page=(value)
25
+ @set_per_page = true
26
+ @per_page = value
27
+ end
28
+
29
+ # If you are using ActiveRecord < 2.2.0 then ActiveRecord does not remove duplicates when using the :joins option, when it should. To fix this problem searchgasm does this for you. Searchgasm tries to act
30
+ # just like ActiveRecord, but in this instance it doesn't make sense.
31
+ #
32
+ # As a result, Searchgasm removes all duplicates results in *ALL* search / calculation queries. It does this by forcing the DISTINCT or GROUP BY operation in your SQL. Which might come as a surprise to you
33
+ # since it is not the "norm". If you don't want searchgasm to do this, set this to false.
34
+ #
35
+ # * <tt>Default:</tt> true
36
+ # * <tt>Accepts:</tt> Boolean
37
+ def remove_duplicates
38
+ return @remove_duplicates if @set_remove_duplicates
39
+ @remove_duplicates ||= true
40
+ end
41
+
42
+ def remove_duplicates? # :nodoc:
43
+ remove_duplicates == true
44
+ end
45
+
46
+ def remove_duplicates=(value) # :nodoc:
47
+ @set_remove_duplicates = true
48
+ @remove_duplicates = value
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -1,14 +1,16 @@
1
1
  module Searchgasm
2
2
  # = Config
3
- # Adds default configuration for all of searchgasm. Just make sure you set your config before you use Searchgasm.
4
- # For rails the best place to do this is in config/initializers. Create a file in there called searchgasm.rb with the following content:
3
+ # Adds default configuration for all of searchgasm. For rails the best place to do this is in config/initializers. Create a file in there called searchgasm.rb with the following content:
5
4
  #
6
5
  # === Example
7
6
  #
8
7
  # # config/iniitializers/searchgasm.rb
9
8
  # Searchgasm::Config.configure do |config|
10
- # config.you_option_here = your_value # see methods below
9
+ # config.search.per_page = 25
10
+ # config.helpers.order_by_link_asc_indicator = "My indicator"
11
11
  # end
12
+ #
13
+ # For a list of all configuration options see Searchgasm::Config::Search and Searchgasm::Config::Helpers
12
14
  class Config
13
15
  class << self
14
16
  # Convenience method for setting configuration
@@ -17,212 +19,12 @@ module Searchgasm
17
19
  yield self
18
20
  end
19
21
 
20
- def asc_indicator # :nodoc:
21
- @asc_indicator ||= "&nbsp;&#9650;"
22
- end
23
-
24
- # The indicator that is used when the sort of a column is ascending
25
- #
26
- # * <tt>Default:</tt> &nbsp;&#9650;
27
- # * <tt>Accepts:</tt> String or a Proc.
28
- #
29
- # === Examples
30
- #
31
- # config.asc_indicator = "(ASC)"
32
- # config.asc_indicator = Proc.new { |template| template.image_tag("asc.jpg") }
33
- def asc_indicator=(value)
34
- @asc_indicator = value
35
- end
36
-
37
- def desc_indicator # :nodoc:
38
- @desc_indicator ||= "&nbsp;&#9660;"
39
- end
40
-
41
- # See asc_indicator=
42
- def desc_indicator=(value)
43
- @desc_indicator = value
44
- end
45
-
46
- def hidden_fields # :nodoc:
47
- @hidden_fields ||= (Search::Base::SPECIAL_FIND_OPTIONS - [:page, :priority_order])
48
- end
49
-
50
- # Which hidden fields to automatically include when creating a form with a Searchgasm object. See Searchgasm::Helpers::Form for more info.
51
- #
52
- # * <tt>Default:</tt> [:order_by, :order_as, :per_page]
53
- # * <tt>Accepts:</tt> Array, nil, false
54
- def hidden_fields=(value)
55
- @hidden_fields = value
56
- end
57
-
58
- def page_links_first # :nodoc:
59
- @page_links_first
60
- end
61
-
62
- # The default for the :first option for the page_links helper.
63
- #
64
- # * <tt>Default:</tt> nil
65
- # * <tt>Accepts:</tt> Anything you want, text, html, etc. nil to disable
66
- def page_links_first=(value)
67
- @page_links_first = value
68
- end
69
-
70
- def page_links_last # :nodoc:
71
- @page_links_last
72
- end
73
-
74
- # The default for the :last option for the page_links helper.
75
- #
76
- # * <tt>Default:</tt> nil
77
- # * <tt>Accepts:</tt> Anything you want, text, html, etc. nil to disable
78
- def page_links_last=(value)
79
- @page_links_last = value
80
- end
81
-
82
- def page_links_inner_spread # :nodoc:
83
- @page_links_inner_spread ||= 3
84
- end
85
-
86
- # The default for the :inner_spread option for the page_links helper.
87
- #
88
- # * <tt>Default:</tt> 3
89
- # * <tt>Accepts:</tt> Any integer >= 1, set to nil to show all pages
90
- def page_links_inner_spread=(value)
91
- @page_links_inner_spread = value
92
- end
93
-
94
- def page_links_outer_spread # :nodoc:
95
- @page_links_outer_spread ||= 1
96
- end
97
-
98
- # The default for the :outer_spread option for the page_links helper.
99
- #
100
- # * <tt>Default:</tt> 2
101
- # * <tt>Accepts:</tt> Any integer >= 1, set to nil to display, 0 to only show the "..." separator
102
- def page_links_outer_spread=(value)
103
- @page_links_outer_spread = value
104
- end
105
-
106
- def page_links_next # :nodoc:
107
- @page_links_next ||= "Next >"
108
- end
109
-
110
- # The default for the :next option for the page_links helper.
111
- #
112
- # * <tt>Default:</tt> "Next >"
113
- # * <tt>Accepts:</tt> Anything you want, text, html, etc. nil to disable
114
- def page_links_next=(value)
115
- @page_links_next = value
116
- end
117
-
118
- def page_links_prev # :nodoc:
119
- @page_links_prev ||= "< Prev"
120
- end
121
-
122
- # The default for the :prev option for the page_links helper.
123
- #
124
- # * <tt>Default:</tt> "< Prev"
125
- # * <tt>Accepts:</tt> Anything you want, text, html, etc. nil to disable
126
- def page_links_prev=(value)
127
- @page_links_prev = value
128
- end
129
-
130
- def per_page # :nodoc:
131
- @per_page ||= per_page_choices[1]
132
- end
133
-
134
- # The default for per page. This is only applicaple for protected searches. Meaning you start the search with new_search or new_conditions.
135
- # The reason for this not to disturb regular queries such as Whatever.find(:all). You would not expect that to be limited.
136
- #
137
- # * <tt>Default:</tt> The 3rd option in your per_page_choices, default of 50
138
- # * <tt>Accepts:</tt> Any value in your per_page choices, nil or a blank string means "show all"
139
- def per_page=(value)
140
- @per_page = value
141
- end
142
-
143
- def per_page_choices # :nodoc:
144
- @per_page_choices ||= [10, 25, 50, 100, 150, 200, nil]
145
- end
146
-
147
- # The choices used in the per_page helper
148
- #
149
- # * <tt>Default:</tt> [10, 25, 50, 100, 150, 200, nil]
150
- # * <tt>Accepts:</tt> Array
151
- #
152
- # nil means "Show all"
153
- def per_page_choices=(value)
154
- @per_page_choices = value
155
- end
156
-
157
- def per_page_show_all_text # :nodoc:
158
- @per_page_show_all_text ||= "Show all"
159
- end
160
-
161
- # The default value for the :text option for per_page_links and per_page_select when the page is nil, meaning show all.
162
- #
163
- # * <tt>Default:</tt> "Show all"
164
- # * <tt>Accepts:</tt> String
165
- def per_page_show_all_text=(value)
166
- @per_page_show_all_text = value
167
- end
168
-
169
- def per_page_text # :nodoc:
170
- @per_page_text ||= "%s per page"
171
- end
172
-
173
- # The default value for the :text option for per_page_links and per_page_select when the page is NOT nil. Only one substitution is
174
- # passed, which is the per_page value.
175
- #
176
- # * <tt>Default:</tt> "%s per page"
177
- # * <tt>Accepts:</tt> String with substitutions, using rubys % method for strings
178
- def per_page_text=(value)
179
- @per_page_text = value
180
- end
181
-
182
- def priority_order_by_link_activate_text # :nodoc:
183
- @priority_order_by_link_activate_text ||= "Show %s first"
184
- end
185
-
186
- # The default value for the :activate_text option for priority_order_by_link
187
- #
188
- # * <tt>Default:</tt> "Show %s first"
189
- # * <tt>Accepts:</tt> String with substitutions, using rubys % method for strings
190
- def priority_order_by_link_activate_text=(value)
191
- @priority_order_by_link_activate_text = value
192
- end
193
-
194
- def priority_order_by_link_deactivate_text # :nodoc:
195
- @priority_order_by_link_deactivate_text ||= "Don't show %s first"
196
- end
197
-
198
- # The default value for the :deactivate_text option for priority_order_by_link
199
- #
200
- # * <tt>Default:</tt> "Dont' show %s first"
201
- # * <tt>Accepts:</tt> String with substitutions, using rubys % method for strings
202
- def priority_order_by_link_deactivate_text=(value)
203
- @priority_order_by_link_deactivate_text = value
204
- end
205
-
206
- def remove_duplicates # :nodoc:
207
- return @remove_duplicates if @set_remove_duplicates
208
- @remove_duplicates ||= true
209
- end
210
-
211
- def remove_duplicates? # :nodoc:
212
- remove_duplicates == true
22
+ def search # :nodoc:
23
+ Search
213
24
  end
214
25
 
215
- # If you are using ActiveRecord < 2.2.0 then ActiveRecord does not remove duplicates when using the :joins option, when it should. To fix this problem searchgasm does this for you. Searchgasm tries to act
216
- # just like ActiveRecord, but in this instance it doesn't make sense.
217
- #
218
- # As a result, Searchgasm removes all duplicates results in *ALL* search / calculation queries. It does this by forcing the DISTINCT or GROUP BY operation in your SQL. Which might come as a surprise to you
219
- # since it is not the "norm". If you don't want searchgasm to do this, set this to false.
220
- #
221
- # * <tt>Default:</tt> true
222
- # * <tt>Accepts:</tt> Boolean
223
- def remove_duplicates=(value)
224
- @set_remove_duplicates = true
225
- @remove_duplicates = value
26
+ def helpers # :nodoc:
27
+ Helpers
226
28
  end
227
29
  end
228
30
  end
@@ -181,8 +181,6 @@ module Searchgasm
181
181
  # As you can see above, passing nil means "show all" and the text will automatically revert to "show all"
182
182
  #
183
183
  # === Options
184
- # * <tt>:text</tt> -- default: "%s per page", text for the link, only if per_page is not blank
185
- # * <tt>:show_all_text</tt> -- default: "Show all", text for the link, only if per_page is blank
186
184
  # * <tt>:html</tt> -- html arrtributes for the <a> tag.
187
185
  #
188
186
  # === Advanced Options
@@ -239,29 +237,32 @@ module Searchgasm
239
237
 
240
238
  private
241
239
  def add_order_by_link_defaults!(order_by, options = {})
242
- add_searchgasm_control_defaults!(:order_by, options)
240
+ add_searchgasm_control_defaults!(options)
241
+ searchgasm_add_class!(options[:html], Config.helpers.order_by_link_class_name)
243
242
  ordering_by_this = searchgasm_ordering_by?(order_by, options)
244
243
  searchgasm_add_class!(options[:html], "ordering") if ordering_by_this
245
244
  options[:text] ||= determine_order_by_text(order_by)
246
- options[:asc_indicator] ||= Config.asc_indicator
247
- options[:desc_indicator] ||= Config.desc_indicator
245
+ options[:asc_indicator] ||= Config.helpers.order_by_link_asc_indicator
246
+ options[:desc_indicator] ||= Config.helpers.order_by_link_desc_indicator
248
247
  options[:text] += options[:search_obj].desc? ? options[:desc_indicator] : options[:asc_indicator] if ordering_by_this
249
248
  options[:url] = searchgasm_params(options.merge(:search_params => {:order_by => order_by}))
250
249
  options
251
250
  end
252
251
 
253
252
  def add_order_as_link_defaults!(order_as, options = {})
254
- add_searchgasm_control_defaults!(:order_as, options)
253
+ add_searchgasm_control_defaults!(options)
254
+ searchgasm_add_class!(options[:html], Config.helpers.order_as_link_class_name)
255
255
  options[:text] ||= order_as.to_s
256
256
  options[:url] = searchgasm_params(options.merge(:search_params => {:order_as => order_as}))
257
257
  options
258
258
  end
259
259
 
260
260
  def add_priority_order_by_link_defaults!(priority_order_by, priority_order_as, options = {})
261
- add_searchgasm_control_defaults!(:priority_order_by, options)
261
+ add_searchgasm_control_defaults!(options)
262
+ searchgasm_add_class!(options[:html], Config.helpers.priority_order_by_link_class_name)
262
263
  options[:column_name] ||= determine_order_by_text(priority_order_by).downcase
263
- options[:activate_text] ||= Config.priority_order_by_link_activate_text % options[:column_name]
264
- options[:deactivate_text] ||= Config.priority_order_by_link_deactivate_text % options[:column_name]
264
+ options[:activate_text] ||= Config.helpers.priority_order_by_link_activate_text % options[:column_name]
265
+ options[:deactivate_text] ||= Config.helpers.priority_order_by_link_deactivate_text % options[:column_name]
265
266
  active = deep_stringify(options[:search_obj].priority_order_by) == deep_stringify(priority_order_by) && options[:search_obj].priority_order_as == priority_order_as
266
267
  options[:text] ||= active ? options[:deactivate_text] : options[:activate_text]
267
268
  if active
@@ -274,15 +275,16 @@ module Searchgasm
274
275
  end
275
276
 
276
277
  def add_per_page_link_defaults!(per_page, options = {})
277
- add_searchgasm_control_defaults!(:per_page, options)
278
- options[:show_all_text] ||= Config.per_page_show_all_text
279
- options[:text] ||= per_page.blank? ? options[:show_all_text] : Config.per_page.text % per_page
278
+ add_searchgasm_control_defaults!(options)
279
+ searchgasm_add_class!(options[:html], Config.helpers.per_page_link_class_name)
280
+ options[:text] ||= per_page.to_s
280
281
  options[:url] = searchgasm_params(options.merge(:search_params => {:per_page => per_page}))
281
282
  options
282
283
  end
283
284
 
284
285
  def add_page_link_defaults!(page, options = {})
285
- add_searchgasm_control_defaults!(:page, options)
286
+ add_searchgasm_control_defaults!(options)
287
+ searchgasm_add_class!(options[:html], Config.helpers.page_link_class_name)
286
288
  options[:text] ||= page.to_s
287
289
  options[:url] = searchgasm_params(options.merge(:search_params => {:page => page}))
288
290
  options
@@ -16,10 +16,15 @@ module Searchgasm
16
16
  # * <tt>:choices</tt> -- default: the models column names, the choices to loop through when calling order_by_link
17
17
  def order_by_links(options = {})
18
18
  add_order_by_links_defaults!(options)
19
- link_options = options.deep_dup
20
- link_options.delete(:choices)
19
+ links_options = options.deep_dup
20
+ links_options.delete(:choices)
21
21
  html = ""
22
- options[:choices].each { |choice| html += order_by_link(choice, link_options.deep_dup) }
22
+ options[:choices].each do |choice|
23
+ link_options = links_option.deep_dup
24
+ text, value = option_text_and_value(choice)
25
+ link_options[:text] ||= text
26
+ html += order_by_link(value, link_options)
27
+ end
23
28
  html
24
29
  end
25
30
 
@@ -37,10 +42,15 @@ module Searchgasm
37
42
  # * <tt>:choices</tt> -- default: ["asc", "desc"], the choices to loop through when calling order_as_link
38
43
  def order_as_links(options = {})
39
44
  add_order_as_links_defaults!(options)
40
- link_options = options.deep_dup
41
- link_options.delete(:choices)
45
+ links_options = options.deep_dup
46
+ links_options.delete(:choices)
42
47
  html = ""
43
- options[:choices].each { |choice| html += order_as_link(choice, link_options.deep_dup) }
48
+ options[:choices].each do |choice|
49
+ link_options = links_option.deep_dup
50
+ text, value = option_text_and_value(choice)
51
+ link_options[:text] ||= text
52
+ html += order_as_link(value, link_options)
53
+ end
44
54
  html
45
55
  end
46
56
 
@@ -55,13 +65,18 @@ module Searchgasm
55
65
  #
56
66
  # Please look at per_page_link. All options there are applicable here and are passed onto each option.
57
67
  #
58
- # * <tt>:choices</tt> -- default: [10, 25, 50, 100, 150, 200, nil], the choices to loop through when calling per_page_link.
68
+ # * <tt>:choices</tt> -- default: [["10 per page", 10], ["25 per page", 25], ["50 per page", 50], ["100 per page", 100], ["150 per page", 150], ["200 per page", 200], ["Show all", nil]]
59
69
  def per_page_links(options = {})
60
70
  add_per_page_links_defaults!(options)
61
- link_options = options.deep_dup
62
- link_options.delete(:choices)
71
+ links_options = options.deep_dup
72
+ links_options.delete(:choices)
63
73
  html = ""
64
- options[:choices].each { |choice| html += per_page_link(choice, link_options.deep_dup) }
74
+ options[:choices].each do |choice|
75
+ link_options = links_option.deep_dup
76
+ text, value = option_text_and_value(choice)
77
+ link_options[:text] ||= text
78
+ html += per_page_link(value, link_options)
79
+ end
65
80
  html
66
81
  end
67
82
 
@@ -148,41 +163,45 @@ module Searchgasm
148
163
 
149
164
  private
150
165
  def add_order_by_links_defaults!(options)
151
- add_searchgasm_control_defaults!(:order_by, options)
166
+ add_searchgasm_control_defaults!(options)
152
167
  options[:choices] ||= options[:search_obj].klass.column_names.map(&:humanize)
153
168
  options
154
169
  end
155
170
 
156
171
  def add_order_as_links_defaults!(options)
157
- add_searchgasm_control_defaults!(:order_as, options)
172
+ add_searchgasm_control_defaults!(options)
158
173
  options[:choices] = [:asc, :desc]
159
174
  options
160
175
  end
161
176
 
162
177
  def add_per_page_links_defaults!(options)
163
- add_searchgasm_control_defaults!(:per_page, options)
164
- options[:choices] ||= Config.per_page_choices.dup
178
+ add_searchgasm_control_defaults!(options)
179
+ options[:choices] ||= Config.helpers.per_page_links_choices.dup
165
180
  if !options[:search_obj].per_page.blank? && !options[:choices].include?(options[:search_obj].per_page)
166
181
  options[:choices] << options[:search_obj].per_page
167
182
  has_nil = options[:choices].include?(nil)
168
183
  options[:choices].compact!
169
- options[:choices].sort!
184
+ options[:choices].sort! do |a, b|
185
+ a_value = (a.is_a?(Array) ? a.last : a).to_i
186
+ b_value = (b.is_a?(Array) ? b.last : b).to_i
187
+ a_value <=> b_value
188
+ end
170
189
  options[:choices] << nil if has_nil
171
190
  end
172
191
  options
173
192
  end
174
193
 
175
194
  def add_page_links_defaults!(options)
176
- add_searchgasm_control_defaults!(:page, options)
195
+ add_searchgasm_control_defaults!(options)
177
196
  options[:first_page] ||= 1
178
197
  options[:last_page] ||= options[:search_obj].page_count
179
198
  options[:current_page] ||= options[:search_obj].page
180
- options[:inner_spread] = Config.page_links_inner_spread unless options.has_key?(:inner_spread)
181
- options[:outer_spread] = Config.page_links_outer_spread unless options.has_key?(:outer_spread)
182
- options[:prev] = Config.page_links_prev unless options.has_key?(:prev)
183
- options[:next] = Config.page_links_next unless options.has_key?(:next)
184
- options[:first] = Config.page_links_first unless options.has_key?(:first)
185
- options[:last] = Config.page_links_last unless options.has_key?(:last)
199
+ options[:inner_spread] = Config.helpers.page_links_inner_spread unless options.has_key?(:inner_spread)
200
+ options[:outer_spread] = Config.helpers.page_links_outer_spread unless options.has_key?(:outer_spread)
201
+ options[:prev] = Config.helpers.page_links_prev unless options.has_key?(:prev)
202
+ options[:next] = Config.helpers.page_links_next unless options.has_key?(:next)
203
+ options[:first] = Config.helpers.page_links_first unless options.has_key?(:first)
204
+ options[:last] = Config.helpers.page_links_last unless options.has_key?(:last)
186
205
  options
187
206
  end
188
207
 
@@ -193,14 +212,17 @@ module Searchgasm
193
212
  when Fixnum
194
213
  text = name
195
214
  page = name
196
- searchgasm_add_class!(options[:html], "current_page") if span
215
+ searchgasm_add_class!(options[:html], Config.helpers.page_links_current_page_class_name) if span
197
216
  else
198
217
  text = options[name]
199
218
  page = options[:search_obj].send("#{name}_page")
200
- searchgasm_add_class!(options[:html], "#{name}_page")
219
+ searchgasm_add_class!(options[:html], Config.helpers.send("page_links_#{name}_page_class_name"))
201
220
  end
202
221
 
203
- searchgasm_add_class!(options[:html], "disabled_page") if span
222
+ if span
223
+ searchgasm_add_class!(options[:html], Config.helpers.page_links_disabled_class_name)
224
+ searchgasm_add_class!(options[:html], "page")
225
+ end
204
226
  options[:text] = text
205
227
  span ? content_tag(:span, text, options[:html]) : page_link(page, options)
206
228
  end
@@ -32,27 +32,28 @@ module Searchgasm
32
32
  private
33
33
  def add_order_by_select_defaults!(options)
34
34
  add_order_by_links_defaults!(options)
35
+ searchgasm_add_class!(options[:html], Config.helpers.order_by_select_class_name)
35
36
  add_searchgasm_select_defaults!(:order_by, options)
36
37
  options
37
38
  end
38
39
 
39
40
  def add_order_as_select_defaults!(options)
40
41
  add_order_as_links_defaults!(options)
42
+ searchgasm_add_class!(options[:html], Config.helpers.order_as_select_class_name)
41
43
  add_searchgasm_select_defaults!(:order_as, options)
42
44
  options
43
45
  end
44
46
 
45
47
  def add_per_page_select_defaults!(options)
46
48
  add_per_page_links_defaults!(options)
47
- options[:show_all_text] ||= Config.per_page_show_all_text
48
- options[:text] ||= Config.per_page_text
49
- options[:choices] = options[:choices].collect { |choice| choice.nil? ? [options[:show_all_text], choice] : [options[:text] % choice, choice]}
49
+ searchgasm_add_class!(options[:html], Config.helpers.per_page_select_class_name)
50
50
  add_searchgasm_select_defaults!(:per_page, options)
51
51
  options
52
52
  end
53
53
 
54
54
  def add_page_select_defaults!(options)
55
55
  add_page_links_defaults!(options)
56
+ searchgasm_add_class!(options[:html], Config.helpers.page_select_class_name)
56
57
  add_searchgasm_select_defaults!(:page, options)
57
58
  options
58
59
  end
@@ -55,12 +55,12 @@ module Searchgasm
55
55
  def extract_searchgasm_options!(args)
56
56
  options = args.extract_options!
57
57
  searchgasm_options = {}
58
- [:hidden_fields].each { |option| searchgasm_options[option] = options.has_key?(option) ? options.delete(option) : Config.send(option) }
58
+ [:hidden_fields].each { |option| searchgasm_options[option] = options.has_key?(option) ? options.delete(option) : Config.helpers.send(option) }
59
59
  searchgasm_options[:hidden_fields] = [searchgasm_options[:hidden_fields]].flatten.compact
60
60
  args << options
61
61
  searchgasm_options
62
62
  end
63
-
63
+
64
64
  def searchgasm_args(args, search_object, search_options, for_helper = nil)
65
65
  args = args.dup
66
66
  first = args.shift
@@ -93,7 +93,7 @@ module Searchgasm
93
93
 
94
94
  javascript = "if(typeof(Prototype) != 'undefined') {"
95
95
  search_options[:hidden_fields].each { |field| javascript += "field = $('#{name}_#{field}'); if(field) { $('#{name}_#{field}_hidden').value = field.value; }" }
96
- javascript += "} else if(jQuery) {"
96
+ javascript += "} else if(typeof(jQuery) != 'undefined') {"
97
97
  search_options[:hidden_fields].each { |field| javascript += "field = $('##{name}_#{field}'); if(field) { $('##{name}_#{field}_hidden').val(field.val()); }" }
98
98
  javascript += "}"
99
99
 
@@ -127,16 +127,15 @@ module Searchgasm
127
127
  end
128
128
 
129
129
  # Adds default options for all control type helper methods.
130
- def add_searchgasm_control_defaults!(option, options)
130
+ def add_searchgasm_control_defaults!(options)
131
131
  add_searchgasm_defaults!(options)
132
132
  options[:html] ||= {}
133
- options[:html][:class] ||= ""
134
- searchgasm_add_class!(options[:html], option)
135
133
  options
136
134
  end
137
135
 
138
136
  def searchgasm_add_class!(html_options, new_class)
139
137
  new_class = new_class.to_s
138
+ html_options[:class] ||= ""
140
139
  classes = html_options[:class].split(" ")
141
140
  classes << new_class unless classes.include?(new_class)
142
141
  html_options[:class] = classes.join(" ")
@@ -92,7 +92,7 @@ module Searchgasm #:nodoc:
92
92
  end
93
93
 
94
94
  def limit
95
- @limit ||= Config.per_page if !acting_as_filter? && !@set_limit
95
+ @limit ||= Config.search.per_page if !acting_as_filter? && !@set_limit
96
96
  @limit
97
97
  end
98
98
 
@@ -120,7 +120,7 @@ module Searchgasm #:nodoc:
120
120
  end
121
121
 
122
122
  def select
123
- @select ||= "DISTINCT #{klass.connection.quote_table_name(klass.table_name)}.*" if !joins.blank? && Config.remove_duplicates?
123
+ @select ||= "DISTINCT #{klass.connection.quote_table_name(klass.table_name)}.*" if !joins.blank? && Config.search.remove_duplicates?
124
124
  @select
125
125
  end
126
126
 
@@ -170,7 +170,7 @@ module Searchgasm
170
170
 
171
171
  case order_by
172
172
  when Array
173
- order_by.each { |part| sql_parts << order_by_to_order(part, order_as) }
173
+ order_by.each { |part| sql_parts << order_by_to_order(part, order_as, alt_klass) }
174
174
  when Hash
175
175
  raise(ArgumentError, "when passing a hash to order_by you must only have 1 key: {:user_group => :name} not {:user_group => :name, :user_group => :id}. The latter should be [{:user_group => :name}, {:user_group => :id}]") if order_by.keys.size != 1
176
176
  key = order_by.keys.first
@@ -66,8 +66,8 @@ module Searchgasm
66
66
  end
67
67
 
68
68
  MAJOR = 1
69
- MINOR = 4
70
- TINY = 1
69
+ MINOR = 5
70
+ TINY = 0
71
71
 
72
72
  # The current version as a Version instance
73
73
  CURRENT = new(MAJOR, MINOR, TINY)
data/lib/searchgasm.rb CHANGED
@@ -21,6 +21,8 @@ require "searchgasm/shared/virtual_classes"
21
21
 
22
22
  # Base classes
23
23
  require "searchgasm/version"
24
+ require "searchgasm/config/helpers"
25
+ require "searchgasm/config/search"
24
26
  require "searchgasm/config"
25
27
 
26
28
  # ActiveRecord
data/searchgasm.gemspec CHANGED
@@ -1,18 +1,18 @@
1
1
 
2
- # Gem::Specification for Searchgasm-1.4.1
2
+ # Gem::Specification for Searchgasm-1.5.0
3
3
  # Originally generated by Echoe
4
4
 
5
5
  --- !ruby/object:Gem::Specification
6
6
  name: searchgasm
7
7
  version: !ruby/object:Gem::Version
8
- version: 1.4.1
8
+ version: 1.5.0
9
9
  platform: ruby
10
10
  authors:
11
11
  - Ben Johnson of Binary Logic
12
12
  autorequire:
13
13
  bindir: bin
14
14
 
15
- date: 2008-10-15 00:00:00 -04:00
15
+ date: 2008-10-20 00:00:00 -04:00
16
16
  default_executable:
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
@@ -35,6 +35,16 @@ dependencies:
35
35
  - !ruby/object:Gem::Version
36
36
  version: "0"
37
37
  version:
38
+ - !ruby/object:Gem::Dependency
39
+ name: configatron
40
+ type: :runtime
41
+ version_requirement:
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: "0"
47
+ version:
38
48
  - !ruby/object:Gem::Dependency
39
49
  name: echoe
40
50
  type: :development
@@ -84,6 +94,8 @@ extra_rdoc_files:
84
94
  - lib/searchgasm/condition/tree.rb
85
95
  - lib/searchgasm/conditions/base.rb
86
96
  - lib/searchgasm/conditions/protection.rb
97
+ - lib/searchgasm/config/helpers.rb
98
+ - lib/searchgasm/config/search.rb
87
99
  - lib/searchgasm/config.rb
88
100
  - lib/searchgasm/core_ext/hash.rb
89
101
  - lib/searchgasm/helpers/control_types/link.rb
@@ -181,6 +193,8 @@ files:
181
193
  - lib/searchgasm/condition/tree.rb
182
194
  - lib/searchgasm/conditions/base.rb
183
195
  - lib/searchgasm/conditions/protection.rb
196
+ - lib/searchgasm/config/helpers.rb
197
+ - lib/searchgasm/config/search.rb
184
198
  - lib/searchgasm/config.rb
185
199
  - lib/searchgasm/core_ext/hash.rb
186
200
  - lib/searchgasm/helpers/control_types/link.rb
data/test/test_config.rb CHANGED
@@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/test_helper.rb'
2
2
 
3
3
  class TestConfig < Test::Unit::TestCase
4
4
  def test_per_page
5
- Searchgasm::Config.per_page = 1
5
+ Searchgasm::Config.search.per_page = 1
6
6
 
7
7
  assert Account.count > 1
8
8
  assert Account.all.size > 1
@@ -11,7 +11,7 @@ class TestConfig < Test::Unit::TestCase
11
11
  assert User.new_search.all.size == 1
12
12
  assert User.new_search(:per_page => nil).all.size > 1
13
13
 
14
- Searchgasm::Config.per_page = nil
14
+ Searchgasm::Config.search.per_page = nil
15
15
 
16
16
  assert Account.count > 1
17
17
  assert Account.all.size > 1
@@ -20,6 +20,4 @@ class TestConfig < Test::Unit::TestCase
20
20
  assert User.new_search.all.size > 1
21
21
  assert User.new_search(:per_page => 1).all.size == 1
22
22
  end
23
-
24
- # test that config options do not mess up regular AR searches
25
23
  end
@@ -63,7 +63,7 @@ class TestSearchPagination < Test::Unit::TestCase
63
63
  search.per_page = 100
64
64
  assert_equal 1, search.page_count
65
65
 
66
- Searchgasm::Config.per_page = 1
66
+ Searchgasm::Config.search.per_page = 1
67
67
  search = Account.new_search
68
68
  assert_equal 3, search.page_count
69
69
  search.conditions.users.first_name_contains
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: searchgasm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Johnson of Binary Logic
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-10-15 00:00:00 -04:00
12
+ date: 2008-10-20 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -32,6 +32,16 @@ dependencies:
32
32
  - !ruby/object:Gem::Version
33
33
  version: "0"
34
34
  version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: configatron
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
35
45
  - !ruby/object:Gem::Dependency
36
46
  name: echoe
37
47
  type: :development
@@ -81,6 +91,8 @@ extra_rdoc_files:
81
91
  - lib/searchgasm/condition/tree.rb
82
92
  - lib/searchgasm/conditions/base.rb
83
93
  - lib/searchgasm/conditions/protection.rb
94
+ - lib/searchgasm/config/helpers.rb
95
+ - lib/searchgasm/config/search.rb
84
96
  - lib/searchgasm/config.rb
85
97
  - lib/searchgasm/core_ext/hash.rb
86
98
  - lib/searchgasm/helpers/control_types/link.rb
@@ -178,6 +190,8 @@ files:
178
190
  - lib/searchgasm/condition/tree.rb
179
191
  - lib/searchgasm/conditions/base.rb
180
192
  - lib/searchgasm/conditions/protection.rb
193
+ - lib/searchgasm/config/helpers.rb
194
+ - lib/searchgasm/config/search.rb
181
195
  - lib/searchgasm/config.rb
182
196
  - lib/searchgasm/core_ext/hash.rb
183
197
  - lib/searchgasm/helpers/control_types/link.rb