url_validation 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 682d17ebc6fc4e9cc86e12f9040c24266b4f9caf
4
- data.tar.gz: c9e43aa2a8b465f1d099f8303478ed55ea4f4552
3
+ metadata.gz: 0fae744847fddf375172f64d9e40a200982b3d8c
4
+ data.tar.gz: fab400c0e41670a2ffeefa1fcb03a398f3712792
5
5
  SHA512:
6
- metadata.gz: 23c5029413f8796d6b1225d3e58db091f801c636006344499dae7cc9dc14f7f665110dab8b8c2fe3e3502b19899fe1fd7f2792a0b4ea6cb15b6309d93b79ffa9
7
- data.tar.gz: 719a8dcd6c4b5f85e483a1c0597ba15e82bccf8b5ae1352569ecbaf303fdbc81f692642c467037b8a3ff2b133cc580b7951b1899ed82d08338f4eb898352864d
6
+ metadata.gz: e15971f514c8b53fb1af82b1bc751cc4bc1dd8da092e68e27984eff755494be750edfda5e2d88c2ab7584ce59433bf05aed115f06b2d5cc6dbfa58b0a488605f
7
+ data.tar.gz: b98920d33b63e3792b63f8bc8bfbeb1798478f09c97d47a6e451fc62921904eb0d5887959d5dc8943149626bb381205670752b2d827a2e0b97bbf67a3bf61cde
@@ -1 +1 @@
1
- 2.1.4
1
+ 2.4.1
data/Gemfile CHANGED
@@ -1,13 +1,18 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'addressable', :require => 'addressable/uri' # for unicode URIs
3
+ gem 'addressable', require: 'addressable/uri' # for unicode URIs
4
4
  gem 'activesupport'
5
5
  gem 'activerecord'
6
6
  gem 'httpi'
7
7
 
8
8
  group :development do
9
- gem 'jeweler'
10
- gem 'yard'
11
- gem 'RedCloth', require: 'redcloth'
9
+ # PUBLISHING
10
+ gem 'juwelier'
11
+
12
+ # DOCS
13
+ gem 'yard', require: nil
14
+ gem 'redcarpet', require: nil
15
+
16
+ # SPECS
12
17
  gem 'rspec'
13
18
  end
@@ -1,96 +1,106 @@
1
1
  GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
- RedCloth (4.2.9)
5
- activemodel (4.1.7)
6
- activesupport (= 4.1.7)
7
- builder (~> 3.1)
8
- activerecord (4.1.7)
9
- activemodel (= 4.1.7)
10
- activesupport (= 4.1.7)
11
- arel (~> 5.0.0)
12
- activesupport (4.1.7)
13
- i18n (~> 0.6, >= 0.6.9)
14
- json (~> 1.7, >= 1.7.7)
4
+ activemodel (5.1.1)
5
+ activesupport (= 5.1.1)
6
+ activerecord (5.1.1)
7
+ activemodel (= 5.1.1)
8
+ activesupport (= 5.1.1)
9
+ arel (~> 8.0)
10
+ activesupport (5.1.1)
11
+ concurrent-ruby (~> 1.0, >= 1.0.2)
12
+ i18n (~> 0.7)
15
13
  minitest (~> 5.1)
16
- thread_safe (~> 0.1)
17
14
  tzinfo (~> 1.1)
18
- addressable (2.3.6)
19
- arel (5.0.1.20140414130214)
20
- builder (3.2.2)
15
+ addressable (2.4.0)
16
+ arel (8.0.0)
17
+ builder (3.2.3)
18
+ concurrent-ruby (1.0.5)
21
19
  descendants_tracker (0.0.4)
22
20
  thread_safe (~> 0.3, >= 0.3.1)
23
- diff-lcs (1.2.5)
24
- faraday (0.9.0)
21
+ diff-lcs (1.3)
22
+ faraday (0.9.2)
25
23
  multipart-post (>= 1.2, < 3)
26
- git (1.2.8)
27
- github_api (0.12.2)
28
- addressable (~> 2.3)
24
+ git (1.3.0)
25
+ github_api (0.17.0)
26
+ addressable (~> 2.4.0)
29
27
  descendants_tracker (~> 0.0.4)
30
28
  faraday (~> 0.8, < 0.10)
31
- hashie (>= 3.3)
32
- multi_json (>= 1.7.5, < 2.0)
33
- nokogiri (~> 1.6.3)
34
- oauth2
35
- hashie (3.3.1)
36
- highline (1.6.21)
37
- httpi (2.2.7)
29
+ hashie (>= 3.4)
30
+ mime-types (>= 1.16, < 3.0)
31
+ oauth2 (~> 1.0)
32
+ hashie (3.5.5)
33
+ highline (1.7.8)
34
+ httpi (2.4.2)
38
35
  rack
39
- i18n (0.6.11)
40
- jeweler (2.0.1)
36
+ socksify
37
+ i18n (0.8.4)
38
+ juwelier (2.4.5)
41
39
  builder
42
- bundler (>= 1.0)
40
+ bundler (>= 1.13)
43
41
  git (>= 1.2.5)
44
42
  github_api
45
43
  highline (>= 1.6.15)
44
+ kamelcase (~> 0)
46
45
  nokogiri (>= 1.5.10)
46
+ psych (~> 2.2)
47
47
  rake
48
48
  rdoc
49
- json (1.8.1)
50
- jwt (1.0.0)
51
- mini_portile (0.6.1)
52
- minitest (5.4.2)
53
- multi_json (1.10.1)
54
- multi_xml (0.5.5)
49
+ semver2
50
+ jwt (1.5.6)
51
+ kamelcase (0.0.0)
52
+ semver2 (~> 3)
53
+ mime-types (2.99.3)
54
+ mini_portile2 (2.1.0)
55
+ minitest (5.10.2)
56
+ multi_json (1.12.1)
57
+ multi_xml (0.6.0)
55
58
  multipart-post (2.0.0)
56
- nokogiri (1.6.4.1)
57
- mini_portile (~> 0.6.0)
58
- oauth2 (1.0.0)
59
- faraday (>= 0.8, < 0.10)
59
+ nokogiri (1.7.2)
60
+ mini_portile2 (~> 2.1.0)
61
+ oauth2 (1.3.1)
62
+ faraday (>= 0.8, < 0.12)
60
63
  jwt (~> 1.0)
61
64
  multi_json (~> 1.3)
62
65
  multi_xml (~> 0.5)
