automagical_validations 0.1.0 → 0.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.
- data/.travis.yml +7 -0
- data/Gemfile +5 -5
- data/README.md +2 -2
- data/Rakefile +5 -0
- data/VERSION +1 -1
- data/automagical_validations.gemspec +63 -0
- data/lib/automagical_validations.rb +1 -0
- data/spec/automagical_validations_spec.rb +6 -0
- data/spec/spec_helper.rb +12 -5
- metadata +68 -60
    
        data/.travis.yml
    ADDED
    
    
    
        data/Gemfile
    CHANGED
    
    | @@ -3,8 +3,8 @@ source "http://rubygems.org" | |
| 3 3 | 
             
            gem "activerecord", ">= 3.0.0"
         | 
| 4 4 |  | 
| 5 5 | 
             
            group :development do
         | 
| 6 | 
            -
              gem "rspec" | 
| 7 | 
            -
              gem " | 
| 8 | 
            -
              gem " | 
| 9 | 
            -
              gem " | 
| 10 | 
            -
            end
         | 
| 6 | 
            +
              gem "rspec"
         | 
| 7 | 
            +
              gem "jeweler"
         | 
| 8 | 
            +
              gem "mysql2", :platforms => :ruby
         | 
| 9 | 
            +
              gem "activerecord-jdbcmysql-adapter", :platforms => :jruby
         | 
| 10 | 
            +
            end
         | 
    
        data/README.md
    CHANGED
    
    | @@ -1,4 +1,4 @@ | |
| 1 | 
            -
            #automagical_validations
         | 
| 1 | 
            +
            #automagical_validations [](http://travis-ci.org/tmikoss/automagical_validations)
         | 
| 2 2 |  | 
| 3 3 | 
             
            automagical_validations provides way to automatically apply validations to ActiveRecord models based on the information that can be inferred from database schema.
         | 
