get latest has_many_polymorphs from git repo.

The repo got fixes we need that are not in the gem
This commit is contained in:
Reinier Balt 2008-12-22 20:54:18 +01:00
parent 7399edc2d6
commit c0dbabf226
179 changed files with 117 additions and 396 deletions

View file

@ -1,259 +0,0 @@
--- !ruby/object:Gem::Specification
name: has_many_polymorphs
version: !ruby/object:Gem::Version
version: "2.12"
platform: ruby
authors:
- ""
autorequire:
bindir: bin
cert_chain:
- |
-----BEGIN CERTIFICATE-----
MIIDLjCCAhagAwIBAgIBADANBgkqhkiG9w0BAQUFADA9MQ0wCwYDVQQDDARldmFu
MRgwFgYKCZImiZPyLGQBGRYIY2xvdWRidXIxEjAQBgoJkiaJk/IsZAEZFgJzdDAe
Fw0wNzA5MTYxMDMzMDBaFw0wODA5MTUxMDMzMDBaMD0xDTALBgNVBAMMBGV2YW4x
GDAWBgoJkiaJk/IsZAEZFghjbG91ZGJ1cjESMBAGCgmSJomT8ixkARkWAnN0MIIB
IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5C0Io89nyApnr+PvbNFge9Vs
yRWAlGBUEMahpXp28VrrfXZT0rAW7JBo4PlCE3jl4nE4dzE6gAdItSycjTosrw7A
Ir5+xoyl4Vb35adv56TIQQXvNz+BzlqnkAY5JN0CSBRTQb6mxS3hFyD/h4qgDosj
R2RFVzHqSxCS8xq4Ny8uzOwOi+Xyu4w67fI5JvnPvMxqrlR1eaIQHmxnf76RzC46
QO5QhufjAYGGXd960XzbQsQyTDUYJzrvT7AdOfiyZzKQykKt8dEpDn+QPjFTnGnT
QmgJBX5WJN0lHF2l1sbv3gh4Kn1tZu+kTUqeXY6ShAoDTyvZRiFqQdwh8w2lTQID
AQABozkwNzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU+WqJz3xQ
XSea1hRvvHWcIMgeeC4wDQYJKoZIhvcNAQEFBQADggEBAGLZ75jfOEW8Nsl26CTt
JFrWxQTcQT/UljeefVE3xYr7lc9oQjbqO3FOyued3qW7TaNEtZfSHoYeUSMYbpw1
XAwocIPuSRFDGM4B+hgQGVDx8PMGiJKom4qLXjO40UZsR7QyN/u869Vj45LURm6h
MBcPeqCASI+WNprj9+uZa2kmHiitrFqqfMBNlm5IFbn9XeYSta9AHVvs5QQqV2m5
hIPfLqCyxsn/YgOGvo6iwyQTWyTswamaAC3HRWZxIS1sfn/Ssqa7E7oQMkv5FAXr
x5rKePfXINf8XTJczkl9OBEYdE9aNdJsJpXD0asLgGVwBICS5Bjohp6mizJcDC1+
yZ0=
-----END CERTIFICATE-----
date: 2008-01-16 00:00:00 +01:00
default_executable:
dependencies:
- !ruby/object:Gem::Dependency
name: activerecord
type: :runtime
version_requirement:
version_requirements: !ruby/object:Gem::Requirement
requirements:
- - ">="
- !ruby/object:Gem::Version
version: "0"
version:
description: An ActiveRecord plugin for self-referential and double-sided polymorphic associations.
email: ""
executables: []
extensions: []
extra_rdoc_files: []
files:
- CHANGELOG
- examples/hmph.rb
- generators/tagging/tagging_generator.rb
- generators/tagging/templates/migration.rb
- generators/tagging/templates/tag.rb
- generators/tagging/templates/tag_test.rb
- generators/tagging/templates/tagging.rb
- generators/tagging/templates/tagging_extensions.rb
- generators/tagging/templates/tagging_test.rb
- generators/tagging/templates/taggings.yml
- generators/tagging/templates/tags.yml
- init.rb
- lib/has_many_polymorphs/association.rb
- lib/has_many_polymorphs/autoload.rb
- lib/has_many_polymorphs/base.rb
- lib/has_many_polymorphs/class_methods.rb
- lib/has_many_polymorphs/configuration.rb
- lib/has_many_polymorphs/debugging_tools.rb
- lib/has_many_polymorphs/rake_task_redefine_task.rb
- lib/has_many_polymorphs/reflection.rb
- lib/has_many_polymorphs/support_methods.rb
- lib/has_many_polymorphs.rb
- LICENSE
- Manifest
- README
- test/fixtures/bow_wows.yml
- test/fixtures/cats.yml
- test/fixtures/eaters_foodstuffs.yml
- test/fixtures/fish.yml
- test/fixtures/frogs.yml
- test/fixtures/keep_your_enemies_close.yml
- test/fixtures/little_whale_pupils.yml
- test/fixtures/people.yml
- test/fixtures/petfoods.yml
- test/fixtures/whales.yml
- test/fixtures/wild_boars.yml
- test/generator/tagging_generator_test.rb
- test/integration/app/app/controllers/application.rb
- test/integration/app/app/controllers/bones_controller.rb
- test/integration/app/app/helpers/addresses_helper.rb
- test/integration/app/app/helpers/application_helper.rb
- test/integration/app/app/helpers/bones_helper.rb
- test/integration/app/app/helpers/sellers_helper.rb
- test/integration/app/app/helpers/states_helper.rb
- test/integration/app/app/helpers/users_helper.rb
- test/integration/app/app/models/bone.rb
- test/integration/app/app/models/double_sti_parent.rb
- test/integration/app/app/models/double_sti_parent_relationship.rb
- test/integration/app/app/models/organic_substance.rb
- test/integration/app/app/models/single_sti_parent.rb
- test/integration/app/app/models/single_sti_parent_relationship.rb
- test/integration/app/app/models/stick.rb
- test/integration/app/app/models/stone.rb
- test/integration/app/app/views/addresses/edit.html.erb
- test/integration/app/app/views/addresses/index.html.erb
- test/integration/app/app/views/addresses/new.html.erb
- test/integration/app/app/views/addresses/show.html.erb
- test/integration/app/app/views/bones/index.rhtml
- test/integration/app/app/views/layouts/addresses.html.erb
- test/integration/app/app/views/layouts/sellers.html.erb
- test/integration/app/app/views/layouts/states.html.erb
- test/integration/app/app/views/layouts/users.html.erb
- test/integration/app/app/views/sellers/edit.html.erb
- test/integration/app/app/views/sellers/index.html.erb
- test/integration/app/app/views/sellers/new.html.erb
- test/integration/app/app/views/sellers/show.html.erb
- test/integration/app/app/views/states/edit.html.erb
- test/integration/app/app/views/states/index.html.erb
- test/integration/app/app/views/states/new.html.erb
- test/integration/app/app/views/states/show.html.erb
- test/integration/app/app/views/users/edit.html.erb
- test/integration/app/app/views/users/index.html.erb
- test/integration/app/app/views/users/new.html.erb
- test/integration/app/app/views/users/show.html.erb
- test/integration/app/config/boot.rb
- test/integration/app/config/database.yml
- test/integration/app/config/environment.rb
- test/integration/app/config/environment.rb.canonical
- test/integration/app/config/environments/development.rb
- test/integration/app/config/environments/production.rb
- test/integration/app/config/environments/test.rb
- test/integration/app/config/locomotive.yml
- test/integration/app/config/routes.rb
- test/integration/app/config/ultrasphinx/default.base
- test/integration/app/config/ultrasphinx/development.conf.canonical
- test/integration/app/db/migrate/001_create_sticks.rb
- test/integration/app/db/migrate/002_create_stones.rb
- test/integration/app/db/migrate/003_create_organic_substances.rb
- test/integration/app/db/migrate/004_create_bones.rb
- test/integration/app/db/migrate/005_create_single_sti_parents.rb
- test/integration/app/db/migrate/006_create_double_sti_parents.rb
- test/integration/app/db/migrate/007_create_single_sti_parent_relationships.rb
- test/integration/app/db/migrate/008_create_double_sti_parent_relationships.rb
- test/integration/app/db/migrate/009_create_library_model.rb
- test/integration/app/db/schema.rb
- test/integration/app/doc/README_FOR_APP
- test/integration/app/generators/commenting_generator_test.rb
- test/integration/app/hmp_development
- test/integration/app/lib/library_model.rb
- test/integration/app/public/404.html
- test/integration/app/public/500.html
- test/integration/app/public/dispatch.cgi
- test/integration/app/public/dispatch.fcgi
- test/integration/app/public/dispatch.rb
- test/integration/app/public/favicon.ico
- test/integration/app/public/images/rails.png
- test/integration/app/public/index.html
- test/integration/app/public/javascripts/application.js
- test/integration/app/public/javascripts/controls.js
- test/integration/app/public/javascripts/dragdrop.js
- test/integration/app/public/javascripts/effects.js
- test/integration/app/public/javascripts/prototype.js
- test/integration/app/public/robots.txt
- test/integration/app/public/stylesheets/scaffold.css
- test/integration/app/Rakefile
- test/integration/app/README
- test/integration/app/script/about
- test/integration/app/script/breakpointer
- test/integration/app/script/console
- test/integration/app/script/destroy
- test/integration/app/script/generate
- test/integration/app/script/performance/benchmarker
- test/integration/app/script/performance/profiler
- test/integration/app/script/plugin
- test/integration/app/script/process/inspector
- test/integration/app/script/process/reaper
- test/integration/app/script/process/spawner
- test/integration/app/script/runner
- test/integration/app/script/server
- test/integration/app/test/fixtures/double_sti_parent_relationships.yml
- test/integration/app/test/fixtures/double_sti_parents.yml
- test/integration/app/test/fixtures/organic_substances.yml
- test/integration/app/test/fixtures/single_sti_parent_relationships.yml
- test/integration/app/test/fixtures/single_sti_parents.yml
- test/integration/app/test/fixtures/sticks.yml
- test/integration/app/test/fixtures/stones.yml
- test/integration/app/test/functional/addresses_controller_test.rb
- test/integration/app/test/functional/bones_controller_test.rb
- test/integration/app/test/functional/sellers_controller_test.rb
- test/integration/app/test/functional/states_controller_test.rb
- test/integration/app/test/functional/users_controller_test.rb
- test/integration/app/test/test_helper.rb
- test/integration/app/test/unit/bone_test.rb
- test/integration/app/test/unit/double_sti_parent_relationship_test.rb
- test/integration/app/test/unit/double_sti_parent_test.rb
- test/integration/app/test/unit/organic_substance_test.rb
- test/integration/app/test/unit/single_sti_parent_relationship_test.rb
- test/integration/app/test/unit/single_sti_parent_test.rb
- test/integration/app/test/unit/stick_test.rb
- test/integration/app/test/unit/stone_test.rb
- test/integration/server_test.rb
- test/models/aquatic/fish.rb
- test/models/aquatic/pupils_whale.rb
- test/models/aquatic/whale.rb
- test/models/beautiful_fight_relationship.rb
- test/models/canine.rb
- test/models/cat.rb
- test/models/dog.rb
- test/models/eaters_foodstuff.rb
- test/models/frog.rb
- test/models/kitten.rb
- test/models/parentship.rb
- test/models/person.rb
- test/models/petfood.rb
- test/models/tabby.rb
- test/models/wild_boar.rb
- test/modules/extension_module.rb
- test/modules/other_extension_module.rb
- test/patches/symlinked_plugins_1.2.6.diff
- test/schema.rb
- test/setup.rb
- test/test_helper.rb
- test/unit/has_many_polymorphs_test.rb
- TODO
- has_many_polymorphs.gemspec
has_rdoc: true
homepage: http://blog.evanweaver.com/files/doc/fauna/has_many_polymorphs/
post_install_message:
rdoc_options: []
require_paths:
- lib
required_ruby_version: !ruby/object:Gem::Requirement
requirements:
- - ">="
- !ruby/object:Gem::Version
version: "0"
version:
required_rubygems_version: !ruby/object:Gem::Requirement
requirements:
- - ">="
- !ruby/object:Gem::Version
version: "0"
version:
requirements: []
rubyforge_project: fauna
rubygems_version: 1.3.1
signing_key:
specification_version: 2
summary: An ActiveRecord plugin for self-referential and double-sided polymorphic associations.
test_files:
- test/generator/tagging_generator_test.rb
- test/integration/server_test.rb
- test/unit/has_many_polymorphs_test.rb

