meta_search 1.1.0 → 1.1.1

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.
@@ -4,7 +4,7 @@ MetaSearch is extensible searching for your form_for enjoyment. It “wraps” o
4
4
 
5
5
  == NOTE
6
6
 
7
- The successor to MetaSearch is {Ransack}[http://github.com/ernie/ransack]). It's got features
7
+ The successor to MetaSearch is {Ransack}[http://github.com/ernie/ransack]. It's got features
8
8
  that MetaSearch doesn't, along with some API changes. I haven't had the time to dedicate to
9
9
  making it bulletproof yet, so I'm releasing a 1.1.x branch of MetaSearch to help with migrations
10
10
  to Rails 3.1.
data/Rakefile CHANGED
@@ -17,6 +17,7 @@ begin
17
17
  gem.add_development_dependency "shoulda"
18
18
  gem.add_dependency "activerecord", "~> 3.1.0"
19
19
  gem.add_dependency "activesupport", "~> 3.1.0"
20
+ gem.add_dependency "polyamorous", "~> 0.5.0"
20
21
  gem.add_dependency "actionpack", "~> 3.1.0"
21
22
  gem.post_install_message = <<END
22
23
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0
1
+ 1.1.1
@@ -47,13 +47,11 @@ require 'active_record'
47
47
  require 'active_support'
48
48
  require 'action_view'
49
49
  require 'action_controller'
50
- require 'meta_search/join_dependency'
51
50
  require 'meta_search/searches/active_record'
52
51
  require 'meta_search/helpers'
53
52
 
54
53
  I18n.load_path += Dir[File.join(File.dirname(__FILE__), 'meta_search', 'locale', '*.yml')]
55
54
 
56
- ActiveRecord::Associations::JoinDependency.send(:include, MetaSearch::JoinDependency)
57
55
  ActiveRecord::Base.send(:include, MetaSearch::Searches::ActiveRecord)
58
56
  ActionView::Helpers::FormBuilder.send(:include, MetaSearch::Helpers::FormBuilder)
59
57
  ActionController::Base.helper(MetaSearch::Helpers::UrlHelper)
@@ -1,3 +1,4 @@
1
+ require 'polyamorous'
1
2
  require 'meta_search/model_compatibility'
2
3
  require 'meta_search/exceptions'
3
4
  require 'meta_search/where'
@@ -254,7 +255,7 @@ module MetaSearch
254
255
  (!klass || assoc.reflection.klass == klass)
255
256
  end
256
257
  unless found_association
257
- @join_dependency.send(:build_polymorphic, name.to_sym, parent, @join_type, klass)
258
+ @join_dependency.send(:build, Polyamorous::Join.new(name, @join_type, klass), parent)
258
259
  found_association = @join_dependency.join_associations.last
259
260
  # Leverage the stashed association functionality in AR
260
261
  @relation = @relation.joins(found_association)
@@ -4,18 +4,14 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{meta_search}
8
- s.version = "1.1.0"
7
+ s.name = "meta_search"
8
+ s.version = "1.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = [%q{Ernie Miller}]
12
- s.date = %q{2011-08-31}
13
- s.description = %q{
14
- Allows simple search forms to be created against an AR3 model
15
- and its associations, has useful view helpers for sort links
16
- and multiparameter fields as well.
17
- }
18
- s.email = %q{ernie@metautonomo.us}
11
+ s.authors = ["Ernie Miller"]
12
+ s.date = "2011-09-03"
13
+ s.description = "\n Allows simple search forms to be created against an AR3 model\n and its associations, has useful view helpers for sort links\n and multiparameter fields as well.\n "
14
+ s.email = "ernie@metautonomo.us"
19
15
  s.extra_rdoc_files = [
20
16
  "LICENSE",
21
17
  "README.rdoc"
@@ -35,7 +31,6 @@ Gem::Specification.new do |s|
35
31
  "lib/meta_search/helpers/form_builder.rb",
36
32
  "lib/meta_search/helpers/form_helper.rb",
37
33
  "lib/meta_search/helpers/url_helper.rb",
38
- "lib/meta_search/join_dependency.rb",
39
34
  "lib/meta_search/locale/en.yml",
40
35
  "lib/meta_search/method.rb",
41
36
  "lib/meta_search/model_compatibility.rb",
@@ -61,18 +56,11 @@ Gem::Specification.new do |s|
61
56
  "test/test_search.rb",
62
57
  "test/test_view_helpers.rb"
63
58
  ]
64
- s.homepage = %q{http://metautonomo.us/projects/metasearch/}
65
- s.post_install_message = %q{
66
- *** Thanks for installing MetaSearch! ***
67
- Be sure to check out http://metautonomo.us/projects/metasearch/ for a
68
- walkthrough of MetaSearch's features, and click the donate button if
69
- you're feeling especially appreciative. It'd help me justify this
70
- "open source" stuff to my lovely wife. :)
71
-
72
- }
73
- s.require_paths = [%q{lib}]
74
- s.rubygems_version = %q{1.8.6}
75
- s.summary = %q{Object-based searching (and more) for simply creating search forms.}
59
+ s.homepage = "http://metautonomo.us/projects/metasearch/"
60
+ s.post_install_message = "\n*** Thanks for installing MetaSearch! ***\nBe sure to check out http://metautonomo.us/projects/metasearch/ for a\nwalkthrough of MetaSearch's features, and click the donate button if\nyou're feeling especially appreciative. It'd help me justify this\n\"open source\" stuff to my lovely wife. :)\n\n"
61
+ s.require_paths = ["lib"]
62
+ s.rubygems_version = "1.8.10"
63
+ s.summary = "Object-based searching (and more) for simply creating search forms."
76
64
 
77
65
  if s.respond_to? :specification_version then
78
66
  s.specification_version = 3
@@ -81,17 +69,20 @@ you're feeling especially appreciative. It'd help me justify this
81
69
  s.add_development_dependency(%q<shoulda>, [">= 0"])
82
70
  s.add_runtime_dependency(%q<activerecord>, ["~> 3.1.0"])
83
71
  s.add_runtime_dependency(%q<activesupport>, ["~> 3.1.0"])
72
+ s.add_runtime_dependency(%q<polyamorous>, ["~> 0.5.0"])
84
73
  s.add_runtime_dependency(%q<actionpack>, ["~> 3.1.0"])
85
74
  else
86
75
  s.add_dependency(%q<shoulda>, [">= 0"])
87
76
  s.add_dependency(%q<activerecord>, ["~> 3.1.0"])
88
77
  s.add_dependency(%q<activesupport>, ["~> 3.1.0"])
78
+ s.add_dependency(%q<polyamorous>, ["~> 0.5.0"])
89
79
  s.add_dependency(%q<actionpack>, ["~> 3.1.0"])
90
80
  end
91
81
  else
92
82
  s.add_dependency(%q<shoulda>, [">= 0"])
93
83
  s.add_dependency(%q<activerecord>, ["~> 3.1.0"])
94
84
  s.add_dependency(%q<activesupport>, ["~> 3.1.0"])
85
+ s.add_dependency(%q<polyamorous>, ["~> 0.5.0"])
95
86
  s.add_dependency(%q<actionpack>, ["~> 3.1.0"])
96
87
  end
97
88
  end
@@ -91,7 +91,7 @@ class TestSearch < Test::Unit::TestCase
91
91
 
92
92
  context "with outer join specified" do
93
93
  setup do
94
- @s = Developer.search({:name_equals=>"Forgetful Notetaker"}, :join_type=>:outer)
94
+ @s = Developer.search({:name_equals => "Forgetful Notetaker"}, :join_type => :outer)
95
95
  end
96
96
 
97
97
  should "find a null entry when searching notes" do
@@ -105,7 +105,7 @@ class TestSearch < Test::Unit::TestCase
105
105
 
106
106
  context "with inner join specified" do
107
107
  setup do
108
- @s = Developer.search({:name_equals=>"Forgetful Notetaker"}, :join_type=>:inner)
108
+ @s = Developer.search({:name_equals=>"Forgetful Notetaker"}, :join_type => :inner)
109
109
  end
110
110
 
111
111
  should "find no null entry when searching notes" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meta_search
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-08-31 00:00:00.000000000Z
12
+ date: 2011-09-03 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: shoulda
16
- requirement: &70351581512540 !ruby/object:Gem::Requirement
16
+ requirement: &70309382367880 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70351581512540
24
+ version_requirements: *70309382367880
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: activerecord
27
- requirement: &70351581512040 !ruby/object:Gem::Requirement
27
+ requirement: &70309382364060 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 3.1.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70351581512040
35
+ version_requirements: *70309382364060
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: activesupport
38
- requirement: &70351581511400 !ruby/object:Gem::Requirement
38
+ requirement: &70309382359180 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,21 @@ dependencies:
43
43
  version: 3.1.0
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70351581511400
46
+ version_requirements: *70309382359180
47
+ - !ruby/object:Gem::Dependency
48
+ name: polyamorous
49
+ requirement: &70309382354200 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 0.5.0
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: *70309382354200
47
58
  - !ruby/object:Gem::Dependency
48
59
  name: actionpack
49
- requirement: &70351581510860 !ruby/object:Gem::Requirement
60
+ requirement: &70309382347400 !ruby/object:Gem::Requirement
50
61
  none: false
51
62
  requirements:
52
63
  - - ~>
@@ -54,7 +65,7 @@ dependencies:
54
65
  version: 3.1.0
55
66
  type: :runtime
56
67
  prerelease: false
57
- version_requirements: *70351581510860
68
+ version_requirements: *70309382347400
58
69
  description: ! "\n Allows simple search forms to be created against an AR3 model\n
59
70
  \ and its associations, has useful view helpers for sort links\n and multiparameter
60
71
  fields as well.\n "
@@ -79,7 +90,6 @@ files:
79
90
  - lib/meta_search/helpers/form_builder.rb
80
91
  - lib/meta_search/helpers/form_helper.rb
81
92
  - lib/meta_search/helpers/url_helper.rb
82
- - lib/meta_search/join_dependency.rb
83
93
  - lib/meta_search/locale/en.yml
84
94
  - lib/meta_search/method.rb
85
95
  - lib/meta_search/model_compatibility.rb
@@ -137,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
147
  version: '0'
138
148
  requirements: []
139
149
  rubyforge_project:
140
- rubygems_version: 1.8.6
150
+ rubygems_version: 1.8.10
141
151
  signing_key:
142
152
  specification_version: 3
143
153
  summary: Object-based searching (and more) for simply creating search forms.
@@ -1,94 +0,0 @@
1
- module MetaSearch
2
-
3
- module JoinDependency
4
-
5
- class JoinAssociation < ::ActiveRecord::Associations::JoinDependency::JoinAssociation
6
-
7
- def initialize(reflection, join_dependency, parent = nil, polymorphic_class = nil)
8
- if polymorphic_class && ::ActiveRecord::Base > polymorphic_class
9
- swapping_reflection_klass(reflection, polymorphic_class) do |reflection|
10
- super(reflection, join_dependency, parent)
11
- end
12
- else
13
- super(reflection, join_dependency, parent)
14
- end
15
- end
16
-
17
- def swapping_reflection_klass(reflection, klass)
18
- reflection = reflection.clone
19
- original_polymorphic = reflection.options.delete(:polymorphic)
20
- reflection.instance_variable_set(:@klass, klass)
21
- yield reflection
22
- ensure
23
- reflection.options[:polymorphic] = original_polymorphic
24
- end
25
-
26
- def ==(other)
27
- super && active_record == other.active_record
28
- end
29
-
30
- def build_constraint(reflection, table, key, foreign_table, foreign_key)
31
- if reflection.options[:polymorphic]
32
- super.and(
33
- foreign_table[reflection.foreign_type].eq(reflection.klass.name)
34
- )
35
- else
36
- super
37
- end
38
- end
39
-
40
- end
41
-
42
- # Yes, I'm using alias_method_chain here. No, I don't feel too
43
- # bad about it. JoinDependency, or, to call it by its full proper
44
- # name, ::ActiveRecord::Associations::JoinDependency, is one of the
45
- # most "for internal use only" chunks of ActiveRecord.
46
- def self.included(base)
47
- base.class_eval do
48
- alias_method_chain :graft, :meta_search
49
- end
50
- end
51
-
52
- def graft_with_meta_search(*associations)
53
- associations.each do |association|
54
- join_associations.detect {|a| association == a} ||
55
- build_polymorphic(association.reflection.name, association.find_parent_in(self) || join_base, association.join_type, association.reflection.klass)
56
- end
57
- self
58
- end
59
-
60
- # Should only be called by MetaSearch, and only with a single association name
61
- def build_polymorphic(association, parent = nil, join_type = Arel::OuterJoin, klass = nil)
62
- parent ||= join_parts.last
63
- reflection = parent.reflections[association] or
64
- raise ::ActiveRecord::ConfigurationError, "Association named '#{ association }' was not found; perhaps you misspelled it?"
65
- unless join_association = find_join_association_respecting_polymorphism(reflection, parent, klass)
66
- @reflections << reflection
67
- join_association = build_join_association_respecting_polymorphism(reflection, parent, klass)
68
- join_association.join_type = join_type
69
- @join_parts << join_association
70
- cache_joined_association(join_association)
71
- end
72
-
73
- join_association
74
- end
75
-
76
- def find_join_association_respecting_polymorphism(reflection, parent, klass)
77
- if association = find_join_association(reflection, parent)
78
- unless reflection.options[:polymorphic]
79
- association
80
- else
81
- association if association.active_record == klass
82
- end
83
- end
84
- end
85
-
86
- def build_join_association_respecting_polymorphism(reflection, parent, klass = nil)
87
- if reflection.options[:polymorphic] && klass
88
- JoinAssociation.new(reflection, self, parent, klass)
89
- else
90
- JoinAssociation.new(reflection, self, parent)
91
- end
92
- end
93
- end
94
- end