| 4 4 |  | 
| @@ -23,7 +23,7 @@ If a maximum length validation already exists for column (for example, `automagi | |
| 23 23 |  | 
| 24 24 | 
             
            Add the following line to your `Gemfile`
         | 
| 25 25 |  | 
| 26 | 
            -
                gem "automagical_validations"
         | 
| 26 | 
            +
                gem "automagical_validations", "~> 0.1.0"
         | 
| 27 27 |  | 
| 28 28 | 
             
            and run the `bundle install` command.
         | 
| 29 29 |  | 
    
        data/Rakefile
    CHANGED
    
    | @@ -31,4 +31,9 @@ RSpec::Core::RakeTask.new(:spec) do |spec| | |
| 31 31 | 
             
              spec.pattern = FileList['spec/**/*_spec.rb']
         | 
| 32 32 | 
             
            end
         | 
| 33 33 |  | 
| 34 | 
            +
            desc 'Create database to run tests on'
         | 
| 35 | 
            +
            task :create_database do
         | 
| 36 | 
            +
              `mysql -u root -e 'create database automagical_validations_test;'`
         | 
| 37 | 
            +
            end
         | 
| 38 | 
            +
             | 
| 34 39 | 
             
            task :default => :spec
         | 
    
        data/VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            0.1. | 
| 1 | 
            +
            0.1.1
         | 
| @@ -0,0 +1,63 @@ | |
| 1 | 
            +
            # Generated by jeweler
         | 
| 2 | 
            +
            # DO NOT EDIT THIS FILE DIRECTLY
         | 
| 3 | 
            +
            # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
         | 
| 4 | 
            +
            # -*- encoding: utf-8 -*-
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            Gem::Specification.new do |s|
         | 
| 7 | 
            +
              s.name = "automagical_validations"
         | 
| 8 | 
            +
              s.version = "0.1.1"
         | 
| 9 | 
            +
             | 
| 10 | 
            +
              s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
         | 
| 11 | 
            +
              s.authors = ["Toms Mikoss"]
         | 
| 12 | 
            +
              s.date = "2012-06-03"
         | 
| 13 | 
            +
              s.description = "ActiveRecord extension that allows to infer validation rules from database"
         | 
| 14 | 
            +
              s.email = "toms.mikoss@gmail.com"
         | 
| 15 | 
            +
              s.extra_rdoc_files = [
         | 
| 16 | 
            +
                "LICENSE.txt",
         | 
| 17 | 
            +
                "README.md"
         | 
| 18 | 
            +
              ]
         | 
| 19 | 
            +
              s.files = [
         | 
| 20 | 
            +
                ".document",
         | 
| 21 | 
            +
                ".rspec",
         | 
| 22 | 
            +
                ".travis.yml",
         | 
| 23 | 
            +
                "Gemfile",
         | 
| 24 | 
            +
                "LICENSE.txt",
         | 
| 25 | 
            +
                "README.md",
         | 
| 26 | 
            +
                "Rakefile",
         | 
| 27 | 
            +
                "VERSION",
         | 
| 28 | 
            +
                "automagical_validations.gemspec",
         | 
| 29 | 
            +
                "lib/automagical_validations.rb",
         | 
| 30 | 
            +
                "spec/automagical_validations_spec.rb",
         | 
| 31 | 
            +
                "spec/spec_helper.rb"
         | 
| 32 | 
            +
              ]
         | 
| 33 | 
            +
              s.homepage = "http://github.com/tmikoss/automagical_validations"
         | 
| 34 | 
            +
              s.licenses = ["MIT"]
         | 
| 35 | 
            +
              s.require_paths = ["lib"]
         | 
| 36 | 
            +
              s.rubygems_version = "1.8.24"
         | 
| 37 | 
            +
              s.summary = "ActiveRecord extension that allows to infer validation rules from database"
         | 
| 38 | 
            +
             | 
| 39 | 
            +
              if s.respond_to? :specification_version then
         | 
| 40 | 
            +
                s.specification_version = 3
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
         | 
| 43 | 
            +
                  s.add_runtime_dependency(%q<activerecord>, [">= 3.0.0"])
         | 
| 44 | 
            +
                  s.add_development_dependency(%q<rspec>, [">= 0"])
         | 
| 45 | 
            +
                  s.add_development_dependency(%q<jeweler>, [">= 0"])
         | 
| 46 | 
            +
                  s.add_development_dependency(%q<mysql2>, [">= 0"])
         | 
| 47 | 
            +
                  s.add_development_dependency(%q<activerecord-jdbcmysql-adapter>, [">= 0"])
         | 
| 48 | 
            +
                else
         | 
| 49 | 
            +
                  s.add_dependency(%q<activerecord>, [">= 3.0.0"])
         | 
| 50 | 
            +
                  s.add_dependency(%q<rspec>, [">= 0"])
         | 
| 51 | 
            +
                  s.add_dependency(%q<jeweler>, [">= 0"])
         | 
| 52 | 
            +
                  s.add_dependency(%q<mysql2>, [">= 0"])
         | 
| 53 | 
            +
                  s.add_dependency(%q<activerecord-jdbcmysql-adapter>, [">= 0"])
         | 
| 54 | 
            +
                end
         | 
| 55 | 
            +
              else
         | 
| 56 | 
            +
                s.add_dependency(%q<activerecord>, [">= 3.0.0"])
         | 
| 57 | 
            +
                s.add_dependency(%q<rspec>, [">= 0"])
         | 
| 58 | 
            +
                s.add_dependency(%q<jeweler>, [">= 0"])
         | 
| 59 | 
            +
                s.add_dependency(%q<mysql2>, [">= 0"])
         | 
| 60 | 
            +
                s.add_dependency(%q<activerecord-jdbcmysql-adapter>, [">= 0"])
         | 
| 61 | 
            +
              end
         | 
| 62 | 
            +
            end
         | 
| 63 | 
            +
             | 
| @@ -3,6 +3,12 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper') | |
| 3 3 | 
             
            describe "AutomagicalValidations" do
         | 
| 4 4 | 
             
              subject { Post.new }
         | 
| 5 5 |  | 
| 6 | 
            +
              context 'model without database table' do
         | 
| 7 | 
            +
                it 'should be automagically validatable' do
         | 
| 8 | 
            +
                  expect { Comment.automagically_validate(:string, :text) }.to_not raise_error
         | 
| 9 | 
            +
                end
         | 
| 10 | 
            +
              end
         | 
| 11 | 
            +
             | 
| 6 12 | 
             
              context "maximum length validator" do
         | 
| 7 13 | 
             
                context "presence of validators" do
         | 
| 8 14 | 
             
                  before(:all) do
         | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    | @@ -8,10 +8,15 @@ require 'automagical_validations' | |
| 8 8 | 
             
            # in ./support/ and its subdirectories.
         | 
| 9 9 | 
             
            Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
         | 
| 10 10 |  | 
| 11 | 
            -
             | 
| 12 | 
            -
              :adapter | 
| 13 | 
            -
              : | 
| 14 | 
            -
             | 
| 11 | 
            +
            database_properties = {
         | 
| 12 | 
            +
              :adapter  => defined?(JRUBY_VERSION) ? "jdbcmysql" : "mysql2",
         | 
| 13 | 
            +
              :host     => "localhost",
         | 
| 14 | 
            +
              :username => "root",
         | 
| 15 | 
            +
              :password => "",
         | 
| 16 | 
            +
              :database => "automagical_validations_test"
         | 
| 17 | 
            +
            }
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            ActiveRecord::Base.establish_connection database_properties
         | 
| 15 20 |  | 
| 16 21 | 
             
            class Post < ActiveRecord::Base
         | 
| 17 22 | 
             
              def self.rebuild_table
         | 
| @@ -31,4 +36,6 @@ class Post < ActiveRecord::Base | |
| 31 36 | 
             
                  memo
         | 
| 32 37 | 
             
                end
         | 
| 33 38 | 
             
              end
         | 
| 34 | 
            -
            end
         | 
| 39 | 
            +
            end
         | 
| 40 | 
            +
             | 
| 41 | 
            +
            class Comment < ActiveRecord::Base; end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,115 +1,123 @@ | |
| 1 | 
            -
            --- !ruby/object:Gem::Specification
         | 
| 1 | 
            +
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: automagical_validations
         | 
| 3 | 
            -
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.1.0
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version 
         | 
| 5 4 | 
             
              prerelease: 
         | 
| 5 | 
            +
              version: 0.1.1
         | 
| 6 6 | 
             
            platform: ruby
         | 
| 7 | 
            -
            authors:
         | 
| 7 | 
            +
            authors: 
         | 
| 8 8 | 
             
            - Toms Mikoss
         | 
| 9 9 | 
             
            autorequire: 
         | 
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 12 | 
            +
             | 
| 13 | 
            +
            date: 2012-06-03 00:00:00 Z
         | 
| 14 | 
            +
            dependencies: 
         | 
| 15 | 
            +
            - !ruby/object:Gem::Dependency 
         | 
| 15 16 | 
             
              name: activerecord
         | 
| 16 | 
            -
              requirement: & | 
| 17 | 
            +
              requirement: &id001 !ruby/object:Gem::Requirement 
         | 
| 17 18 | 
             
                none: false
         | 
| 18 | 
            -
                requirements:
         | 
| 19 | 
            -
                - -  | 
| 20 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            +
                requirements: 
         | 
| 20 | 
            +
                - - ">="
         | 
| 21 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 21 22 | 
             
                    version: 3.0.0
         | 
| 22 23 | 
             
              type: :runtime
         | 
| 23 24 | 
             
              prerelease: false
         | 
| 24 | 
            -
              version_requirements: * | 
| 25 | 
            -
            - !ruby/object:Gem::Dependency
         | 
| 25 | 
            +
              version_requirements: *id001
         | 
| 26 | 
            +
            - !ruby/object:Gem::Dependency 
         | 
| 26 27 | 
             
              name: rspec
         | 
| 27 | 
            -
              requirement: & | 
| 28 | 
            +
              requirement: &id002 !ruby/object:Gem::Requirement 
         | 
| 28 29 | 
             
                none: false
         | 
| 29 | 
            -
                requirements:
         | 
| 30 | 
            -
                - -  | 
| 31 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 32 | 
            -
                    version:  | 
| 30 | 
            +
                requirements: 
         | 
| 31 | 
            +
                - - ">="
         | 
| 32 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 33 | 
            +
                    version: "0"
         | 
| 33 34 | 
             
              type: :development
         | 
| 34 35 | 
             
              prerelease: false
         | 
| 35 | 
            -
              version_requirements: * | 
| 36 | 
            -
            - !ruby/object:Gem::Dependency
         | 
| 37 | 
            -
              name:  | 
| 38 | 
            -
              requirement: & | 
| 36 | 
            +
              version_requirements: *id002
         | 
| 37 | 
            +
            - !ruby/object:Gem::Dependency 
         | 
| 38 | 
            +
              name: jeweler
         | 
| 39 | 
            +
              requirement: &id003 !ruby/object:Gem::Requirement 
         | 
| 39 40 | 
             
                none: false
         | 
| 40 | 
            -
                requirements:
         | 
| 41 | 
            -
                - -  | 
| 42 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 43 | 
            -
                    version:  | 
| 41 | 
            +
                requirements: 
         | 
| 42 | 
            +
                - - ">="
         | 
| 43 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 44 | 
            +
                    version: "0"
         | 
| 44 45 | 
             
              type: :development
         | 
| 45 46 | 
             
              prerelease: false
         | 
| 46 | 
            -
              version_requirements: * | 
| 47 | 
            -
            - !ruby/object:Gem::Dependency
         | 
| 48 | 
            -
              name:  | 
| 49 | 
            -
              requirement: & | 
| 47 | 
            +
              version_requirements: *id003
         | 
| 48 | 
            +
            - !ruby/object:Gem::Dependency 
         | 
| 49 | 
            +
              name: mysql2
         | 
| 50 | 
            +
              requirement: &id004 !ruby/object:Gem::Requirement 
         | 
| 50 51 | 
             
                none: false
         | 
| 51 | 
            -
                requirements:
         | 
| 52 | 
            -
                - -  | 
| 53 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 54 | 
            -
                    version:  | 
| 52 | 
            +
                requirements: 
         | 
| 53 | 
            +
                - - ">="
         | 
| 54 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 55 | 
            +
                    version: "0"
         | 
| 55 56 | 
             
              type: :development
         | 
| 56 57 | 
             
              prerelease: false
         | 
| 57 | 
            -
              version_requirements: * | 
| 58 | 
            -
            - !ruby/object:Gem::Dependency
         | 
| 59 | 
            -
              name:  | 
| 60 | 
            -
              requirement: & | 
| 58 | 
            +
              version_requirements: *id004
         | 
| 59 | 
            +
            - !ruby/object:Gem::Dependency 
         | 
| 60 | 
            +
              name: activerecord-jdbcmysql-adapter
         | 
| 61 | 
            +
              requirement: &id005 !ruby/object:Gem::Requirement 
         | 
| 61 62 | 
             
                none: false
         | 
| 62 | 
            -
                requirements:
         | 
| 63 | 
            -
                - -  | 
| 64 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 65 | 
            -
                    version:  | 
| 63 | 
            +
                requirements: 
         | 
| 64 | 
            +
                - - ">="
         | 
| 65 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 66 | 
            +
                    version: "0"
         | 
| 66 67 | 
             
              type: :development
         | 
| 67 68 | 
             
              prerelease: false
         | 
| 68 | 
            -
              version_requirements: * | 
| 69 | 
            +
              version_requirements: *id005
         | 
| 69 70 | 
             
            description: ActiveRecord extension that allows to infer validation rules from database
         | 
| 70 71 | 
             
            email: toms.mikoss@gmail.com
         | 
| 71 72 | 
             
            executables: []
         | 
| 73 | 
            +
             | 
| 72 74 | 
             
            extensions: []
         | 
| 73 | 
            -
             | 
| 75 | 
            +
             | 
| 76 | 
            +
            extra_rdoc_files: 
         | 
| 74 77 | 
             
            - LICENSE.txt
         | 
| 75 78 | 
             
            - README.md
         | 
| 76 | 
            -
            files:
         | 
| 79 | 
            +
            files: 
         | 
| 77 80 | 
             
            - .document
         | 
| 78 81 | 
             
            - .rspec
         | 
| 82 | 
            +
            - .travis.yml
         | 
| 79 83 | 
             
            - Gemfile
         | 
| 80 84 | 
             
            - LICENSE.txt
         | 
| 81 85 | 
             
            - README.md
         | 
| 82 86 | 
             
            - Rakefile
         | 
| 83 87 | 
             
            - VERSION
         | 
| 88 | 
            +
            - automagical_validations.gemspec
         | 
| 84 89 | 
             
            - lib/automagical_validations.rb
         | 
| 85 90 | 
             
            - spec/automagical_validations_spec.rb
         | 
| 86 91 | 
             
            - spec/spec_helper.rb
         | 
| 87 92 | 
             
            homepage: http://github.com/tmikoss/automagical_validations
         | 
| 88 | 
            -
            licenses:
         | 
| 93 | 
            +
            licenses: 
         | 
| 89 94 | 
             
            - MIT
         | 
| 90 95 | 
             
            post_install_message: 
         | 
| 91 96 | 
             
            rdoc_options: []
         | 
| 92 | 
            -
             | 
| 97 | 
            +
             | 
| 98 | 
            +
            require_paths: 
         | 
| 93 99 | 
             
            - lib
         | 
| 94 | 
            -
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 100 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement 
         | 
| 95 101 | 
             
              none: false
         | 
| 96 | 
            -
              requirements:
         | 
| 97 | 
            -
              - -  | 
| 98 | 
            -
                - !ruby/object:Gem::Version
         | 
| 99 | 
            -
                   | 
| 100 | 
            -
                  segments:
         | 
| 102 | 
            +
              requirements: 
         | 
| 103 | 
            +
              - - ">="
         | 
| 104 | 
            +
                - !ruby/object:Gem::Version 
         | 
| 105 | 
            +
                  hash: -3639426043304595810
         | 
| 106 | 
            +
                  segments: 
         | 
| 101 107 | 
             
                  - 0
         | 
| 102 | 
            -
                   | 
| 103 | 
            -
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 108 | 
            +
                  version: "0"
         | 
| 109 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement 
         | 
| 104 110 | 
             
              none: false
         | 
| 105 | 
            -
              requirements:
         | 
| 106 | 
            -
              - -  | 
| 107 | 
            -
                - !ruby/object:Gem::Version
         | 
| 108 | 
            -
                  version:  | 
| 111 | 
            +
              requirements: 
         | 
| 112 | 
            +
              - - ">="
         | 
| 113 | 
            +
                - !ruby/object:Gem::Version 
         | 
| 114 | 
            +
                  version: "0"
         | 
| 109 115 | 
             
            requirements: []
         | 
| 116 | 
            +
             | 
| 110 117 | 
             
            rubyforge_project: 
         | 
| 111 | 
            -
            rubygems_version: 1.8. | 
| 118 | 
            +
            rubygems_version: 1.8.24
         | 
| 112 119 | 
             
            signing_key: 
         | 
| 113 120 | 
             
            specification_version: 3
         | 
| 114 121 | 
             
            summary: ActiveRecord extension that allows to infer validation rules from database
         | 
| 115 122 | 
             
            test_files: []
         | 
| 123 | 
            +
             |