File diff suppressed because one or more lines are too long

View file

@ -1,17 +0,0 @@
=begin rdoc
Access the <tt>has_many_polymorphs_options</tt> hash in your Rails::Initializer.run#after_initialize block if you need to modify the behavior of Rails::Initializer::HasManyPolymorphsAutoload.
=end
class Rails::Configuration
def has_many_polymorphs_options
::HasManyPolymorphs.options
end
def has_many_polymorphs_options=(hash)
::HasManyPolymorphs.options = HashWithIndifferentAccess.new(hash)
end
end

View file

@ -1,44 +0,0 @@
# This file is autogenerated. Instead of editing this file, please use the
# migrations feature of ActiveRecord to incrementally modify your database, and
# then regenerate this schema definition.
ActiveRecord::Schema.define(:version => 9) do
create_table "double_sti_parent_relationships", :force => true do |t|
t.column "the_bone_type", :string, :default => "", :null => false
t.column "the_bone_id", :integer, :null => false
t.column "parent_type", :string, :default => "", :null => false
t.column "parent_id", :integer, :null => false
end
create_table "double_sti_parents", :force => true do |t|
t.column "name", :string
end
create_table "library_models", :force => true do |t|
t.column "name", :string
end
create_table "organic_substances", :force => true do |t|
t.column "type", :string
end
create_table "single_sti_parent_relationships", :force => true do |t|
t.column "the_bone_type", :string, :default => "", :null => false
t.column "the_bone_id", :integer, :null => false
t.column "single_sti_parent_id", :integer, :null => false
end
create_table "single_sti_parents", :force => true do |t|
t.column "name", :string
end
create_table "sticks", :force => true do |t|
t.column "name", :string
end
create_table "stones", :force => true do |t|
t.column "name", :string
end
end

