Skip to content

Commit

Permalink
chore(*): Test against ruby 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
plribeiro3000 committed Apr 26, 2021
1 parent c07a21e commit 0e6f84b
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 12 deletions.
4 changes: 4 additions & 0 deletions .rubocop.yml
@@ -1,5 +1,9 @@
require: rubocop-rspec

AllCops:
TargetRubyVersion: 2.0
NewCops: enable

Layout/EmptyLinesAroundAttributeAccessor:
Enabled: true

Expand Down
14 changes: 14 additions & 0 deletions .travis.yml
Expand Up @@ -24,8 +24,22 @@ matrix:
gemfile: gemfiles/Gemfile.rails4
- rvm: 2.5
gemfile: gemfiles/Gemfile.rails5
- rvm: 2.5
gemfile: gemfiles/Gemfile.rails6
- rvm: 2.6
gemfile: gemfiles/Gemfile.rails4
- rvm: 2.6
gemfile: gemfiles/Gemfile.rails5
- rvm: 2.6
gemfile: gemfiles/Gemfile.rails6
- rvm: 2.7
gemfile: gemfiles/Gemfile.rails4
- rvm: 2.7
gemfile: gemfiles/Gemfile.rails5
- rvm: 2.7
gemfile: gemfiles/Gemfile.rails6
- rvm: 3.0
gemfile: gemfiles/Gemfile.rails4
- rvm: 3.0
gemfile: gemfiles/Gemfile.rails6
script: rake complete
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -2,7 +2,8 @@

[![Gem Version](https://badge.fury.io/rb/validates_host.png)](http://badge.fury.io/rb/validates_host) [![Build Status](https://secure.travis-ci.org/plribeiro3000/validates_host.png?branch=master)](http://travis-ci.org/plribeiro3000/validates_host) [![Coverage Status](https://coveralls.io/repos/plribeiro3000/validates_host/badge.png?branch=master)](https://coveralls.io/r/plribeiro3000/validates_host) [![Code Climate](https://codeclimate.com/github/plribeiro3000/validates_host.png)](https://codeclimate.com/github/plribeiro3000/validates_host)

Validates host attributes and test it in a simple way
Validates host attributes and test it in a simple way.
Supports ruby 2.0+ and rails 3+

## Installation

Expand Down
4 changes: 2 additions & 2 deletions gemfiles/Gemfile.rails5
@@ -1,5 +1,5 @@
source :rubygems

gem 'activesupport', '>= 5.0.0'
gem 'activesupport', '>= 5.0.0', '< 6.0.0'

gemspec :path => '../'
gemspec :path => '../'
5 changes: 5 additions & 0 deletions gemfiles/Gemfile.rails6
@@ -0,0 +1,5 @@
source :rubygems

gem 'activesupport', '>= 6.0.0'

gemspec :path => '../'
11 changes: 10 additions & 1 deletion lib/validates_host/domain_name_validator.rb
Expand Up @@ -2,6 +2,15 @@

class DomainNameValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
record.errors.add(attribute, :invalid, options) unless ValidatesHost::DomainName.new(value).valid?
return if ValidatesHost::DomainName.new(value).valid?

ruby_prior_version_three =
Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.0.0')

if ruby_prior_version_three
record.errors.add(attribute, :invalid, options)
else
record.errors.add(attribute, :invalid, **options)
end
end
end
11 changes: 10 additions & 1 deletion lib/validates_host/host_name_validator.rb
Expand Up @@ -2,6 +2,15 @@

class HostNameValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
record.errors.add(attribute, :invalid, options) unless ValidatesHost::HostName.new(value).valid?
return if ValidatesHost::HostName.new(value).valid?

ruby_prior_version_three =
Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.0.0')

if ruby_prior_version_three
record.errors.add(attribute, :invalid, options)
else
record.errors.add(attribute, :invalid, **options)
end
end
end
11 changes: 10 additions & 1 deletion lib/validates_host/ip_validator.rb
Expand Up @@ -2,6 +2,15 @@

class IpValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
record.errors.add(attribute, :invalid, options) unless ValidatesHost::Ip.new(value).valid?
return if ValidatesHost::Ip.new(value).valid?

ruby_prior_version_three =
Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.0.0')

if ruby_prior_version_three
record.errors.add(attribute, :invalid, options)
else
record.errors.add(attribute, :invalid, **options)
end
end
end
11 changes: 10 additions & 1 deletion lib/validates_host/subnet_validator.rb
Expand Up @@ -2,6 +2,15 @@

class SubnetValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
record.errors.add(attribute, :invalid, options) unless ValidatesHost::Subnet.new(value).valid?
return if ValidatesHost::Subnet.new(value).valid?

ruby_prior_version_three =
Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3.0.0')

if ruby_prior_version_three
record.errors.add(attribute, :invalid, options)
else
record.errors.add(attribute, :invalid, **options)
end
end
end
11 changes: 6 additions & 5 deletions validates_host.gemspec
Expand Up @@ -9,17 +9,18 @@ Gem::Specification.new do |gem|
gem.email = 'plribeiro3000@gmail.com'
gem.summary = 'Validates Host, Domain and IP and test it with matchers in a simple way.'

gem.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
gem.test_files = `git ls-files -- {test,spec,features,examples,gemfiles}/*`.split("\n")
gem.executables = `git ls-files -- bin/*`.split('\n').map { |f| File.basename(f) }
gem.require_paths = %w[lib]
gem.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
gem.test_files = `git ls-files -- {test,spec,features,examples,gemfiles}/*`.split("\n")
gem.executables = `git ls-files -- bin/*`.split('\n').map { |f| File.basename(f) }
gem.require_paths = %w[lib]
gem.required_ruby_version = '>= 2.0.0'

gem.license = 'MIT'

gem.add_development_dependency 'coveralls'
gem.add_development_dependency 'rake'
gem.add_development_dependency 'rspec'
gem.add_development_dependency 'rubocop'
gem.add_development_dependency 'rubocop', '< 0.50'
gem.add_development_dependency 'rubocop-rspec'
gem.add_development_dependency 'shoulda-matchers'

Expand Down

0 comments on commit 0e6f84b

Please sign in to comment.