Skip to content

Commit

Permalink
feature: Change to a Rails 4 ActiveModel validator.
Browse files Browse the repository at this point in the history
Rails 4 introduced ActiveModel, ActiveModel::Validations and
ActiveModel::EachValidator.

Instead of injecting ourselves into ActiveRecord::Base, we will be
automatically picked up. This fixes KimNorgaard#1.

We can now also be used on ActiveModel as well as ActiveRecord. This
simplifies testing.

Also
* rspec-rails was dropped becasue it seems to want all of Rails loaded.
  We only needed one convenience method, errors_on. It has been copied into our test model.
* Bumped our runtime dependency to activemodel >= 4.0. Dropped the others.
* Dropped the development dependency on all of Rails. We only need ActiveModel.
  • Loading branch information
schwern committed Feb 17, 2020
1 parent 7a6abba commit b197c81
Show file tree
Hide file tree
Showing 6 changed files with 249 additions and 262 deletions.
4 changes: 3 additions & 1 deletion README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

== Description

Extension to ActiveRecord::Base for validating hostnames and domain names.
Validate hostnames and domain names in Rails.


== Features
Expand All @@ -16,6 +16,8 @@ Extension to ActiveRecord::Base for validating hostnames and domain names.

== Installation

Requires Rails 4 or newer.

As plugin (from master)

rails plugin install git://github.com/KimNorgaard/validates_hostname.git
Expand Down
8 changes: 2 additions & 6 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,16 @@ spec = Gem::Specification.new do |s|
s.version = GEM_VERSION
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Kim Nørgaard"]
s.description = 'Extension to ActiveRecord::Base for validating hostnames'
s.description = 'Extension to validate hostnames in Rails'
s.summary = 'Checks for valid hostnames'
s.email = '[email protected]'
s.extra_rdoc_files = ["README.rdoc", "CHANGELOG.rdoc", "MIT-LICENSE"]
s.files = ["validates_hostname.gemspec", "MIT-LICENSE", "CHANGELOG.rdoc", "README.rdoc", "Rakefile", "lib/validates_hostname", "lib/validates_hostname/version.rb", "lib/validates_hostname.rb"]
s.homepage = %q{https://github.com/KimNorgaard/validates_hostname}
s.licenses = 'MIT'
s.require_paths = ["lib"]
s.add_runtime_dependency 'activerecord', '>= 3.0'
s.add_runtime_dependency 'activesupport', '>= 3.0'
s.add_runtime_dependency 'activemodel', '>= 4.0'
s.add_development_dependency 'rspec', '~> 3.0'
s.add_development_dependency 'rspec-rails'
s.add_development_dependency 'rails'
s.add_development_dependency 'sqlite3'
s.add_development_dependency 'pry-byebug'
s.add_development_dependency 'rspec-collection_matchers'
end
Expand Down
Loading

0 comments on commit b197c81

Please sign in to comment.