meta_search 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +8 -0
- data/README.rdoc +1 -1
- data/VERSION +1 -1
- data/lib/meta_search/helpers/form_builder.rb +2 -4
- data/lib/meta_search/join_dependency.rb +1 -1
- data/lib/meta_search/searches/active_record.rb +33 -18
- data/lib/meta_search.rb +3 -3
- data/meta_search.gemspec +3 -4
- metadata +4 -30
data/CHANGELOG
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
Changes since 1.0.1 (2011-01-18):
|
2
|
+
* Include all non-boolean types in is_present and is_blank, to match
|
3
|
+
documentation
|
4
|
+
* Avoid setting alias to collection_check_boxes and check_boxes against
|
5
|
+
the base. Fixes issues with SimpleForm compatibility.
|
6
|
+
* Delegate page method to relation, for Kaminari support.
|
7
|
+
* Don't check for existence of attributes if the table doesn't exist yet.
|
8
|
+
|
1
9
|
Changes since 1.0.0 (2011-01-17):
|
2
10
|
* Update polymorphic join support to play nicely with MetaWhere
|
3
11
|
|
data/README.rdoc
CHANGED
@@ -33,7 +33,7 @@ In your view:
|
|
33
33
|
<%= f.submit %>
|
34
34
|
<% end %>
|
35
35
|
|
36
|
-
Options for the search method are documented at MetaSearch::Searches::
|
36
|
+
Options for the search method are documented at MetaSearch::Searches::ActiveRecord.
|
37
37
|
|
38
38
|
== "Wheres", and what they're good for
|
39
39
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.2
|
@@ -8,10 +8,8 @@ module MetaSearch
|
|
8
8
|
|
9
9
|
def self.included(base)
|
10
10
|
# Only take on the check_boxes method names if someone else (Hi, José!) hasn't grabbed them.
|
11
|
-
|
12
|
-
|
13
|
-
alias_method :collection_check_boxes, :collection_checks unless method_defined?(:collection_check_boxes)
|
14
|
-
end
|
11
|
+
alias_method :check_boxes, :checks unless method_defined?(:check_boxes)
|
12
|
+
alias_method :collection_check_boxes, :collection_checks unless method_defined?(:collection_check_boxes)
|
15
13
|
end
|
16
14
|
|
17
15
|
# Like other form_for field methods (text_field, hidden_field, password_field) etc,
|
@@ -27,7 +27,7 @@ module MetaSearch
|
|
27
27
|
case associations
|
28
28
|
when Symbol, String
|
29
29
|
reflection = parent.reflections[associations.to_s.intern] or
|
30
|
-
raise ConfigurationError, "Association named '#{
|
30
|
+
raise ConfigurationError, "Association named '#{ associations }' was not found; perhaps you misspelled it?"
|
31
31
|
unless (association = find_join_association(reflection, parent)) && (!polymorphic_class || association.active_record == polymorphic_class)
|
32
32
|
@reflections << reflection
|
33
33
|
if reflection.options[:polymorphic]
|
@@ -27,6 +27,17 @@ module MetaSearch
|
|
27
27
|
# MetaSearch::Builder, which behaves pretty much like an ActiveRecord::Relation,
|
28
28
|
# in that it doesn't actually query the database until you do something that
|
29
29
|
# requires it to do so.
|
30
|
+
#
|
31
|
+
# Options:
|
32
|
+
#
|
33
|
+
# * +params+ - a hash of valid searches with keys that are valid according to
|
34
|
+
# the docs in MetaSearch::Where.
|
35
|
+
# * +opts+ - A hash of additional information that will be passed through to
|
36
|
+
# the search's Builder object. +search_key+, if present, will override the
|
37
|
+
# default param name, 'search', in any sort_links generated by this Builder.
|
38
|
+
# All other keys are passed untouched to the builder, and available from the
|
39
|
+
# Builder's +options+ reader for use in :if blocks supplied to attr_searchable
|
40
|
+
# and friends.
|
30
41
|
def metasearch(params = nil, opts = nil)
|
31
42
|
builder = Searches.for(self).new(self, opts || {})
|
32
43
|
builder.build(params || {})
|
@@ -67,15 +78,17 @@ module MetaSearch
|
|
67
78
|
# like <tt>:user_id_equals</tt>, nor will an Article.search accept the parameter
|
68
79
|
# <tt>:comments_user_id_equals</tt>.
|
69
80
|
def attr_unsearchable(*args)
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
81
|
+
if table_exists?
|
82
|
+
opts = args.extract_options!
|
83
|
+
args.flatten.each do |attr|
|
84
|
+
attr = attr.to_s
|
85
|
+
raise(ArgumentError, "No persisted attribute (column) named #{attr} in #{self}") unless self.columns_hash.has_key?(attr)
|
86
|
+
self._metasearch_exclude_attributes = self._metasearch_exclude_attributes.merge(
|
87
|
+
attr => {
|
88
|
+
:if => opts[:if]
|
89
|
+
}
|
90
|
+
)
|
91
|
+
end
|
79
92
|
end
|
80
93
|
end
|
81
94
|
|
@@ -83,15 +96,17 @@ module MetaSearch
|
|
83
96
|
# <tt>attr_searchable</tt> and <tt>attr_unsearchable</tt> are present, the latter
|
84
97
|
# is ignored.
|
85
98
|
def attr_searchable(*args)
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
99
|
+
if table_exists?
|
100
|
+
opts = args.extract_options!
|
101
|
+
args.flatten.each do |attr|
|
102
|
+
attr = attr.to_s
|
103
|
+
raise(ArgumentError, "No persisted attribute (column) named #{attr} in #{self}") unless self.columns_hash.has_key?(attr)
|
104
|
+
self._metasearch_include_attributes = self._metasearch_include_attributes.merge(
|
105
|
+
attr => {
|
106
|
+
:if => opts[:if]
|
107
|
+
}
|
108
|
+
)
|
109
|
+
end
|
95
110
|
end
|
96
111
|
end
|
97
112
|
|
data/lib/meta_search.rb
CHANGED
@@ -26,8 +26,8 @@ module MetaSearch
|
|
26
26
|
['not_in', 'ni', 'not_in', {:types => ALL_TYPES, :predicate => :not_in}],
|
27
27
|
['is_true', {:types => BOOLEANS, :skip_compounds => true}],
|
28
28
|
['is_false', {:types => BOOLEANS, :skip_compounds => true, :formatter => Proc.new {|param| !param}}],
|
29
|
-
['is_present', {:types => (
|
30
|
-
['is_blank', {:types => (
|
29
|
+
['is_present', {:types => (ALL_TYPES - BOOLEANS), :predicate => :not_eq_all, :skip_compounds => true, :cast => :boolean, :formatter => Proc.new {|param| [nil, '']}}],
|
30
|
+
['is_blank', {:types => (ALL_TYPES - BOOLEANS), :predicate => :eq_any, :skip_compounds => true, :cast => :boolean, :formatter => Proc.new {|param| [nil, '']}}],
|
31
31
|
['is_null', {:types => ALL_TYPES, :skip_compounds => true, :cast => :boolean, :formatter => Proc.new {|param| nil}}],
|
32
32
|
['is_not_null', {:types => ALL_TYPES, :predicate => :not_eq, :skip_compounds => true, :cast => :boolean, :formatter => Proc.new {|param| nil}}]
|
33
33
|
]
|
@@ -36,7 +36,7 @@ module MetaSearch
|
|
36
36
|
# Query construction
|
37
37
|
:joins, :includes, :select, :order, :where, :having, :group,
|
38
38
|
# Results, debug, array methods
|
39
|
-
:to_a, :all, :length, :size, :to_sql, :debug_sql, :paginate,
|
39
|
+
:to_a, :all, :length, :size, :to_sql, :debug_sql, :paginate, :page,
|
40
40
|
:find_each, :first, :last, :each, :arel, :in_groups_of, :group_by,
|
41
41
|
# Calculations
|
42
42
|
:count, :average, :minimum, :maximum, :sum
|
data/meta_search.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{meta_search}
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Ernie Miller"]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-03-14}
|
13
13
|
s.description = %q{
|
14
14
|
Allows simple search forms to be created against an AR3 model
|
15
15
|
and its associations, has useful view helpers for sort links
|
@@ -71,7 +71,7 @@ you're feeling especially appreciative. It'd help me justify this
|
|
71
71
|
|
72
72
|
}
|
73
73
|
s.require_paths = ["lib"]
|
74
|
-
s.rubygems_version = %q{1.3
|
74
|
+
s.rubygems_version = %q{1.5.3}
|
75
75
|
s.summary = %q{Object-based searching (and more) for simply creating search forms.}
|
76
76
|
s.test_files = [
|
77
77
|
"test/fixtures/company.rb",
|
@@ -86,7 +86,6 @@ you're feeling especially appreciative. It'd help me justify this
|
|
86
86
|
]
|
87
87
|
|
88
88
|
if s.respond_to? :specification_version then
|
89
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
90
89
|
s.specification_version = 3
|
91
90
|
|
92
91
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
metadata
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: meta_search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 1
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
version: 1.0.1
|
4
|
+
prerelease:
|
5
|
+
version: 1.0.2
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
8
|
- Ernie Miller
|
@@ -14,7 +10,7 @@ autorequire:
|
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
12
|
|
17
|
-
date: 2011-
|
13
|
+
date: 2011-03-14 00:00:00 -04:00
|
18
14
|
default_executable:
|
19
15
|
dependencies:
|
20
16
|
- !ruby/object:Gem::Dependency
|
@@ -25,8 +21,6 @@ dependencies:
|
|
25
21
|
requirements:
|
26
22
|
- - ">="
|
27
23
|
- !ruby/object:Gem::Version
|
28
|
-
segments:
|
29
|
-
- 0
|
30
24
|
version: "0"
|
31
25
|
type: :development
|
32
26
|
version_requirements: *id001
|
@@ -38,10 +32,6 @@ dependencies:
|
|
38
32
|
requirements:
|
39
33
|
- - ~>
|
40
34
|
- !ruby/object:Gem::Version
|
41
|
-
segments:
|
42
|
-
- 3
|
43
|
-
- 0
|
44
|
-
- 2
|
45
35
|
version: 3.0.2
|
46
36
|
type: :runtime
|
47
37
|
version_requirements: *id002
|
@@ -53,10 +43,6 @@ dependencies:
|
|
53
43
|
requirements:
|
54
44
|
- - ~>
|
55
45
|
- !ruby/object:Gem::Version
|
56
|
-
segments:
|
57
|
-
- 3
|
58
|
-
- 0
|
59
|
-
- 2
|
60
46
|
version: 3.0.2
|
61
47
|
type: :runtime
|
62
48
|
version_requirements: *id003
|
@@ -68,10 +54,6 @@ dependencies:
|
|
68
54
|
requirements:
|
69
55
|
- - ~>
|
70
56
|
- !ruby/object:Gem::Version
|
71
|
-
segments:
|
72
|
-
- 3
|
73
|
-
- 0
|
74
|
-
- 2
|
75
57
|
version: 3.0.2
|
76
58
|
type: :runtime
|
77
59
|
version_requirements: *id004
|
@@ -83,10 +65,6 @@ dependencies:
|
|
83
65
|
requirements:
|
84
66
|
- - ~>
|
85
67
|
- !ruby/object:Gem::Version
|
86
|
-
segments:
|
87
|
-
- 2
|
88
|
-
- 0
|
89
|
-
- 2
|
90
68
|
version: 2.0.2
|
91
69
|
type: :runtime
|
92
70
|
version_requirements: *id005
|
@@ -158,21 +136,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
158
136
|
requirements:
|
159
137
|
- - ">="
|
160
138
|
- !ruby/object:Gem::Version
|
161
|
-
segments:
|
162
|
-
- 0
|
163
139
|
version: "0"
|
164
140
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
165
141
|
none: false
|
166
142
|
requirements:
|
167
143
|
- - ">="
|
168
144
|
- !ruby/object:Gem::Version
|
169
|
-
segments:
|
170
|
-
- 0
|
171
145
|
version: "0"
|
172
146
|
requirements: []
|
173
147
|
|
174
148
|
rubyforge_project:
|
175
|
-
rubygems_version: 1.3
|
149
|
+
rubygems_version: 1.5.3
|
176
150
|
signing_key:
|
177
151
|
specification_version: 3
|
178
152
|
summary: Object-based searching (and more) for simply creating search forms.
|