From 93133c91033565bef4115db2dc758e8795bf98a7 Mon Sep 17 00:00:00 2001 From: Rick Bradley Date: Fri, 23 Jul 2010 19:27:59 -0500 Subject: [PATCH] removing old validation_reflection plugin --- .../plugins/validation_reflection/CHANGELOG | 40 ----- vendor/plugins/validation_reflection/LICENSE | 20 --- vendor/plugins/validation_reflection/README | 64 -------- vendor/plugins/validation_reflection/Rakefile | 42 ----- .../plugins/validation_reflection/VERSION.yml | 4 - .../plugins/validation_reflection/about.yml | 7 - .../lib/validation_reflection.rb | 148 ------------------ .../validation_reflection/rails/init.rb | 2 - .../validation_reflection/test/test_helper.rb | 19 --- .../test/validation_reflection_test.rb | 123 --------------- .../validation_reflection.gemspec | 52 ------ 11 files changed, 521 deletions(-) delete mode 100644 vendor/plugins/validation_reflection/CHANGELOG delete mode 100644 vendor/plugins/validation_reflection/LICENSE delete mode 100644 vendor/plugins/validation_reflection/README delete mode 100644 vendor/plugins/validation_reflection/Rakefile delete mode 100644 vendor/plugins/validation_reflection/VERSION.yml delete mode 100644 vendor/plugins/validation_reflection/about.yml delete mode 100644 vendor/plugins/validation_reflection/lib/validation_reflection.rb delete mode 100644 vendor/plugins/validation_reflection/rails/init.rb delete mode 100644 vendor/plugins/validation_reflection/test/test_helper.rb delete mode 100644 vendor/plugins/validation_reflection/test/validation_reflection_test.rb delete mode 100644 vendor/plugins/validation_reflection/validation_reflection.gemspec diff --git a/vendor/plugins/validation_reflection/CHANGELOG b/vendor/plugins/validation_reflection/CHANGELOG deleted file mode 100644 index 815ba40..0000000 --- a/vendor/plugins/validation_reflection/CHANGELOG +++ /dev/null @@ -1,40 +0,0 @@ -== 0.3.5, 2009-10-09 -* version bump - -== 0.3.4, 2009-10-09 -* Enhancements from Jonas Grimfelt - ** Don't include instead of explicit namespaces to make the code much DRY:er and readable - ** Avoid mutable strings - ** Be clear about the namespaces for external classes (to avoid Ruby 1.9.x issues) - ** Fixing gem loading issues on Ruby 1.9.x - ** Removed the freezing of validations - -== 0.3.3, 2009-09-12 -* version bump - -== 0.3.2, 2009-09-12 -* gemified by Christopher Redinger - -== 0.3.1, 2008-01-03 -* require 'ostruct'; thanks to Georg Friedrich. - -== 0.3, 2008-01-01 -* Added configurability in config/plugins/validation_reflection.rb - -== 0.2.1, 2006-12-28 -* Moved lib files into subfolder boiler_plate. - -== 0.2, 2006-08-06 -? - -= Deprecation Notice - -Version 0.1 had supplied three methods - - - validates_presence_of_mandatory_content_columns - - validates_lengths_of_string_attributes - - validates_all_associated - -These have been removed. Please use the Enforce Schema Rules plugin instead - - http://enforce-schema-rules.googlecode.com/svn/trunk/enforce_schema_rules/ diff --git a/vendor/plugins/validation_reflection/LICENSE b/vendor/plugins/validation_reflection/LICENSE deleted file mode 100644 index 1887bf5..0000000 --- a/vendor/plugins/validation_reflection/LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2006 Michael Schuerig - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/plugins/validation_reflection/README b/vendor/plugins/validation_reflection/README deleted file mode 100644 index bd968b7..0000000 --- a/vendor/plugins/validation_reflection/README +++ /dev/null @@ -1,64 +0,0 @@ -Validation Reflection -===================== - -Version 0.3.1, 2008-01-03 - -This plugin adds reflective access to validations - - - ModelClass.reflect_on_all_validations - - ModelClass.reflect_on_validations_for(:property) - -Both of these methods return arrays containing instances of -ActiveRecord::Reflection::MacroReflection. For example - - class Person < ActiveRecord::Base - validates_presence_of :name - validates_numericality_of :size, :only_integer => true - end - - refl = Person.reflect_on_validations_for(:name) - refl[0].macro - # => :validates_presence_of - - refl = Person.reflect_on_validations_for(:size) - refl[0].macro - # => :validates_numericality_of - refl[0].options - # => { :only_integer => true } - - -== Customization - -Usually, all the standard Rails validations are reflected. -You can change this -- add or remove validations -- in an -application-specific configuration file, - - config/plugins/validation_reflection.rb - -In that file change config.reflected_validations to suit your -needs. Say, you have a custom validation for email addresses, -validates_as_email, then you could add it like this - - config.reflected_validations << :validates_as_email - -If validates_as_email is implemented in terms of other validation -methods, these validations are added to the reflection metadata, -too. As that may not be what you want, you can disable reflection -for these subordinate validations - - config.reflected_validations << { - :method => :validates_as_email, - :ignore_subvalidations => true - } - -You have to make sure that all reflected validations are defined -before this plugin is loaded. To this end, you may have to -explicitly set the load order of plugins somewhere in the environment -configuration using - - config.plugins = [...] - - - - -Copyright (c) 2006-2008, Michael Schuerig, michael@schuerig.de diff --git a/vendor/plugins/validation_reflection/Rakefile b/vendor/plugins/validation_reflection/Rakefile deleted file mode 100644 index a081902..0000000 --- a/vendor/plugins/validation_reflection/Rakefile +++ /dev/null @@ -1,42 +0,0 @@ -# encoding: utf-8 -require 'rake' -require 'rake/testtask' -require 'rake/rdoctask' - -desc 'Default: run unit tests.' -task :default => :test - -desc 'Test the validation_reflection plugin.' -Rake::TestTask.new(:test) do |t| - t.libs << 'lib' - t.pattern = 'test/**/*_test.rb' - t.verbose = true -end - -desc 'Generate documentation for the validation_reflection plugin.' -Rake::RDocTask.new(:rdoc) do |rdoc| - rdoc.rdoc_dir = 'rdoc' - rdoc.title = 'ValidationReflection' - rdoc.options << '--line-numbers' << '--inline-source' - rdoc.rdoc_files.include('README') - rdoc.rdoc_files.include('lib/**/*.rb') -end - -begin - begin - require 'jeweler' - rescue LoadError - gem 'technicalpickles-jeweler', '>= 1.0.0' - require 'jeweler' - end - Jeweler::Tasks.new do |gemspec| - gemspec.name = "validation_reflection" - gemspec.summary = "Adds reflective access to validations" - gemspec.description = "Adds reflective access to validations" - gemspec.email = "redinger@gmail.com" - gemspec.homepage = "http://github.com/redinger/validation_reflection" - gemspec.authors = ["Christopher Redinger"] - end -rescue LoadError - puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com" -end \ No newline at end of file diff --git a/vendor/plugins/validation_reflection/VERSION.yml b/vendor/plugins/validation_reflection/VERSION.yml deleted file mode 100644 index 302d7a1..0000000 --- a/vendor/plugins/validation_reflection/VERSION.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -:major: 0 -:minor: 3 -:patch: 5 diff --git a/vendor/plugins/validation_reflection/about.yml b/vendor/plugins/validation_reflection/about.yml deleted file mode 100644 index f78ac6f..0000000 --- a/vendor/plugins/validation_reflection/about.yml +++ /dev/null @@ -1,7 +0,0 @@ -author: Michael Schuerig -summary: Reflection on validations -homepage: http://rubyforge.org/projects/valirefl/validation_reflection/trunk -plugin: validation_reflection -license: MIT -version: 0.3.1 -rails_version: >= 1.1.6 diff --git a/vendor/plugins/validation_reflection/lib/validation_reflection.rb b/vendor/plugins/validation_reflection/lib/validation_reflection.rb deleted file mode 100644 index 066b399..0000000 --- a/vendor/plugins/validation_reflection/lib/validation_reflection.rb +++ /dev/null @@ -1,148 +0,0 @@ -# encoding: utf-8 -#-- -# Copyright (c) 2006-2008, Michael Schuerig, michael@schuerig.de -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -#++ -require 'active_record/reflection' -require 'ostruct' - -# Based on code by Sebastian Kanthak -# See http://dev.rubyonrails.org/ticket/861 -# -module ActiveRecordExtensions # :nodoc: - module ValidationReflection # :nodoc: - - extend self - - # Look for config/initalizer here in: - CONFIG_PATH = ::Dir.glob((::File.join(RAILS_ROOT, 'config', '**', 'validation_reflection.rb').to_s rescue '')).first || '' - CORE_VALIDATONS = [ - :validates_acceptance_of, - :validates_associated, - :validates_confirmation_of, - :validates_exclusion_of, - :validates_format_of, - :validates_inclusion_of, - :validates_length_of, - :validates_numericality_of, - :validates_presence_of, - :validates_uniqueness_of, - ].freeze - - @@reflected_validations = CORE_VALIDATONS.dup - @@in_ignored_subvalidation = false - - mattr_accessor :reflected_validations, - :in_ignored_subvalidation - - def included(base) # :nodoc: - return if base.kind_of?(::ActiveRecordExtensions::ValidationReflection::ClassMethods) - base.extend(ClassMethods) - end - - # Load config/initializer on load, where ValidationReflection defaults - # (such as which validations to reflect upon) cane be overridden/extended. - # - def load_config - if ::File.file?(CONFIG_PATH) - config = ::OpenStruct.new - config.reflected_validations = @@reflected_validations - silence_warnings do - eval(::IO.read(CONFIG_PATH), binding, CONFIG_PATH) - end - end - end - - # Iterate through all validations and store/cache the info - # for later easy access. - # - def install(base) - @@reflected_validations.each do |validation_type| - next if base.respond_to?(:"#{validation_type}_with_reflection") - ignore_subvalidations = false - - if validation_type.kind_of?(::Hash) - ignore_subvalidations = validation_type[:ignore_subvalidations] - validation_type = validation_type[:method] - end - - base.class_eval %{ - class << self - def #{validation_type}_with_reflection(*attr_names) - ignoring_subvalidations(#{ignore_subvalidations}) do - #{validation_type}_without_reflection(*attr_names) - remember_validation_metadata(:#{validation_type}, *attr_names) - end - end - alias_method_chain :#{validation_type}, :reflection - end - }, __FILE__, __LINE__ - end - end - alias :reload :install - - module ClassMethods - - include ::ActiveRecordExtensions::ValidationReflection - - # Returns an array of MacroReflection objects for all validations in the class - def reflect_on_all_validations - self.read_inheritable_attribute(:validations) || [] - end - - # Returns an array of MacroReflection objects for all validations defined for the field +attr_name+. - def reflect_on_validations_for(attr_name) - self.reflect_on_all_validations.select do |reflection| - reflection.name == attr_name.to_sym - end - end - - private - - # Store validation info for easy and fast access. - # - def remember_validation_metadata(validation_type, *attr_names) - configuration = attr_names.last.is_a?(::Hash) ? attr_names.pop : {} - attr_names.each do |attr_name| - self.write_inheritable_array :validations, - [::ActiveRecord::Reflection::MacroReflection.new(validation_type, attr_name.to_sym, configuration, self)] - end - end - - def ignoring_subvalidations(ignore) - save_ignore = self.in_ignored_subvalidation - unless self.in_ignored_subvalidation - self.in_ignored_subvalidation = ignore - yield - end - ensure - self.in_ignored_subvalidation = save_ignore - end - - end - end -end - -ActiveRecord::Base.class_eval do - include ::ActiveRecordExtensions::ValidationReflection - ::ActiveRecordExtensions::ValidationReflection.load_config - ::ActiveRecordExtensions::ValidationReflection.install(self) -end diff --git a/vendor/plugins/validation_reflection/rails/init.rb b/vendor/plugins/validation_reflection/rails/init.rb deleted file mode 100644 index f70e1c5..0000000 --- a/vendor/plugins/validation_reflection/rails/init.rb +++ /dev/null @@ -1,2 +0,0 @@ -# encoding: utf-8 -require 'validation_reflection' \ No newline at end of file diff --git a/vendor/plugins/validation_reflection/test/test_helper.rb b/vendor/plugins/validation_reflection/test/test_helper.rb deleted file mode 100644 index cea9016..0000000 --- a/vendor/plugins/validation_reflection/test/test_helper.rb +++ /dev/null @@ -1,19 +0,0 @@ -# encoding: utf-8 -ENV['RAILS_ENV'] = 'test' -RAILS_ROOT = File.join(File.dirname(__FILE__)) - -require 'rubygems' - -begin - require 'active_record' -rescue LoadError - gem 'activerecord', '>= 1.2.3' - require 'active_record' -end - -begin - require 'test/unit' -rescue LoadError - gem 'test-unit', '>= 1.2.3' - require 'test/unit' -end \ No newline at end of file diff --git a/vendor/plugins/validation_reflection/test/validation_reflection_test.rb b/vendor/plugins/validation_reflection/test/validation_reflection_test.rb deleted file mode 100644 index 18b346c..0000000 --- a/vendor/plugins/validation_reflection/test/validation_reflection_test.rb +++ /dev/null @@ -1,123 +0,0 @@ -# encoding: utf-8 -require File.join(File.dirname(__FILE__), 'test_helper') - -ActiveRecord::Base.class_eval do - def self.validates_something_weird(*cols) - cols.each do |col| - validates_format_of col, :with => /weird/ - end - end - def self.validates_something_selfcontained(*cols) - cols.each do |col| - validates_format_of col, :with => /blablabla/ - end - end -end - -require 'validation_reflection' - -ActiveRecord::Base.class_eval do - include ::ActiveRecordExtensions::ValidationReflection - ::ActiveRecordExtensions::ValidationReflection.reflected_validations << :validates_something_weird - ::ActiveRecordExtensions::ValidationReflection.reflected_validations << { - :method => :validates_something_selfcontained, - :ignore_subvalidations => true - } - ::ActiveRecordExtensions::ValidationReflection.install(self) -end - - -class ValidationReflectionTest < Test::Unit::TestCase - - class Dummy < ActiveRecord::Base - class << self - - def create_fake_column(name, null = true, limit = nil) - sql_type = limit ? "varchar (#{limit})" : nil - col = ActiveRecord::ConnectionAdapters::Column.new(name, nil, sql_type, null) - col - end - - def columns - [ - create_fake_column('col0'), - create_fake_column('col1'), - create_fake_column('col2', false, 100), - create_fake_column('col3'), - create_fake_column('col4'), - create_fake_column('col5'), - create_fake_column('col6'), - create_fake_column('col7') - ] - end - end - - has_one :nothing - - validates_presence_of :col1 - validates_length_of :col2, :maximum => 100 - validates_format_of :col3, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i - validates_numericality_of :col4, :only_integer => true - validates_numericality_of :col5, :less_than => 5 - validates_something_weird :col6 - validates_something_selfcontained :col7 - end - - def test_sanity - assert_equal [], Dummy.reflect_on_validations_for(:col0) - end - - def test_validates_presence_of_is_reflected - reflections = Dummy.reflect_on_validations_for(:col1) - assert reflections.all? { |r| r.name.to_s == 'col1' } - assert reflections.find { |r| r.macro == :validates_presence_of } - end - - def test_string_limit_is_reflected - reflections = Dummy.reflect_on_validations_for(:col2) - assert reflections.any? { |r| r.macro == :validates_length_of && r.options[:maximum] == 100 } - end - - def test_format_is_reflected - reflections = Dummy.reflect_on_validations_for(:col3) - assert reflections.any? { |r| r.macro == :validates_format_of && r.options[:with] == /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i } - end - - def test_numeric_integer_is_reflected - reflections = Dummy.reflect_on_validations_for(:col4) - assert reflections.any? { |r| r.macro == :validates_numericality_of && r.options[:only_integer] } - end - - def test_numeric_is_reflected - reflections = Dummy.reflect_on_validations_for(:col5) - assert reflections.any? { |r| r.macro == :validates_numericality_of } - end - - def test_validation_options_are_reflected - reflections = Dummy.reflect_on_validations_for(:col5) - refl = reflections[0] - assert_equal 5, refl.options[:less_than] - end - - def test_custom_validations_are_reflected - reflections = Dummy.reflect_on_validations_for(:col6) - assert reflections.any? { |r| r.macro == :validates_something_weird } - assert reflections.any? { |r| r.macro == :validates_format_of } - end - - def test_custom_validations_with_options_are_reflected - reflections = Dummy.reflect_on_validations_for(:col7) - assert reflections.any? { |r| r.macro == :validates_something_selfcontained } - end - - def test_subvalidations_are_reflected - reflections = Dummy.reflect_on_validations_for(:col6) - assert_equal 2, reflections.size - end - - def test_ignored_subvalidations_are_not_reflected - reflections = Dummy.reflect_on_validations_for(:col7) - assert_equal 1, reflections.size - end - -end diff --git a/vendor/plugins/validation_reflection/validation_reflection.gemspec b/vendor/plugins/validation_reflection/validation_reflection.gemspec deleted file mode 100644 index 12e78f0..0000000 --- a/vendor/plugins/validation_reflection/validation_reflection.gemspec +++ /dev/null @@ -1,52 +0,0 @@ -# Generated by jeweler -# DO NOT EDIT THIS FILE -# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec` -# -*- encoding: utf-8 -*- - -Gem::Specification.new do |s| - s.name = %q{validation_reflection} - s.version = "0.3.5" - - s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= - s.authors = ["Christopher Redinger"] - s.date = %q{2009-10-09} - s.description = %q{Adds reflective access to validations} - s.email = %q{redinger@gmail.com} - s.extra_rdoc_files = [ - "LICENSE", - "README" - ] - s.files = [ - ".gitignore", - "CHANGELOG", - "LICENSE", - "README", - "Rakefile", - "VERSION.yml", - "about.yml", - "lib/validation_reflection.rb", - "rails/init.rb", - "test/test_helper.rb", - "test/validation_reflection_test.rb", - "validation_reflection.gemspec" - ] - s.homepage = %q{http://github.com/redinger/validation_reflection} - s.rdoc_options = ["--charset=UTF-8"] - s.require_paths = ["lib"] - s.rubygems_version = %q{1.3.5} - s.summary = %q{Adds reflective access to validations} - s.test_files = [ - "test/test_helper.rb", - "test/validation_reflection_test.rb" - ] - - if s.respond_to? :specification_version then - current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION - s.specification_version = 3 - - if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then - else - end - else - end -end