can_has_validations 0.6.3 → 1.0.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d565ec38823188e137ba900db6247e643f3c436a6a8f0be7d210a8af0f2606e6
4
- data.tar.gz: 47fc9fc83d7224d9831d66a98e967b161b6f3fa66de7186b8b51c85ffc8287d1
3
+ metadata.gz: 98d343f6a4e3bded76cac6973926550938ba481bc9357585c3d83fb8427f48e1
4
+ data.tar.gz: dc5648966508e9db4ff6972475f1df6b813fa9beb7bd5b83192eb5483ad09e08
5
5
  SHA512:
6
- metadata.gz: 1cfa321ceee3431a7b2a99027794a655a5cd2b0a570eb715ccbaf06be183956689bfb7e369b0927d31f6a80f781591fae5422803df836fe2b41a9e52babe3bbd
7
- data.tar.gz: 34d93b15d141061ded5dc58c2cdb62f2abe646e60c4e49e6b4ee8856d76356a3e83be0c080db3f71a5499ae095955299a3cfc978ee90d86fc50c4b465e289662
6
+ metadata.gz: 4b6bf6510a992f70ffb418010bc05ae0f97ddb181c7d0482c93ff87756abac7024b8c3e9cf32caee7cfefac7a93bf60b0292475732ea9dc3a39a2009196f6893
7
+ data.tar.gz: 4a157d72a5ec06a71e3e07a93e4f9fa009fedc7e637b4188d7a7aad2aadb3f55b612e94f3eb3a54dcd1581874ae646f001d00efa956e31e2eb65633b5551a276
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2012 YOURNAME
1
+ Copyright 2012-2019 thomas morgan
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -190,6 +190,10 @@ can be specified; they default to ['http','https'].
190
190
  validates :website, url: true
191
191
  validates :secure_url, url: {scheme: 'https'}
192
192
 
193
+ # Dynamic list of schemes. *Must* return an array.
194
+ validates :git, url: {scheme: :some_method}
195
+ validates :old_school, url: {scheme: ->(record){ %w(ftp gopher) }}
196
+
193
197
  # With IDN parsing:
194
198
  require 'addressable/uri'
195
199
  validates :website, url: true
@@ -236,4 +240,4 @@ Default messages are as follows:
236
240
 
237
241
  ## Compatibility ##
238
242
 
239
- Tested with Ruby 2.3-2.5 and ActiveSupport and ActiveModel 4.2-5.2.
243
+ The current version is tested with Ruby 2.5-2.6 and ActiveModel 5.2-6.0.
@@ -7,7 +7,13 @@
7
7
  module ActiveModel::Validations
8
8
  class UrlValidator < ActiveModel::EachValidator
9
9
  def validate_each(record, attribute, value)
10
- allowed_schemes = Array.wrap(options[:scheme] || %w(http https))
10
+ allowed_schemes = if options[:scheme].respond_to?(:call)
11
+ options[:scheme].call(record)
12
+ elsif options[:scheme].is_a?(Symbol)
13
+ record.send(options[:scheme])
14
+ else
15
+ Array.wrap(options[:scheme] || %w(http https))
16
+ end
11
17
 
12
18
  if defined?(Addressable::URI)
13
19
  u = Addressable::URI.parse(value) rescue nil
@@ -16,7 +22,7 @@ module ActiveModel::Validations
16
22
  u2 = u = URI.parse(value) rescue nil
17
23
  end
18
24
  if !u || !u2 || u.relative? || allowed_schemes.exclude?(u.scheme)
19
- record.errors.add(attribute, :invalid_url, options.merge(value: value))
25
+ record.errors.add(attribute, :invalid_url, options.merge(value: value, scheme: allowed_schemes))
20
26
  end
21
27
  end
22
28
  end
@@ -1,3 +1,3 @@
1
1
  module CanHasValidations
2
- VERSION = '0.6.3'
2
+ VERSION = '1.0.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: can_has_validations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - thomas morgan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-07 00:00:00.000000000 Z
11
+ date: 2019-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,20 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '3.0'
19
+ version: '5.0'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '6'
22
+ version: '6.1'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: '3.0'
29
+ version: '5.0'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '6'
32
+ version: '6.1'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: sqlite3
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -44,7 +44,7 @@ dependencies:
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
46
  version: '0'
47
- description: Assorted Rails 4.x-5.x validators.
47
+ description: Assorted Rails 5.x-6.x validators.
48
48
  email:
49
49
  - tm@iprog.com
50
50
  executables: []
@@ -115,40 +115,39 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
115
  - !ruby/object:Gem::Version
116
116
  version: '0'
117
117
  requirements: []
118
- rubyforge_project:
119
- rubygems_version: 2.7.6
118
+ rubygems_version: 3.0.3
120
119
  signing_key:
121
120
  specification_version: 4
122
- summary: Assorted Rails 4.x-5.x validators
121
+ summary: Assorted Rails 5.x-6.x validators
123
122
  test_files:
124
- - test/can_has_validations_test.rb
123
+ - test/dummy/app/controllers/application_controller.rb
124
+ - test/dummy/app/views/layouts/application.html.erb
125
125
  - test/dummy/app/assets/javascripts/application.js
126
126
  - test/dummy/app/assets/stylesheets/application.css
127
- - test/dummy/app/controllers/application_controller.rb
128
127
  - test/dummy/app/helpers/application_helper.rb
129
- - test/dummy/app/views/layouts/application.html.erb
130
- - test/dummy/config/application.rb
131
- - test/dummy/config/boot.rb
132
- - test/dummy/config/database.yml
133
- - test/dummy/config/environment.rb
134
- - test/dummy/config/environments/development.rb
128
+ - test/dummy/config/routes.rb
129
+ - test/dummy/config/locales/en.yml
135
130
  - test/dummy/config/environments/production.rb
131
+ - test/dummy/config/environments/development.rb
136
132
  - test/dummy/config/environments/test.rb
133
+ - test/dummy/config/environment.rb
134
+ - test/dummy/config/application.rb
135
+ - test/dummy/config/database.yml
136
+ - test/dummy/config/boot.rb
137
137
  - test/dummy/config/initializers/backtrace_silencers.rb
138
- - test/dummy/config/initializers/inflections.rb
139
138
  - test/dummy/config/initializers/mime_types.rb
140
- - test/dummy/config/initializers/secret_token.rb
141
139
  - test/dummy/config/initializers/session_store.rb
142
140
  - test/dummy/config/initializers/wrap_parameters.rb
143
- - test/dummy/config/locales/en.yml
144
- - test/dummy/config/routes.rb
141
+ - test/dummy/config/initializers/secret_token.rb
142
+ - test/dummy/config/initializers/inflections.rb
145
143
  - test/dummy/config.ru
146
- - test/dummy/log/test.log
147
- - test/dummy/public/404.html
144
+ - test/dummy/script/rails
145
+ - test/dummy/Rakefile
146
+ - test/dummy/public/favicon.ico
148
147
  - test/dummy/public/422.html
149
148
  - test/dummy/public/500.html
150
- - test/dummy/public/favicon.ico
151
- - test/dummy/Rakefile
149
+ - test/dummy/public/404.html
150
+ - test/dummy/log/test.log
152
151
  - test/dummy/README.rdoc
153
- - test/dummy/script/rails
152
+ - test/can_has_validations_test.rb
154
153
  - test/test_helper.rb