63
- rack (~> 1.2)
64
- rack (1.5.2)
65
- rake (10.3.2)
66
- rdoc (4.1.2)
67
- json (~> 1.4)
68
- rspec (3.1.0)
69
- rspec-core (~> 3.1.0)
70
- rspec-expectations (~> 3.1.0)
71
- rspec-mocks (~> 3.1.0)
72
- rspec-core (3.1.7)
73
- rspec-support (~> 3.1.0)
74
- rspec-expectations (3.1.2)
66
+ rack (>= 1.2, < 3)
67
+ psych (2.2.4)
68
+ rack (2.0.3)
69
+ rake (12.0.0)
70
+ rdoc (5.1.0)
71
+ redcarpet (3.4.0)
72
+ rspec (3.6.0)
73
+ rspec-core (~> 3.6.0)
74
+ rspec-expectations (~> 3.6.0)
75
+ rspec-mocks (~> 3.6.0)
76
+ rspec-core (3.6.0)
77
+ rspec-support (~> 3.6.0)
78
+ rspec-expectations (3.6.0)
79
+ diff-lcs (>= 1.2.0, < 2.0)
80
+ rspec-support (~> 3.6.0)
81
+ rspec-mocks (3.6.0)
75
82
  diff-lcs (>= 1.2.0, < 2.0)
76
- rspec-support (~> 3.1.0)
77
- rspec-mocks (3.1.3)
78
- rspec-support (~> 3.1.0)
79
- rspec-support (3.1.2)
80
- thread_safe (0.3.4)
81
- tzinfo (1.2.2)
83
+ rspec-support (~> 3.6.0)
84
+ rspec-support (3.6.0)
85
+ semver2 (3.4.2)
86
+ socksify (1.7.1)
87
+ thread_safe (0.3.6)
88
+ tzinfo (1.2.3)
82
89
  thread_safe (~> 0.1)
83
- yard (0.8.7.6)
90
+ yard (0.9.9)
84
91
 
85
92
  PLATFORMS
86
93
  ruby
87
94
 
88
95
  DEPENDENCIES
89
- RedCloth
90
96
  activerecord
91
97
  activesupport
92
98
  addressable
93
99
  httpi
94
- jeweler
100
+ juwelier
101
+ redcarpet
95
102
  rspec
96
103
  yard