View file

@ -1,13 +1,14 @@
Has_many_polymorphs
An ActiveRecord plugin for self-referential and double-sided polymorphic associations.
== License
Copyright 2007 Cloudburst, LLC. Licensed under the AFL 3. See the included LICENSE file.
Copyright 2006-2008 Cloudburst, LLC. Licensed under the AFL 3. See the included LICENSE file.
The public certificate for this gem is at http://rubyforge.org/frs/download.php/25331/evan_weaver-original-public_cert.pem.
The public certificate for the gem is here[http://rubyforge.org/frs/download.php/25331/evan_weaver-original-public_cert.pem].
If you use this software, please {make a donation}[http://blog.evanweaver.com/donate/], or {recommend Evan}[http://www.workingwithrails.com/person/7739-evan-weaver] at Working with Rails.
== Description
@ -35,7 +36,7 @@ The plugin also includes a generator for a tagging system, a common use case (se
== Installation
To install the Rails plugin, run:
script/plugin install svn://rubyforge.org/var/svn/fauna/has_many_polymorphs/trunk
script/plugin install git://github.com/fauna/has_many_polymorphs.git
There's also a gem version. To install it instead, run:
sudo gem install has_many_polymorphs
@ -187,7 +188,7 @@ Note that because of the way Rails reloads model classes, the plugin can sometim
== Reporting problems
* http://rubyforge.org/forum/forum.php?forum_id=16450
The support forum is here[http://rubyforge.org/forum/forum.php?forum_id=16450].
Patches and contributions are very welcome. Please note that contributors are required to assign copyright for their additions to Cloudburst, LLC.

View file

@ -0,0 +1,28 @@
require 'echoe'
Echoe.new("has_many_polymorphs") do |p|
p.project = "fauna"
p.summary = "An ActiveRecord plugin for self-referential and double-sided polymorphic associations."
p.url = "http://blog.evanweaver.com/files/doc/fauna/has_many_polymorphs/"
p.docs_host = "blog.evanweaver.com:~/www/bax/public/files/doc/"
p.dependencies = ["activerecord"]
p.rdoc_pattern = /polymorphs\/association|polymorphs\/class_methods|polymorphs\/reflection|polymorphs\/autoload|polymorphs\/configuration|README|CHANGELOG|TODO|LICENSE|templates\/migration\.rb|templates\/tag\.rb|templates\/tagging\.rb|templates\/tagging_extensions\.rb/
p.require_signed = true
p.clean_pattern += ["**/ruby_sess*", "**/generated_models/**"]
p.test_pattern = ["test/unit/*_test.rb", "test/integration/*_test.rb", "test/generator/*_test.rb"]
end
desc "Run all the tests for every database adapter"
task "test_all" do
['mysql', 'postgresql', 'sqlite3'].each do |adapter|
ENV['DB'] = adapter
ENV['PRODUCTION'] = nil
STDERR.puts "#{'='*80}\nDevelopment mode for #{adapter}\n#{'='*80}"
system("rake test:multi_rails:all")
ENV['PRODUCTION'] = '1'
STDERR.puts "#{'='*80}\nProduction mode for #{adapter}\n#{'='*80}"
system("rake test:multi_rails:all")
end
end

View file

@ -101,13 +101,14 @@ class ActiveRecord::Base #:nodoc:
end
module TaggingFinders
#
# Find all the objects tagged with the supplied list of tags
#
# Usage : Model.tagged_with("ruby")
# Model.tagged_with("hello", "world")
# Model.tagged_with("hello", "world", :limit => 10)
#
# XXX This query strategy is not performant, and needs to be rewritten as an inverted join or a series of unions
#
def tagged_with(*tag_list)
options = tag_list.last.is_a?(Hash) ? tag_list.pop : {}
tag_list = parse_tags(tag_list)
@ -119,17 +120,22 @@ class ActiveRecord::Base #:nodoc:
sql = "SELECT #{(scope && scope[:select]) || options[:select]} "
sql << "FROM #{(scope && scope[:from]) || options[:from]} "
add_joins!(sql, options, scope)
add_joins!(sql, options[:joins], scope)
sql << "WHERE #{table_name}.#{primary_key} = taggings.taggable_id "
sql << "AND taggings.taggable_type = '#{ActiveRecord::Base.send(:class_name_of_active_record_descendant, self).to_s}' "
sql << "AND taggings.tag_id = tags.id "
tag_list_condition = tag_list.map {|t| "'#{t}'"}.join(", ")
tag_list_condition = tag_list.map {|name| "'#{name}'"}.join(", ")
sql << "AND (tags.name IN (#{sanitize_sql(tag_list_condition)})) "
sql << "AND #{sanitize_sql(options[:conditions])} " if options[:conditions]
sql << "GROUP BY #{table_name}.id "
columns = column_names.map do |column|
"#{table_name}.#{column}"
end.join(", ")
sql << "GROUP BY #{columns} "
sql << "HAVING COUNT(taggings.tag_id) = #{tag_list.size}"
add_order!(sql, options[:order], scope)

View file

@ -360,10 +360,14 @@ Be aware, however, that <tt>NULL != 'Spot'</tt> returns <tt>false</tt> due to SQ
begin
table = plural._as_class.table_name
rescue NameError => e
raise PolymorphicError, "Could not find a valid class for #{plural.inspect}. If it's namespaced, be sure to specify it as :\"module/#{plural}\" instead."
raise PolymorphicError, "Could not find a valid class for #{plural.inspect} (tried #{plural.to_s._classify}). If it's namespaced, be sure to specify it as :\"module/#{plural}\" instead."
end
plural._as_class.columns.map(&:name).each_with_index do |field, f_index|
aliases["#{table}.#{field}"] = "t#{t_index}_r#{f_index}"
begin
plural._as_class.columns.map(&:name).each_with_index do |field, f_index|
aliases["#{table}.#{field}"] = "t#{t_index}_r#{f_index}"
end
rescue ActiveRecord::StatementInvalid => e
_logger_warn "Looks like your table doesn't exist for #{plural.to_s._classify}.\nError #{e}\nSkipping..."
end
end
end

View file

@ -0,0 +1,19 @@
=begin rdoc
Access the <tt>has_many_polymorphs_options</tt> hash in your Rails::Initializer.run#after_initialize block if you need to modify the behavior of Rails::Initializer::HasManyPolymorphsAutoload.
=end
module Rails #:nodoc:
class Configuration
def has_many_polymorphs_options
::HasManyPolymorphs.options
end
def has_many_polymorphs_options=(hash)
::HasManyPolymorphs.options = HashWithIndifferentAccess.new(hash)
end
end
end

View file

@ -2,18 +2,19 @@ module ActiveRecord #:nodoc:
module Reflection #:nodoc:
module ClassMethods #:nodoc:
# Update the default reflection switch so that <tt>:has_many_polymorphs</tt> types get instantiated. It's not a composed method so we have to override the whole thing.
# Update the default reflection switch so that <tt>:has_many_polymorphs</tt> types get instantiated.
# It's not a composed method so we have to override the whole thing.
def create_reflection(macro, name, options, active_record)
case macro
when :has_many, :belongs_to, :has_one, :has_and_belongs_to_many
reflection = AssociationReflection.new(macro, name, options, active_record)
klass = options[:through] ? ThroughReflection : AssociationReflection
reflection = klass.new(macro, name, options, active_record)
when :composed_of
reflection = AggregateReflection.new(macro, name, options, active_record)
# added by has_many_polymorphs #
# added by has_many_polymorphs #
when :has_many_polymorphs
reflection = PolymorphicReflection.new(macro, name, options, active_record)
# end added #
end
write_inheritable_hash :reflections, name => reflection
reflection
@ -32,7 +33,7 @@ Inherits from ActiveRecord::Reflection::AssociationReflection.
=end
class PolymorphicReflection < AssociationReflection
class PolymorphicReflection < ThroughReflection
# Stub out the validity check. Has_many_polymorphs checks validity on macro creation, not on reflection.
def check_validity!
# nothing

Some files were not shown because too many files have changed in this diff Show more