104
+
105
+ BUNDLED WITH
106
+ 1.15.0
@@ -0,0 +1,40 @@
1
+ # url_validation
2
+
3
+ Simple URL validator for Rails 3.
4
+
5
+ | | |
6
+ |:------------|:--------------------------------|
7
+ | **Author** | Tim Morgan |
8
+ | **Version** | 1.0 (May 9, 2011) |
9
+ | **License** | Released under the MIT license. |
10
+
11
+ ## About
12
+
13
+ This gem adds a very simple URL format validator to be used with Active Record
14
+ models in Rails 3.0. It supports localized error messages. It can validate many
15
+ different kinds of URLs, including HTTP and HTTPS. It supports advanced
16
+ validation features like sending `HEAD` requests to URLS to verify that they are
17
+ valid endpoints.
18
+
19
+ ## Installation
20
+
21
+ Add the gem to your project's Gemfile:
22
+
23
+ ``` ruby
24
+ gem 'url_validation'
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ This gem is an `EachValidator`, and thus is used with the `validates` method:
30
+
31
+ ``` ruby
32
+ class User < ActiveRecord::Base
33
+ validates :terms_of_service_link,
34
+ presence: true,
35
+ url: true
36
+ end
37
+ ```
38
+
39
+ There are other options to fine-tune your validation; see the {UrlValidator}
40
+ class for more, and for a list of error message localization keys.
data/Rakefile CHANGED
@@ -9,30 +9,30 @@ rescue Bundler::BundlerError => e
9
9
  end
10
10
  require 'rake'
11
11
 
12
- require 'jeweler'
13
- Jeweler::Tasks.new do |gem|
14
- gem.name = "url_validation"
15
- gem.summary = %Q{Simple URL validation in Rails 3}
12
+ require 'juwelier'
13
+ Juwelier::Tasks.new do |gem|
14
+ gem.name = 'url_validation'
15
+ gem.summary = %Q{Simple URL validation in Rails 3+}
16
16
  gem.description = %Q{A simple, localizable EachValidator for URL fields in ActiveRecord 3.0.}
17
- gem.email = "git@timothymorgan.info"
18
- gem.homepage = "http://github.com/riscfuture/url_validation"
19
- gem.authors = [ "Tim Morgan" ]
20
- gem.required_ruby_version = '>= 1.8.7'
17
+ gem.email = 'git@timothymorgan.info'
18
+ gem.homepage = 'http://github.com/riscfuture/url_validation'
19
+ gem.authors = ['Tim Morgan']
20
+ gem.required_ruby_version = '>= 2.0.0'
21
21
  end
22
- Jeweler::RubygemsDotOrgTasks.new
22
+ Juwelier::RubygemsDotOrgTasks.new
23
23
 
24
24
  require 'yard'
25
25
  YARD::Rake::YardocTask.new('doc') do |doc|
26
- doc.options << "-m" << "textile"
27
- doc.options << "--protected" << "--no-private"
28
- doc.options << "-r" << "README.textile"
29
- doc.options << "-o" << "doc"
30
- doc.options << "--title" << "url_validation Documentation".inspect
31
-
32
- doc.files = [ 'lib/*_validator.rb', 'README.textile' ]
26
+ doc.options << '-m' << 'markdown' << '-M' << 'redcarpet'
27
+ doc.options << '--protected' << '--no-private'
28
+ doc.options << '-r' << 'README.md'
29
+ doc.options << '-o' << 'doc'
30
+ doc.options << '--title' << 'url_validation Documentation'.inspect
31
+
32
+ doc.files = %w(lib/**/*.rb README.md)
33
33
  end
34
34
 
35
35
  require 'rspec/core/rake_task'
36
36
  RSpec::Core::RakeTask.new
37
37
 
38
- task :default => :spec
38
+ task default: :spec
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0
1
+ 1.2.0
@@ -6,142 +6,154 @@ require 'active_support/core_ext/array/wrap'
6
6
 
7
7
  # Validates URLs. Uses the following I18n error message keys:
8
8
  #
9
- # | @invalid_url@ | URL is improperly formatted. |
10
- # | @url_not_accessible@ | Couldn't connect to the URL. |
11
- # | @url_invalid_response@ | Got a bad HTTP response (not of an acceptable type, e.g., 2xx). |
9
+ # | | |
10
+ # |:-----------------------|:----------------------------------------------------------------|
11
+ # | `invalid_url` | URL is improperly formatted. |
12
+ # | `url_not_accessible` | Couldn't connect to the URL. |
13
+ # | `url_invalid_response` | Got a bad HTTP response (not of an acceptable type, e.g., 2xx). |
12
14
  #
13
15
  # @example Checks the syntax only
14
- # validates :link, :url => true
16
+ # validates :link, url: true
15
17
  #
16
18
  # @example Ensures the host is available but does not check the path
17
- # validates :link, :url => { :check_host => true }
19
+ # validates :link, url: {check_host: true}
18
20
  #
19
21
  # @example Ensures that the host is available and that a request for the path does not return a 4xx or 5xx response
20
- # validates :link, :url => { :check_path => true }
22
+ # validates :link, url: {check_path: true}
21
23
  #
22
24
  # @example Ensures that the host is available and that a request for the path does not return a 3xx, 4xx, or 5xx response
23
- # validates :link, :url => { :check_path => [ 300..399, 400..499, 500..599 ] }
25
+ # validates :link, url: {check_path: [300..399, 400..499, 500..599]}
24
26
  #
25
27
  # @example Checks for host accessibility with a custom timeout
26
- # validates :link, :url => {
27
- # :check_host => true,
28
- # :request_callback => lambda { |request| request.timeout = 30 }
28
+ # validates :link, url: {
29
+ # check_host: true,
30
+ # request_callback: ->(request) { request.timeout = 30 }
29
31
  # }
30
32
  #
31
- # h2. Options
33
+ # ## Options
32
34
  #
33
- # h3. Basic options
35
+ # ### Basic options
34
36
  #
35
- # | @:allow_nil@ | If @true@, @nil@ values are allowed. |
36
- # | @:allow_blank@ | If @true@, @nil@ or empty values are allowed. |
37
+ # | | |
38
+ # |:---------------|:----------------------------------------------|
39
+ # | `:allow_nil` | If `true`, `nil` values are allowed. |
40
+ # | `:allow_blank` | If `true`, `nil` or empty values are allowed. |
37
41
  #
38
- # h3. Error messages
42
+ # ### Error messages
39
43
  #
40
- # | @:invalid_url_message@ | A custom message to use in place of @:invalid_url@. |
41
- # | @:incorrect_url_type_message@ | A custom message to use in place of @:incorrect_url_type@. |
42
- # | @:url_not_accessible_message@ | A custom message to use in place of @:url_not_accessible@. |
43
- # | @:url_invalid_response_message@ | A custom message to use in place of @:url_invalid_response@. |
44
+ # | | |
45
+ # |:--------------------------------|:-------------------------------------------------------------|
46
+ # | `:invalid_url_message` | A custom message to use in place of `:invalid_url`. |
47
+ # | `:incorrect_url_type_message` | A custom message to use in place of `:incorrect_url_type`. |
48
+ # | `:url_not_accessible_message` | A custom message to use in place of `:url_not_accessible`. |
49
+ # | `:url_invalid_response_message` | A custom message to use in place of `:url_invalid_response`. |
44
50
  #
45
- # h3. Networkless URL validation
51
+ # ### Networkless URL validation
46
52
  #
47
- # | @:scheme@ | A string or array of strings, such as "http" or "ftp", indicating which URL schemes are valid. By default only ==HTTP(S)== URLs are accepted. |
48
- # | @:default_scheme@ | A default URL scheme to try for improper URLs. If this is set to, e.g., "http", then when a URL like "whoops.com" is given (which would otherwise fail due to an improper format), "http://whoops.com" will be tried instead. |
53
+ # | | |
54
+ # |:------------------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
55
+ # | `:scheme` | A string or array of strings, such as "http" or "ftp", indicating which URL schemes are valid. By default only HTTP(S) URLs are accepted. |
56
+ # | `:default_scheme` | A default URL scheme to try for improper URLs. If this is set to, e.g., "http", then when a URL like "whoops.com" is given (which would otherwise fail due to an improper format), "http://whoops.com" will be tried instead. |
49
57
  #
50
- # h3. Over-the-network URL validation
58
+ # ### Over-the-network URL validation
51
59
  #
52
60
  # The HTTPI gem is used to provide a generic interface to whatever HTTP client
53
61
  # you wish to use. This allows you to drop in, e.g., a Curl client if you want.
54
- # You can set the HTTPI adapter with the @:httpi_adapter@ option.
62
+ # You can set the HTTPI adapter with the `:httpi_adapter` option.
55
63
  #
56
- # | @:check_host@ | If @true@, the validator will perform a network test to verify that it can connect to the server and access the host (at the "/" path). This check will only be performed for ==HTTP(S)== URLs. |
57
- # | @:check_path@ | An integer or symbol (or array of integers or symbols), such as 301 or @:moved_permanently@, indicating what response codes are unacceptable. You can also use ranges, and include them in an array, such as @[ :moved_permanently, 400..404, 500..599 ]@. By default, this is @nil@, and therefore only host accessibility is checked. If @true@ is given, uses a default set of invalid error codes (4xx and 5xx). Implies @:check_host@ is also true. |
58
- # | @:httpi_adapter@ | The HTTPI adapter to use for checking HTTP and HTTPS URLs (default set by the HTTPI gem). |
64
+ # | | |
65
+ # |:-----------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
66
+ # | `:check_host` | If `true`, the validator will perform a network test to verify that it can connect to the server and access the host (at the "/" path). This check will only be performed for HTTP(S) URLs. |
67
+ # | `:check_path` | An integer or symbol (or array of integers or symbols), such as 301 or `:moved_permanently`, indicating what response codes are unacceptable. You can also use ranges, and include them in an array, such as `[:moved_permanently, 400..404, 500..599]`. By default, this is `nil`, and therefore only host accessibility is checked. If `true` is given, uses a default set of invalid error codes (4xx and 5xx). Implies `:check_host` is also true. |
68
+ # | `:httpi_adapter` | The HTTPI adapter to use for checking HTTP and HTTPS URLs (default set by the HTTPI gem). |
59
69
  #
60
- # h3. Other options
70
+ # ### Other options
61
71
  #
62
- # | @:request_callback@ | A proc that receives the request object (for ==HTTP(S)== requests, the @HTTPI::Request@ object) before it is executed. You can use this proc to set, e.g., custom headers or timeouts on the request. |
72
+ # | | |
73
+ # |:--------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
74
+ # | `:request_callback` | A proc that receives the request object (for HTTP(S) requests, the `HTTPI::Request` object) before it is executed. You can use this proc to set, e.g., custom headers or timeouts on the request. |
63
75
 
64
76
  class UrlValidator < ActiveModel::EachValidator
65
77
  # @private
66
78
  CODES = {
67
- :continue => 100,
68
- :switching_protocols => 101,
69
- :processing => 102,
70
- :ok => 200,
71
- :created => 201,
72
- :accepted => 202,
73
- :non_authoritative_information => 203,
74
- :no_content => 204,
75
- :reset_content => 205,
76
- :partial_content => 206,
77
- :multi_status => 207,
78
- :im_used => 226,
79
- :multiple_choices => 300,
80
- :moved_permanently => 301,
81
- :found => 302,
82
- :see_other => 303,
83
- :not_modified => 304,
84
- :use_proxy => 305,
85
- :reserved => 306,
86
- :temporary_redirect => 307,
87
- :bad_request => 400,
88
- :unauthorized => 401,
89
- :payment_required => 402,
90
- :forbidden => 403,
91
- :not_found => 404,
92
- :method_not_allowed => 405,
93
- :not_acceptable => 406,
94
- :proxy_authentication_required => 407,
95
- :request_timeout => 408,
96
- :conflict => 409,
97
- :gone => 410,
98
- :length_required => 411,
99
- :precondition_failed => 412,
100
- :request_entity_too_large => 413,
101
- :request_uri_too_long => 414,
102
- :unsupported_media_type => 415,
103
- :requested_range_not_satisfiable => 416,
104
- :expectation_failed => 417,
105
- :unprocessable_entity => 422,
106
- :locked => 423,
107
- :failed_dependency => 424,
108
- :upgrade_required => 426,
109
- :internal_server_error => 500,
110
- :not_implemented => 501,
111
- :bad_gateway => 502,
112
- :service_unavailable => 503,
113
- :gateway_timeout => 504,
114
- :http_version_not_supported => 505,
115
- :variant_also_negotiates => 506,
116
- :insufficient_storage => 507,
117
- :not_extended => 510
79
+ continue: 100,
80
+ switching_protocols: 101,
81
+ processing: 102,
82
+ ok: 200,
83
+ created: 201,
84
+ accepted: 202,
85
+ non_authoritative_information: 203,
86
+ no_content: 204,
87
+ reset_content: 205,
88
+ partial_content: 206,
89
+ multi_status: 207,
90
+ im_used: 226,
91
+ multiple_choices: 300,
92
+ moved_permanently: 301,
93
+ found: 302,
94
+ see_other: 303,
95
+ not_modified: 304,
96
+ use_proxy: 305,
97
+ reserved: 306,
98
+ temporary_redirect: 307,
99
+ bad_request: 400,
100
+ unauthorized: 401,
101
+ payment_required: 402,
102
+ forbidden: 403,
103
+ not_found: 404,
104
+ method_not_allowed: 405,
105
+ not_acceptable: 406,
106
+ proxy_authentication_required: 407,
107
+ request_timeout: 408,
108
+ conflict: 409,
109
+ gone: 410,
110
+ length_required: 411,
111
+ precondition_failed: 412,
112
+ request_entity_too_large: 413,
113
+ request_uri_too_long: 414,
114
+ unsupported_media_type: 415,
115
+ requested_range_not_satisfiable: 416,
116
+ expectation_failed: 417,
117
+ unprocessable_entity: 422,
118
+ locked: 423,
119
+ failed_dependency: 424,
120
+ upgrade_required: 426,
121
+ internal_server_error: 500,
122
+ not_implemented: 501,
123
+ bad_gateway: 502,
124
+ service_unavailable: 503,
125
+ gateway_timeout: 504,
126
+ http_version_not_supported: 505,
127
+ variant_also_negotiates: 506,
128
+ insufficient_storage: 507,
129
+ not_extended: 510
118
130
  }
119
-
120
-
131
+
121
132
  # @private
122
133
  def validate_each(record, attribute, value)
123
134
  return if value.blank?
124
135
 
125
136
  begin
126
137
  uri = Addressable::URI.parse(value)
127
- if uri.scheme.nil? and options[:default_scheme] then
138
+
139
+ if uri.scheme.nil? and options[:default_scheme]
128
140
  uri = Addressable::URI.parse("#{options[:default_scheme]}://#{value}")
129
141
  end
130
142
  rescue Addressable::URI::InvalidURIError
131
- record.errors.add(attribute, options[:invalid_url_message] || :invalid_url) unless url_format_valid?(uri, options)
143
+ record.errors.add(attribute, options[:invalid_url_message] || :invalid_url) if uri.nil? || !url_format_valid?(uri, options)
132
144
  return
133
145
  end
134
-
135
- record.errors.add(attribute, options[:invalid_url_message] || :invalid_url) unless url_format_valid?(uri, options)
136
- record.errors.add(attribute, options[:url_not_accessible_message] || :url_not_accessible) unless response = url_accessible?(uri, options)
146
+
147
+ record.errors.add(attribute, options[:invalid_url_message] || :invalid_url) unless url_format_valid?(uri, options)
148
+ record.errors.add(attribute, options[:url_not_accessible_message] || :url_not_accessible) unless response = url_accessible?(uri, options)
137
149
  record.errors.add(attribute, options[:url_invalid_response_message] || :url_invalid_response) unless url_response_valid?(response, options)
138
150
  end
139
-
151
+
140
152
  private
141
-
153
+
142
154
  def url_format_valid?(uri, options)
143
- return false unless Array.wrap(options[:scheme] || %w( http https )).include?(uri.scheme)
144
-
155
+ return false unless Array.wrap(options[:scheme] || %w(http https)).include?(uri.scheme)
156
+
145
157
  case uri.scheme
146
158
  when 'http', 'https'
147
159
  return http_url_format_valid?(uri)
@@ -149,20 +161,20 @@ class UrlValidator < ActiveModel::EachValidator
149
161
  return true
150
162
  end
151
163
  end
152
-
164
+
153
165
  def http_url_format_valid?(uri)
154
166
  uri.host.present? and not uri.path.nil?
155
167
  end
156
-
168
+
157
169
  def url_accessible?(uri, options)
158
170
  return true unless options[:check_host] or options[:check_path]
159
-
171
+
160
172
  check_host = options[:check_host]
161
- check_host ||= %w( http https ) if options[:check_path]
162
- if (schemes = Array.wrap(check_host)) and schemes.all? { |scheme| scheme.kind_of?(String) } then
173
+ check_host ||= %w(http https) if options[:check_path]
174
+ if (schemes = Array.wrap(check_host)) and schemes.all? { |scheme| scheme.kind_of?(String) }
163
175
  return true unless schemes.include?(uri.scheme)
164
176
  end
165
-
177
+
166
178
  case uri.scheme
167
179
  when 'http', 'https'
168
180
  return http_url_accessible?(uri, options)
@@ -178,7 +190,7 @@ class UrlValidator < ActiveModel::EachValidator
178
190
  rescue
179
191
  return false
180
192
  end
181
-
193
+
182
194
  def url_response_valid?(response, options)
183
195
  return true unless response.kind_of?(HTTPI::Response) and options[:check_path]
184
196
  response_codes = options[:check_path] == true ? [400..499, 500..599] : Array.wrap(options[:check_path]).flatten
@@ -186,7 +198,7 @@ class UrlValidator < ActiveModel::EachValidator
186
198
  case code # and it's a bad response if...
187
199
  when Range
188
200
  code.include? response.code
189
- when Fixnum
201
+ when Integer
190
202
  code == response.code
191
203
  when Symbol
192
204
  CODES.include?(code) && CODES[code] == response.code
@@ -11,219 +11,223 @@ describe UrlValidator do
11
11
  @record = Record.new
12
12
  end
13
13
 
14
- context "[basic]" do
14
+ context '[basic]' do
15
15
  it "should allow nil if :allow_nil is set" do
16
- @validator = UrlValidator.new(:attributes => [ :field ], :allow_nil => true)
16
+ @validator = UrlValidator.new(attributes: %i(field), allow_nil: true)
17
17
  @validator.validate_each(@record, :field, nil)
18
18
  expect(@record.errors).to be_empty
19
19
  end
20
20
 
21
21
  it "should allow \"\" if :allow_blank is set" do
22
- @validator = UrlValidator.new(:attributes => [ :field ], :allow_blank => true)
22
+ @validator = UrlValidator.new(attributes: %i(field), allow_blank: true)
23
23
  @validator.validate_each(@record, :field, "")
24
24
  expect(@record.errors).to be_empty
25
25
  end
26
26
  end
27
-
28
- context "[format]" do
27
+
28
+ context '[format]' do
29
29
  it "should only allow HTTP URLs if :scheme is set to 'http'" do
30
- @validator = UrlValidator.new(:attributes => [ :field ], :scheme => 'http')
31
- @validator.validate_each(@record, :field, "http://www.apple.com")
30
+ @validator = UrlValidator.new(attributes: %i(field), scheme: 'http')
31
+ @validator.validate_each(@record, :field, 'http://www.apple.com')
32
32
  expect(@record.errors).to be_empty
33
33
 
34
- @validator.validate_each(@record, :field, "https://www.apple.com")
34
+ @validator.validate_each(@record, :field, 'https://www.apple.com')
35
35
  expect(@record.errors[:field].first).to include('invalid_url')
36
36
  end
37
37
 
38
- it "should only allow HTTP and HTTPS URLs if :scheme is set to %w( http https )" do
39
- @validator = UrlValidator.new(:attributes => [ :field ], :scheme => %w( http https ))
40
- @validator.validate_each(@record, :field, "http://www.apple.com")
38
+ it "should only allow HTTP and HTTPS URLs if :scheme is set to %w(http https)" do
39
+ @validator = UrlValidator.new(attributes: %i(field), scheme: %w(http https))
40
+ @validator.validate_each(@record, :field, 'http://www.apple.com')
41
41
  expect(@record.errors).to be_empty
42
- @validator.validate_each(@record, :field, "https://www.apple.com")
42
+ @validator.validate_each(@record, :field, 'https://www.apple.com')
43
43
  expect(@record.errors).to be_empty
44
44
 
45
- @validator.validate_each(@record, :field, "ftp://www.apple.com")
45
+ @validator.validate_each(@record, :field, 'ftp://www.apple.com')
46
46
  expect(@record.errors[:field].first).to include('invalid_url')
47
47
  end
48
48
 
49
49
  it "should try a default scheme if :default_scheme is set" do
50
- @validator = UrlValidator.new(:attributes => [ :field ], :scheme => 'http', :default_scheme => 'http')
51
- @validator.validate_each(@record, :field, "www.apple.com")
50
+ @validator = UrlValidator.new(attributes: %i(field), scheme: 'http', default_scheme: 'http')
51
+ @validator.validate_each(@record, :field, 'www.apple.com')
52
52
  expect(@record.errors).to be_empty
53
53
  end
54
-
55
- context "[HTTP(S)]" do
54
+
55
+ context '[HTTP(S)]' do
56
56
  it "should not allow garbage URLs that still somehow pass the ridiculously open-ended RFC" do
57
- @validator = UrlValidator.new(:attributes => [ :field ])
58
-
59
- [
60
- 'http:sdg.sdfg/',
61
- 'http/sdg.d',
62
- 'http:://dsfg.dsfg/',
63
- 'http//sdg..g',
64
- 'http://://sdfg.f',
65
- 'http://dsaf.com://sdg.com'
66
- ].each do |uri|
57
+ @validator = UrlValidator.new(attributes: %i(field))
58
+
59
+ %w(
60
+ http:sdg.sdfg/
61
+ http/sdg.d
62
+ http:://dsfg.dsfg/
63
+ http//sdg..g
64
+ http://://sdfg.f).each do |uri|
67
65
  @record.errors.clear
68
- @validator.validate_each(@record, :field, "www.apple.com")
66
+ @validator.validate_each(@record, :field, uri)
69
67
  expect(@record.errors[:field].first).to include('invalid_url')
70
68
  end
71
69
  end
70
+
71
+ it "should not allow invalid scheme formats" do
72
+ @validator = UrlValidator.new(attributes: %i(field))
73
+ @validator.validate_each(@record, :field, ' https://www.apple.com')
74
+ expect(@record.errors[:field].first).to include('invalid_url')
75
+ end
72
76
  end
73
77
  end
74
-
75
- context "[accessibility]" do
76
- context "[:check_host]" do
78
+
79
+ context '[accessibility]' do
80
+ context '[:check_host]' do
77
81
  it "should only validate if the host is accessible when :check_host is set" do
78
- @validator = UrlValidator.new(:attributes => [ :field ])
79
- @validator.validate_each(@record, :field, "http://www.invalid.tld")
82
+ @validator = UrlValidator.new(attributes: %i(field))
83
+ @validator.validate_each(@record, :field, 'http://www.invalid.tld')
80
84
  expect(@record.errors).to be_empty
81
85
 
82
- @validator = UrlValidator.new(:attributes => [ :field ], :check_host => true)
83
- @validator.validate_each(@record, :field, "http://www.invalid.tld")
86
+ @validator = UrlValidator.new(attributes: %i(field), check_host: true)
87
+ @validator.validate_each(@record, :field, 'http://www.invalid.tld')
84
88
  expect(@record.errors[:field].first).to include('url_not_accessible')
85
89
  end
86
90
 
87
91
  it "should not perform the accessibility check if :check_host is set to 'http' and the URL scheme is not HTTP" do
88
- @validator = UrlValidator.new(:attributes => [ :field ], :check_host => 'http')
89
- @validator.validate_each(@record, :field, "https://www.invalid.tld")
92
+ @validator = UrlValidator.new(attributes: %i(field), check_host: 'http')
93
+ @validator.validate_each(@record, :field, 'https://www.invalid.tld')
90
94
  expect(@record.errors).to be_empty
91
95
  end
92
96
 
93
97
  it "should only validate if the host is accessible when :check_host is set to 'http' and the URL scheme is HTTP" do
94
- @validator = UrlValidator.new(:attributes => [ :field ], :check_host => 'http')
95
- @validator.validate_each(@record, :field, "http://www.invalid.tld")
98
+ @validator = UrlValidator.new(attributes: %i(field), check_host: 'http')
99
+ @validator.validate_each(@record, :field, 'http://www.invalid.tld')
96
100
  expect(@record.errors[:field].first).to include('url_not_accessible')
97
101
  end
98
102
 
99
- it "should not perform the accessibility check if :check_host is set to %w( http https ) and the URL scheme is not HTTP(S)" do
100
- @validator = UrlValidator.new(:attributes => [ :field ], :check_host => %w( http https ), :scheme => %w( ftp http https ))
101
- @validator.validate_each(@record, :field, "ftp://www.invalid.tld")
103
+ it "should not perform the accessibility check if :check_host is set to %w(http https) and the URL scheme is not HTTP(S)" do
104
+ @validator = UrlValidator.new(attributes: %i(field), check_host: %w(http https), scheme: %w(ftp http https))
105
+ @validator.validate_each(@record, :field, 'ftp://www.invalid.tld')
102
106
  expect(@record.errors).to be_empty
103
107
  end
104
-
105
- it "should only validate if the host is accessible when :check_host is set to %w( http https ) and the URL scheme is HTTP(S)" do
106
- @validator = UrlValidator.new(:attributes => [ :field ], :check_host => %w( http https ))
107
- @validator.validate_each(@record, :field, "http://www.invalid.tld")
108
+
109
+ it "should only validate if the host is accessible when :check_host is set to %w(http https) and the URL scheme is HTTP(S)" do
110
+ @validator = UrlValidator.new(attributes: %i(field), check_host: %w(http https))
111
+ @validator.validate_each(@record, :field, 'http://www.invalid.tld')
108
112
  expect(@record.errors[:field].first).to include('url_not_accessible')
109
113
 
110
- @validator = UrlValidator.new(:attributes => [ :field ], :check_host => %w( http https ))
111
- @validator.validate_each(@record, :field, "https://www.invalid.tld")
114
+ @validator = UrlValidator.new(attributes: %i(field), check_host: %w(http https))
115
+ @validator.validate_each(@record, :field, 'https://www.invalid.tld')
112
116
  expect(@record.errors[:field].first).to include('url_not_accessible')
113
117
  end
114
118
 
115
119
  it "should only validate the host" do
116
- @validator = UrlValidator.new(:attributes => [ :field ], :check_host => true)
117
- @validator.validate_each(@record, :field, "http://www.google.com/sdgsdgf")
120
+ @validator = UrlValidator.new(attributes: %i(field), check_host: true)
121
+ @validator.validate_each(@record, :field, 'http://www.google.com/sdgsdgf')
118
122
  expect(@record.errors).to be_empty
119
123
  end
120
124
  end
121
-
122
- context "[:check_path]" do
123
- it "should not validate if the response code is equal to the Fixnum value of this option" do
124
- @validator = UrlValidator.new(:attributes => [ :field ], :check_path => 404)
125
- @validator.validate_each(@record, :field, "http://www.google.com/sdgsdgf")
125
+
126
+ context '[:check_path]' do
127
+ it "should not validate if the response code is equal to the Integer value of this option" do
128
+ @validator = UrlValidator.new(attributes: %i(field), check_path: 404)
129
+ @validator.validate_each(@record, :field, 'http://www.google.com/sdgsdgf')
126
130
  expect(@record.errors[:field].first).to include('url_invalid_response')
127
-
131
+
128
132
  @record.errors.clear
129
-
130
- @validator = UrlValidator.new(:attributes => [ :field ], :check_path => 405)
131
- @validator.validate_each(@record, :field, "http://www.google.com/sdgsdgf")
133
+
134
+ @validator = UrlValidator.new(attributes: %i(field), check_path: 405)
135
+ @validator.validate_each(@record, :field, 'http://www.google.com/sdgsdgf')
132
136
  expect(@record.errors[:field]).to be_empty
133
137
  end
134
-
138
+
135
139
  it "should not validate if the response code is equal to the Symbol value of this option" do
136
- @validator = UrlValidator.new(:attributes => [ :field ], :check_path => :not_found)
137
- @validator.validate_each(@record, :field, "http://www.google.com/sdgsdgf")
140
+ @validator = UrlValidator.new(attributes: %i(field), check_path: :not_found)
141
+ @validator.validate_each(@record, :field, 'http://www.google.com/sdgsdgf')
138
142
  expect(@record.errors[:field].first).to include('url_invalid_response')
139
-
143
+
140
144
  @record.errors.clear
141
-
142
- @validator = UrlValidator.new(:attributes => [ :field ], :check_path => :unauthorized)
143
- @validator.validate_each(@record, :field, "http://www.google.com/sdgsdgf")
145
+
146
+ @validator = UrlValidator.new(attributes: %i(field), check_path: :unauthorized)
147
+ @validator.validate_each(@record, :field, 'http://www.google.com/sdgsdgf')
144
148
  expect(@record.errors[:field]).to be_empty
145
149
  end
146
-
150
+
147
151
  it "should not validate if the response code is within the Range value of this option" do
148
- @validator = UrlValidator.new(:attributes => [ :field ], :check_path => 400..499)
149
- @validator.validate_each(@record, :field, "http://www.google.com/sdgsdgf")
152
+ @validator = UrlValidator.new(attributes: %i(field), check_path: 400..499)
153
+ @validator.validate_each(@record, :field, 'http://www.google.com/sdgsdgf')
150
154
  expect(@record.errors[:field].first).to include('url_invalid_response')
151
-
155
+
152
156
  @record.errors.clear
153
-
154
- @validator = UrlValidator.new(:attributes => [ :field ], :check_path => 500..599)
155
- @validator.validate_each(@record, :field, "http://www.google.com/sdgsdgf")
157
+
158
+ @validator = UrlValidator.new(attributes: %i(field), check_path: 500..599)
159
+ @validator.validate_each(@record, :field, 'http://www.google.com/sdgsdgf')
156
160
  expect(@record.errors[:field]).to be_empty
157
161
  end
158
-
159
- it "should not validate if the response code is equal to the Fixnum value contained in the Array value of this option" do
160
- @validator = UrlValidator.new(:attributes => [ :field ], :check_path => [ 404, 405 ])
161
- @validator.validate_each(@record, :field, "http://www.google.com/sdgsdgf")
162
+
163
+ it "should not validate if the response code is equal to the Integer value contained in the Array value of this option" do
164
+ @validator = UrlValidator.new(attributes: %i(field), check_path: [404, 405])
165
+ @validator.validate_each(@record, :field, 'http://www.google.com/sdgsdgf')
162
166
  expect(@record.errors[:field].first).to include('url_invalid_response')
163
-
167
+
164
168
  @record.errors.clear
165
-
166
- @validator = UrlValidator.new(:attributes => [ :field ], :check_path => [ 405, 406 ])
167
- @validator.validate_each(@record, :field, "http://www.google.com/sdgsdgf")
169
+
170
+ @validator = UrlValidator.new(attributes: %i(field), check_path: [405, 406])
171
+ @validator.validate_each(@record, :field, 'http://www.google.com/sdgsdgf')
168
172
  expect(@record.errors[:field]).to be_empty
169
173
  end
170
-
174
+
171
175
  it "should not validate if the response code is equal to the Symbol value contained in the Array value of this option" do
172
- @validator = UrlValidator.new(:attributes => [ :field ], :check_path => [ :not_found, :unauthorized ])
173
- @validator.validate_each(@record, :field, "http://www.google.com/sdgsdgf")
176
+ @validator = UrlValidator.new(attributes: %i(field), check_path: %i(not_found unauthorized))
177
+ @validator.validate_each(@record, :field, 'http://www.google.com/sdgsdgf')
174
178
  expect(@record.errors[:field].first).to include('url_invalid_response')
175
-
179
+
176
180
  @record.errors.clear
177
-
178
- @validator = UrlValidator.new(:attributes => [ :field ], :check_path => [ :unauthorized, :moved_permanently ])
179
- @validator.validate_each(@record, :field, "http://www.google.com/sdgsdgf")
181
+
182
+ @validator = UrlValidator.new(attributes: %i(field), check_path: %i(unauthorized moved_permanently))
183
+ @validator.validate_each(@record, :field, 'http://www.google.com/sdgsdgf')
180
184
  expect(@record.errors[:field]).to be_empty
181
185
  end
182
-
186
+
183
187
  it "should not validate if the response code is equal to the Range value contained in the Array value of this option" do
184
- @validator = UrlValidator.new(:attributes => [ :field ], :check_path => [ 400..499, 500..599 ])
185
- @validator.validate_each(@record, :field, "http://www.google.com/sdgsdgf")
188
+ @validator = UrlValidator.new(attributes: %i(field), check_path: [400..499, 500..599])
189
+ @validator.validate_each(@record, :field, 'http://www.google.com/sdgsdgf')
186
190
  expect(@record.errors[:field].first).to include('url_invalid_response')
187
-
191
+
188
192
  @record.errors.clear
189
-
190
- @validator = UrlValidator.new(:attributes => [ :field ], :check_path => [ 500..599, 300..399 ])
191
- @validator.validate_each(@record, :field, "http://www.google.com/sdgsdgf")
193
+
194
+ @validator = UrlValidator.new(attributes: %i(field), check_path: [500..599, 300..399])
195
+ @validator.validate_each(@record, :field, 'http://www.google.com/sdgsdgf')
192
196
  expect(@record.errors[:field]).to be_empty
193
197
  end
194
-
198
+
195
199
  it "should skip validation by default" do
196
- @validator = UrlValidator.new(:attributes => [ :field ], :check_path => nil)
197
- @validator.validate_each(@record, :field, "http://www.google.com/sdgsdgf")
200
+ @validator = UrlValidator.new(attributes: %i(field), check_path: nil)
201
+ @validator.validate_each(@record, :field, 'http://www.google.com/sdgsdgf')
198
202
  expect(@record.errors[:field]).to be_empty
199
203
  end
200
-
204
+
201
205
  it "should not validate 4xx and 5xx response codes if the value is true" do
202
- @validator = UrlValidator.new(:attributes => [ :field ], :check_path => true)
203
- @validator.validate_each(@record, :field, "http://www.google.com/sdgsdgf")
206
+ @validator = UrlValidator.new(attributes: %i(field), check_path: true)
207
+ @validator.validate_each(@record, :field, 'http://www.google.com/sdgsdgf')
204
208
  expect(@record.errors[:field].first).to include('url_invalid_response')
205
209
  end
206
-
210
+
207
211
  it "should skip validation for non-HTTP URLs" do
208
- @validator = UrlValidator.new(:attributes => [ :field ], :check_path => true, :scheme => %w( ftp http https ))
209
- @validator.validate_each(@record, :field, "ftp://ftp.sdgasdgohaodgh.com/sdgjsdg")
212
+ @validator = UrlValidator.new(attributes: %i(field), check_path: true, scheme: %w(ftp http https))
213
+ @validator.validate_each(@record, :field, 'ftp://ftp.sdgasdgohaodgh.com/sdgjsdg')
210
214
  expect(@record.errors[:field]).to be_empty
211
215
  end
212
216
  end
213
-
214
- context "[:httpi_adapter]" do
217
+
218
+ context '[:httpi_adapter]' do
215
219
  it "should use the specified HTTPI adapter" do
216
- @validator = UrlValidator.new(:attributes => [ :field ], :httpi_adapter => :curl, :check_host => true)
220
+ @validator = UrlValidator.new(attributes: %i(field), httpi_adapter: :curl, check_host: true)
217
221
  expect(HTTPI).to receive(:get).once.with(an_instance_of(HTTPI::Request), :curl).and_return(false)
218
- @validator.validate_each(@record, :field, "http://www.google.com/sdgsdgf")
222
+ @validator.validate_each(@record, :field, 'http://www.google.com/sdgsdgf')
219
223
  end
220
224
  end
221
-
222
- context "[:request_callback]" do
225
+
226
+ context '[:request_callback]' do
223
227
  it "should be yielded the HTTPI request" do
224
- called = false
225
- @validator = UrlValidator.new(:attributes => [ :field ], :check_host => true, :request_callback => lambda { |request| called = true; expect(request).to be_kind_of(HTTPI::Request) })
226
- @validator.validate_each(@record, :field, "http://www.google.com/sdgsdgf")
228
+ called = false
229
+ @validator = UrlValidator.new(attributes: %i(field), check_host: true, request_callback: ->(request) { called = true; expect(request).to be_kind_of(HTTPI::Request) })
230
+ @validator.validate_each(@record, :field, 'http://www.google.com/sdgsdgf')
227
231
  expect(called).to eql(true)
228
232
  end
229
233
  end
@@ -1,22 +1,22 @@
1
- # Generated by jeweler
1
+ # Generated by juwelier
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
3
+ # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: url_validation 1.1.0 ruby lib
5
+ # stub: url_validation 1.2.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
- s.name = "url_validation"
9
- s.version = "1.1.0"
8
+ s.name = "url_validation".freeze
9
+ s.version = "1.2.0"
10
10
 
11
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
- s.require_paths = ["lib"]
13
- s.authors = ["Tim Morgan"]
14
- s.date = "2014-11-08"
15
- s.description = "A simple, localizable EachValidator for URL fields in ActiveRecord 3.0."
16
- s.email = "git@timothymorgan.info"
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib".freeze]
13
+ s.authors = ["Tim Morgan".freeze]
14
+ s.date = "2017-05-31"
15
+ s.description = "A simple, localizable EachValidator for URL fields in ActiveRecord 3.0.".freeze
16
+ s.email = "git@timothymorgan.info".freeze
17
17
  s.extra_rdoc_files = [
18
18
  "LICENSE",
19
- "README.textile"
19
+ "README.md"
20
20
  ]
21
21
  s.files = [
22
22
  ".document",
@@ -26,7 +26,7 @@ Gem::Specification.new do |s|
26
26
  "Gemfile",
27
27
  "Gemfile.lock",
28
28
  "LICENSE",
29
- "README.textile",
29
+ "README.md",
30
30
  "Rakefile",
31
31
  "VERSION",
32
32
  "lib/url_validation.rb",
@@ -34,42 +34,42 @@ Gem::Specification.new do |s|
34
34
  "spec/url_validator_spec.rb",
35
35
  "url_validation.gemspec"
36
36
  ]
37
- s.homepage = "http://github.com/riscfuture/url_validation"
38
- s.required_ruby_version = Gem::Requirement.new(">= 1.8.7")
39
- s.rubygems_version = "2.4.2"
40
- s.summary = "Simple URL validation in Rails 3"
37
+ s.homepage = "http://github.com/riscfuture/url_validation".freeze
38
+ s.required_ruby_version = Gem::Requirement.new(">= 2.0.0".freeze)
39
+ s.rubygems_version = "2.6.12".freeze
40
+ s.summary = "Simple URL validation in Rails 3+".freeze
41
41
 
42
42
  if s.respond_to? :specification_version then
43
43
  s.specification_version = 4
44
44
 
45
45
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
46
- s.add_runtime_dependency(%q<addressable>, [">= 0"])
47
- s.add_runtime_dependency(%q<activesupport>, [">= 0"])
48
- s.add_runtime_dependency(%q<activerecord>, [">= 0"])
49
- s.add_runtime_dependency(%q<httpi>, [">= 0"])
50
- s.add_development_dependency(%q<jeweler>, [">= 0"])
51
- s.add_development_dependency(%q<yard>, [">= 0"])
52
- s.add_development_dependency(%q<RedCloth>, [">= 0"])
53
- s.add_development_dependency(%q<rspec>, [">= 0"])
46
+ s.add_runtime_dependency(%q<addressable>.freeze, [">= 0"])
47
+ s.add_runtime_dependency(%q<activesupport>.freeze, [">= 0"])
48
+ s.add_runtime_dependency(%q<activerecord>.freeze, [">= 0"])
49
+ s.add_runtime_dependency(%q<httpi>.freeze, [">= 0"])
50
+ s.add_development_dependency(%q<juwelier>.freeze, [">= 0"])
51
+ s.add_development_dependency(%q<yard>.freeze, [">= 0"])
52
+ s.add_development_dependency(%q<redcarpet>.freeze, [">= 0"])
53
+ s.add_development_dependency(%q<rspec>.freeze, [">= 0"])
54
54
  else
55
- s.add_dependency(%q<addressable>, [">= 0"])
56
- s.add_dependency(%q<activesupport>, [">= 0"])
57
- s.add_dependency(%q<activerecord>, [">= 0"])
58
- s.add_dependency(%q<httpi>, [">= 0"])
59
- s.add_dependency(%q<jeweler>, [">= 0"])
60
- s.add_dependency(%q<yard>, [">= 0"])
61
- s.add_dependency(%q<RedCloth>, [">= 0"])
62
- s.add_dependency(%q<rspec>, [">= 0"])
55
+ s.add_dependency(%q<addressable>.freeze, [">= 0"])
56
+ s.add_dependency(%q<activesupport>.freeze, [">= 0"])
57
+ s.add_dependency(%q<activerecord>.freeze, [">= 0"])
58
+ s.add_dependency(%q<httpi>.freeze, [">= 0"])
59
+ s.add_dependency(%q<juwelier>.freeze, [">= 0"])
60
+ s.add_dependency(%q<yard>.freeze, [">= 0"])
61
+ s.add_dependency(%q<redcarpet>.freeze, [">= 0"])
62
+ s.add_dependency(%q<rspec>.freeze, [">= 0"])
63
63
  end
64
64
  else
65
- s.add_dependency(%q<addressable>, [">= 0"])
66
- s.add_dependency(%q<activesupport>, [">= 0"])
67
- s.add_dependency(%q<activerecord>, [">= 0"])
68
- s.add_dependency(%q<httpi>, [">= 0"])
69
- s.add_dependency(%q<jeweler>, [">= 0"])
70
- s.add_dependency(%q<yard>, [">= 0"])
71
- s.add_dependency(%q<RedCloth>, [">= 0"])
72
- s.add_dependency(%q<rspec>, [">= 0"])
65
+ s.add_dependency(%q<addressable>.freeze, [">= 0"])
66
+ s.add_dependency(%q<activesupport>.freeze, [">= 0"])
67
+ s.add_dependency(%q<activerecord>.freeze, [">= 0"])
68
+ s.add_dependency(%q<httpi>.freeze, [">= 0"])
69
+ s.add_dependency(%q<juwelier>.freeze, [">= 0"])
70
+ s.add_dependency(%q<yard>.freeze, [">= 0"])
71
+ s.add_dependency(%q<redcarpet>.freeze, [">= 0"])
72
+ s.add_dependency(%q<rspec>.freeze, [">= 0"])
73
73
  end
74
74
  end
75
75
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: url_validation
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Morgan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-08 00:00:00.000000000 Z
11
+ date: 2017-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -67,7 +67,7 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: jeweler
70
+ name: juwelier
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -95,7 +95,7 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: RedCloth
98
+ name: redcarpet
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - ">="
@@ -128,7 +128,7 @@ executables: []
128
128
  extensions: []
129
129
  extra_rdoc_files:
130
130
  - LICENSE
131
- - README.textile
131
+ - README.md
132
132
  files:
133
133
  - ".document"
134
134
  - ".rspec"
@@ -137,7 +137,7 @@ files:
137
137
  - Gemfile
138
138
  - Gemfile.lock
139
139
  - LICENSE
140
- - README.textile
140
+ - README.md
141
141
  - Rakefile
142
142
  - VERSION
143
143
  - lib/url_validation.rb
@@ -155,7 +155,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
155
155
  requirements:
156
156
  - - ">="
157
157
  - !ruby/object:Gem::Version
158
- version: 1.8.7
158
+ version: 2.0.0
159
159
  required_rubygems_version: !ruby/object:Gem::Requirement
160
160
  requirements:
161
161
  - - ">="
@@ -163,8 +163,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
163
  version: '0'
164
164
  requirements: []
165
165
  rubyforge_project:
166
- rubygems_version: 2.4.2
166
+ rubygems_version: 2.6.12
167
167
  signing_key:
168
168
  specification_version: 4
169
- summary: Simple URL validation in Rails 3
169
+ summary: Simple URL validation in Rails 3+
170
170
  test_files: []
@@ -1,36 +0,0 @@
1
- h1. url_validation -- Simple URL validator for Rails 3
2
-
3
- | *Author* | Tim Morgan |
4
- | *Version* | 1.0 (May 9, 2011) |
5
- | *License* | Released under the MIT license. |
6
-
7
- h2. About
8
-
9
- This gem adds a very simple URL format validator to be used with ActiveRecord
10
- models in Rails 3.0. It supports localized error messages. It can validate many
11
- different kinds of URLs, including HTTP and HTTPS. It supports advanced
12
- validation features like sending @HEAD@ requests to URLS to verify that they are
13
- valid endpoints.
14
-
15
- h2. Installation
16
-
17
- Add the gem to your project's @Gemfile@:
18
-
19
- <pre><code>
20
- gem 'url_validation'
21
- </code></pre>
22
-
23
- h2. Usage
24
-
25
- This gem is an @EachValidator@, and thus is used with the @validates@ method:
26
-
27
- <pre><code>
28
- class User < ActiveRecord::Base
29
- validates :terms_of_service_link,
30
- :presence => true,
31
- :url => true
32
- end
33
- </code></pre>
34
-
35
- There are other options to fine-tune your validation; see the {UrlValidator}
36
- class for more, and for a list of error message localization keys.