validates_url_format_of 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/.gemtest ADDED
File without changes
data/.gitignore CHANGED
@@ -1,5 +1,41 @@
1
- *.sw?
1
+ !.gitignore
2
+ *.gem
3
+ *.rbc
4
+ *.sw[a-p]
5
+ *.tmproj
6
+ *.tmproject
7
+ *.un~
8
+ *~
2
9
  .DS_Store
10
+ .Spotlight-V100
11
+ .Trashes
12
+ ._*
13
+ .bundle
14
+ .config
15
+ .directory
16
+ .elc
17
+ .redcar
18
+ .yardoc
19
+ /.emacs.desktop
20
+ /.emacs.desktop.lock
21
+ Desktop.ini
22
+ Gemfile.lock
23
+ Icon?
24
+ InstalledFiles
25
+ Session.vim
26
+ Thumbs.db
27
+ \#*\#
28
+ _yardoc
29
+ auto-save-list
3
30
  coverage
4
- rdoc
31
+ doc/
32
+ lib/bundler/man
5
33
  pkg
34
+ pkg/*
35
+ rdoc
36
+ spec/reports
37
+ test/tmp
38
+ test/version_tmp
39
+ tmp
40
+ tmtags
41
+ tramp
data/.travis.yml ADDED
@@ -0,0 +1,9 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.1
4
+ - 1.9.2
5
+ - 1.9.3
6
+ - jruby
7
+ - rbx
8
+ - rbx-2.0
9
+ - ree
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'http://rubygems.org'
2
+
3
+ platforms :jruby do
4
+ gem 'jruby-openssl', '~> 0.7'
5
+ end
6
+
7
+ gemspec
data/LICENSE.md ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2008 Erik-Michels-Ober, Henrik Nyh, Josh Nichols, Nicholas Silva.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,22 @@
1
+ # validates\_url\_format\_of
2
+ Rails plugin that provides a `validates_url_format_of` method to `ActiveRecord` models. URLs are validated by regexp.
3
+
4
+ ## Usage
5
+ After installing the plugin, it's used like
6
+
7
+ class User < ActiveRecord::Base
8
+ validates_url_format_of :url,
9
+ :allow_nil => true,
10
+ :message => 'is completely unacceptable'
11
+ end
12
+
13
+ Takes the same arguments as [`validates_format_of`](http://ar.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html#M000087) except for the `:with` regexp.
14
+
15
+ The default `:message` is different depending on whether the attribute name contains the word "URL". So you will get "Homepage URL does not appear to be valid" but "Homepage does not appear to be a valid URL" without having to customize the `:message`.
16
+
17
+ Please note that the regexp used to validate URLs is not perfect, but hopefully good enough. See the test suite. Patches are very welcome.
18
+
19
+ ## Limitations and design choices
20
+ Does not handle IPv6.
21
+
22
+ By design, the plugin does not allow e.g. "http://localhost" or "http://my.localurl", which are valid URLs but not suitable in most web apps. It also requires a "http://" or "https://" prefix, so just "example.com" is not valid. Fix that in the setter.
data/Rakefile CHANGED
@@ -1,22 +1,7 @@
1
- require 'rubygems'
2
- require 'rake'
1
+ #!/usr/bin/env rake
3
2
 
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "validates_url_format_of"
8
- gem.summary = %Q{ActiveRecord URL Validation}
9
- gem.description = %Q{Rails plugin that provides a validates_url_format_of method to ActiveRecord models. URLs are validated by regexp.}
10
- gem.email = "conickal@gmail.com"
11
- gem.homepage = "http://github.com/conickal/validates_url_format_of"
12
- gem.authors = ["Henrik Nyh", "Josh Nichols", "Nicholas Silva"]
13
- gem.add_dependency('activerecord', '~> 2.3.4')
14
- gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
15
- end
16
- Jeweler::GemcutterTasks.new
17
- rescue LoadError
18
- puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
19
- end
3
+ require 'bundler'
4
+ Bundler::GemHelper.install_tasks
20
5
 
21
6
  require 'rake/testtask'
22
7
  Rake::TestTask.new(:test) do |test|
@@ -25,34 +10,10 @@ Rake::TestTask.new(:test) do |test|
25
10
  test.verbose = true
26
11
  end
27
12
 
28
- begin
29
- require 'rcov/rcovtask'
30
- Rcov::RcovTask.new do |test|
31
- test.libs << 'test'
32
- test.pattern = 'test/**/*_test.rb'
33
- test.verbose = true
34
- end
35
- rescue LoadError
36
- task :rcov do
37
- abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
38
- end
39
- end
40
-
41
-
42
13
  task :default => :test
43
14
 
44
- require 'rake/rdoctask'
45
- Rake::RDocTask.new do |rdoc|
46
- if File.exist?('VERSION.yml')
47
- config = YAML.load(File.read('VERSION.yml'))
48
- version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
49
- else
50
- version = ""
51
- end
52
-
53
- rdoc.rdoc_dir = 'rdoc'
54
- rdoc.title = "validates_url_format_of #{version}"
55
- rdoc.rdoc_files.include('README*')
56
- rdoc.rdoc_files.include('lib/**/*.rb')
15
+ require 'yard'
16
+ YARD::Rake::YardocTask.new do |task|
17
+ task.files = ['LICENSE.md', 'lib/**/*.rb']
18
+ task.options = ['--markup', 'markdown']
57
19
  end
58
-
@@ -1,3 +1,5 @@
1
+ require 'active_record'
2
+
1
3
  module ValidatesUrlFormatOf
2
4
  IPv4_PART = /\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]/ # 0-255
3
5
  REGEXP = %r{
@@ -13,11 +15,11 @@ module ValidatesUrlFormatOf
13
15
 
14
16
  DEFAULT_MESSAGE = 'does not appear to be a valid URL'
15
17
  DEFAULT_MESSAGE_URL = 'does not appear to be valid'
16
-
18
+
17
19
  def validates_url_format_of(*attr_names)
18
20
  options = { :allow_nil => false,
19
21
  :allow_blank => false,
20
- :with => REGEXP }
22
+ :with => REGEXP }
21
23
  options = options.merge(attr_names.pop) if attr_names.last.is_a?(Hash)
22
24
 
23
25
  attr_names.each do |attr_name|
data/test/helper.rb ADDED
@@ -0,0 +1,20 @@
1
+ $:.unshift File.expand_path('..', __FILE__)
2
+ $:.unshift File.expand_path('../../lib', __FILE__)
3
+ require 'validates_url_format_of'
4
+ require 'active_record'
5
+ require 'model'
6
+ require 'minitest/unit'
7
+
8
+ MiniTest::Unit.autorun
9
+
10
+ unless ActiveRecord::Base.connected?
11
+ ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ':memory:')
12
+ ActiveRecord::Migration.verbose = false
13
+ ActiveRecord::Schema.define(:version => 0) do
14
+ create_table :models, :force => true do |t|
15
+ t.string :homepage
16
+ t.string :my_UrL_hooray
17
+ t.string :custom_url
18
+ end
19
+ end
20
+ end
data/test/model.rb ADDED
@@ -0,0 +1,5 @@
1
+ class Model < ActiveRecord::Base
2
+ validates_url_format_of :homepage
3
+ validates_url_format_of :my_UrL_hooray
4
+ validates_url_format_of :custom_url, :message => 'custom message'
5
+ end
@@ -1,34 +1,11 @@
1
- # encoding: utf-8
1
+ require File.expand_path('../helper', __FILE__)
2
2
 
3
- require 'rubygems'
4
- require 'test/unit'
5
- require 'active_record'
6
- require "#{File.dirname(__FILE__)}/../init"
3
+ class ValidatesUrlFormatOfTest < MiniTest::Unit::TestCase
7
4
 
8
- ActiveRecord::Base.establish_connection(
9
- :adapter => 'sqlite3',
10
- :database => ':memory:')
11
-
12
- ActiveRecord::Schema.define(:version => 0) do
13
- create_table :models, :force => true do |t|
14
- t.string :homepage
15
- t.string :my_UrL_hooray
16
- t.string :custom_url
17
- end
18
- end
19
-
20
- class Model < ActiveRecord::Base
21
- validates_url_format_of :homepage
22
- validates_url_format_of :my_UrL_hooray
23
- validates_url_format_of :custom_url, :message => 'custom message'
24
- end
25
-
26
- class ValidatesUrlFormatOfTest < Test::Unit::TestCase
27
-
28
5
  def setup
29
6
  @model = Model.new
30
7
  end
31
-
8
+
32
9
  def test_should_allow_valid_urls
33
10
  [
34
11
  'http://example.com',
@@ -43,15 +20,14 @@ class ValidatesUrlFormatOfTest < Test::Unit::TestCase
43
20
  'http://user:pass@example.com',
44
21
  'http://user:@example.com',
45
22
  'http://example.com/~user',
46
- 'http://example.xy', # Not a real TLD, but we're fine with anything of 2-6 chars
23
+ 'http://example.xy', # Not a real TLD, but we're fine with anything of 2-6 chars
47
24
  'http://example.museum',
48
25
  'http://1.0.255.249',
49
26
  'http://1.2.3.4:80',
50
27
  'HttP://example.com',
51
28
  'https://example.com',
52
- 'http://räksmörgås.nu', # IDN
53
- 'http://xn--rksmrgs-5wao1o.nu', # Punycode
54
- 'http://example.com.', # Explicit TLD root period
29
+ 'http://xn--rksmrgs-5wao1o.nu', # Punycode
30
+ 'http://example.com.', # Explicit TLD root period
55
31
  'http://example.com./foo'
56
32
  ].each do |url|
57
33
  @model.homepage = url
@@ -59,7 +35,7 @@ class ValidatesUrlFormatOfTest < Test::Unit::TestCase
59
35
  assert !@model.errors.on(:homepage), "#{url.inspect} should have been accepted"
60
36
  end
61
37
  end
62
-
38
+
63
39
  def test_should_reject_invalid_urls
64
40
  [
65
41
  nil, 1, "", " ", "url",
@@ -69,7 +45,7 @@ class ValidatesUrlFormatOfTest < Test::Unit::TestCase
69
45
  'http://256.0.0.1',
70
46
  'http://u:u:u@example.com',
71
47
  'http://r?ksmorgas.com',
72
-
48
+
73
49
  # These can all be valid local URLs, but should not be considered valid
74
50
  # for public consumption.
75
51
  "http://example",
@@ -81,20 +57,19 @@ class ValidatesUrlFormatOfTest < Test::Unit::TestCase
81
57
  assert @model.errors.on(:homepage), "#{url.inspect} should have been rejected"
82
58
  end
83
59
  end
84
-
60
+
85
61
  def test_different_defaults_based_on_attribute_name
86
62
  @model.homepage = 'x'
87
63
  @model.my_UrL_hooray = 'x'
88
64
  @model.save
89
- assert_not_equal ValidatesUrlFormatOf::DEFAULT_MESSAGE, ValidatesUrlFormatOf::DEFAULT_MESSAGE_URL
90
65
  assert_equal ValidatesUrlFormatOf::DEFAULT_MESSAGE, @model.errors.on(:homepage)
91
66
  assert_equal ValidatesUrlFormatOf::DEFAULT_MESSAGE_URL, @model.errors.on(:my_UrL_hooray)
92
67
  end
93
-
68
+
94
69
  def test_can_override_defaults
95
70
  @model.custom_url = 'x'
96
71
  @model.save
97
72
  assert_equal 'custom message', @model.errors.on(:custom_url)
98
73
  end
99
-
74
+
100
75
  end
@@ -1,54 +1,21 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
- # -*- encoding: utf-8 -*-
1
+ # encoding: utf-8
5
2
 
6
- Gem::Specification.new do |s|
7
- s.name = %q{validates_url_format_of}
8
- s.version = "0.1.2"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Henrik Nyh", "Josh Nichols", "Nicholas Silva"]
12
- s.date = %q{2011-02-15}
13
- s.description = %q{Rails plugin that provides a validates_url_format_of method to ActiveRecord models. URLs are validated by regexp.}
14
- s.email = %q{conickal@gmail.com}
15
- s.extra_rdoc_files = [
16
- "README.markdown"
17
- ]
18
- s.files = [
19
- ".gitignore",
20
- "README.markdown",
21
- "Rakefile",
22
- "VERSION",
23
- "init.rb",
24
- "lib/validates_url_format_of.rb",
25
- "shoulda_macros/validates_url_format_of_macros.rb",
26
- "test/validates_url_format_of_test.rb",
27
- "validates_url_format_of.gemspec"
28
- ]
29
- s.homepage = %q{http://github.com/conickal/validates_url_format_of}
30
- s.rdoc_options = ["--charset=UTF-8"]
31
- s.require_paths = ["lib"]
32
- s.rubygems_version = %q{1.3.7}
33
- s.summary = %q{ActiveRecord URL Validation}
34
- s.test_files = [
35
- "test/validates_url_format_of_test.rb"
36
- ]
37
-
38
- if s.respond_to? :specification_version then
39
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
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>, ["~> 2.3.4"])
44
- s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
45
- else
46
- s.add_dependency(%q<activerecord>, ["~> 2.3.4"])
47
- s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
48
- end
49
- else
50
- s.add_dependency(%q<activerecord>, ["~> 2.3.4"])
51
- s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
52
- end
3
+ Gem::Specification.new do |gem|
4
+ gem.add_dependency 'activerecord', '~> 2.3.4'
5
+ gem.add_development_dependency 'minitest', '~> 2.5'
6
+ gem.add_development_dependency 'rake', '~> 0.9'
7
+ gem.add_development_dependency 'rdiscount', '~> 1.6'
8
+ gem.add_development_dependency 'sqlite3', '~> 1.3'
9
+ gem.add_development_dependency 'yard', '~> 0.7'
10
+ gem.authors = ["Erik-Michels-Ober", "Henrik Nyh", "Josh Nichols", "Nicholas Silva"]
11
+ gem.description = %q{Rails plugin that provides a validates_url_format_of method to ActiveRecord models. URLs are validated by regexp.}
12
+ gem.email = 'conickal@gmail.com'
13
+ gem.files = `git ls-files`.split("\n")
14
+ gem.homepage = 'http://github.com/conickal/validates_url_format_of'
15
+ gem.name = 'validates_url_format_of'
16
+ gem.require_paths = ['lib']
17
+ gem.required_rubygems_version = Gem::Requirement.new('>= 1.3.6')
18
+ gem.summary = %q{ActiveRecord URL Validation}
19
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
+ gem.version = '0.1.3'
53
21
  end
54
-
metadata CHANGED
@@ -1,106 +1,129 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: validates_url_format_of
3
- version: !ruby/object:Gem::Version
4
- hash: 31
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 1
9
- - 2
10
- version: 0.1.2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.3
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
8
+ - Erik-Michels-Ober
13
9
  - Henrik Nyh
14
10
  - Josh Nichols
15
11
  - Nicholas Silva
16
12
  autorequire:
17
13
  bindir: bin
18
14
  cert_chain: []
19
-
20
- date: 2011-02-15 00:00:00 -05:00
21
- default_executable:
22
- dependencies:
23
- - !ruby/object:Gem::Dependency
15
+ date: 2011-08-27 00:00:00.000000000 Z
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
24
18
  name: activerecord
25
- prerelease: false
26
- requirement: &id001 !ruby/object:Gem::Requirement
19
+ requirement: &70206836681580 !ruby/object:Gem::Requirement
27
20
  none: false
28
- requirements:
21
+ requirements:
29
22
  - - ~>
30
- - !ruby/object:Gem::Version
31
- hash: 11
32
- segments:
33
- - 2
34
- - 3
35
- - 4
23
+ - !ruby/object:Gem::Version
36
24
  version: 2.3.4
37
25
  type: :runtime
38
- version_requirements: *id001
39
- - !ruby/object:Gem::Dependency
40
- name: thoughtbot-shoulda
41
26
  prerelease: false
42
- requirement: &id002 !ruby/object:Gem::Requirement
27
+ version_requirements: *70206836681580
28
+ - !ruby/object:Gem::Dependency
29
+ name: minitest
30
+ requirement: &70206836680760 !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ~>
34
+ - !ruby/object:Gem::Version
35
+ version: '2.5'
36
+ type: :development
37
+ prerelease: false
38
+ version_requirements: *70206836680760
39
+ - !ruby/object:Gem::Dependency
40
+ name: rake
41
+ requirement: &70206836679720 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: '0.9'
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: *70206836679720
50
+ - !ruby/object:Gem::Dependency
51
+ name: rdiscount
52
+ requirement: &70206836675100 !ruby/object:Gem::Requirement
43
53
  none: false
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- hash: 3
48
- segments:
49
- - 0
50
- version: "0"
54
+ requirements:
55
+ - - ~>
56
+ - !ruby/object:Gem::Version
57
+ version: '1.6'
58
+ type: :development
59
+ prerelease: false
60
+ version_requirements: *70206836675100
61
+ - !ruby/object:Gem::Dependency
62
+ name: sqlite3
63
+ requirement: &70206836674480 !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '1.3'
51
69
  type: :development
52
- version_requirements: *id002
53
- description: Rails plugin that provides a validates_url_format_of method to ActiveRecord models. URLs are validated by regexp.
70
+ prerelease: false
71
+ version_requirements: *70206836674480
72
+ - !ruby/object:Gem::Dependency
73
+ name: yard
74
+ requirement: &70206836673880 !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ~>
78
+ - !ruby/object:Gem::Version
79
+ version: '0.7'
80
+ type: :development
81
+ prerelease: false
82
+ version_requirements: *70206836673880
83
+ description: Rails plugin that provides a validates_url_format_of method to ActiveRecord
84
+ models. URLs are validated by regexp.
54
85
  email: conickal@gmail.com
55
86
  executables: []
56
-
57
87
  extensions: []
58
-
59
- extra_rdoc_files:
60
- - README.markdown
61
- files:
88
+ extra_rdoc_files: []
89
+ files:
90
+ - .gemtest
62
91
  - .gitignore
63
- - README.markdown
92
+ - .travis.yml
93
+ - Gemfile
94
+ - LICENSE.md
95
+ - README.md
64
96
  - Rakefile
65
- - VERSION
66
- - init.rb
67
97
  - lib/validates_url_format_of.rb
68
- - shoulda_macros/validates_url_format_of_macros.rb
98
+ - test/helper.rb
99
+ - test/model.rb
69
100
  - test/validates_url_format_of_test.rb
70
101
  - validates_url_format_of.gemspec
71
- has_rdoc: true
72
102
  homepage: http://github.com/conickal/validates_url_format_of
73
103
  licenses: []
74
-
75
104
  post_install_message:
76
- rdoc_options:
77
- - --charset=UTF-8
78
- require_paths:
105
+ rdoc_options: []
106
+ require_paths:
79
107
  - lib
80
- required_ruby_version: !ruby/object:Gem::Requirement
108
+ required_ruby_version: !ruby/object:Gem::Requirement
81
109
  none: false
82
- requirements:
83
- - - ">="
84
- - !ruby/object:Gem::Version
85
- hash: 3
86
- segments:
87
- - 0
88
- version: "0"
89
- required_rubygems_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ! '>='
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
115
  none: false
91
- requirements:
92
- - - ">="
93
- - !ruby/object:Gem::Version
94
- hash: 3
95
- segments:
96
- - 0
97
- version: "0"
116
+ requirements:
117
+ - - ! '>='
118
+ - !ruby/object:Gem::Version
119
+ version: 1.3.6
98
120
  requirements: []
99
-
100
121
  rubyforge_project:
101
- rubygems_version: 1.3.7
122
+ rubygems_version: 1.8.10
102
123
  signing_key:
103
124
  specification_version: 3
104
125
  summary: ActiveRecord URL Validation
105
- test_files:
126
+ test_files:
127
+ - test/helper.rb
128
+ - test/model.rb
106
129
  - test/validates_url_format_of_test.rb
data/README.markdown DELETED
@@ -1,49 +0,0 @@
1
- # validates\_url\_format\_of
2
-
3
- Rails plugin that provides a `validates_url_format_of` method to `ActiveRecord` models. URLs are validated by regexp.
4
-
5
- ## Usage
6
-
7
- After installing the plugin, it's used like
8
-
9
- class User < ActiveRecord::Base
10
- validates_url_format_of :url,
11
- :allow_nil => true,
12
- :message => 'is completely unacceptable'
13
- end
14
-
15
- Takes the same arguments as [`validates_format_of`](http://api.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html#M001052) except for the `:with` regexp.
16
-
17
- The default `:message` is different depending on whether the attribute name contains the word "URL". So you will get "Homepage URL does not appear to be valid" but "Homepage does not appear to be a valid URL" without having to customize the `:message`.
18
-
19
- Please note that the regexp used to validate URLs is not perfect, but hopefully good enough. See the test suite. Patches are very welcome.
20
-
21
- ## Limitations and design choices
22
-
23
- Does not handle IPv6.
24
-
25
- By design, the plugin does not allow e.g. "http://localhost" or "http://my.localurl", which are valid URLs but not suitable in most web apps. It also requires a "http://" or "https://" prefix, so just "example.com" is not valid. Fix that in the setter.
26
-
27
- ## Credits and license
28
-
29
- By [Henrik Nyh](http://henrik.nyh.se/) under the MIT license:
30
-
31
- > Copyright (c) 2008 Henrik Nyh
32
- >
33
- > Permission is hereby granted, free of charge, to any person obtaining a copy
34
- > of this software and associated documentation files (the "Software"), to deal
35
- > in the Software without restriction, including without limitation the rights
36
- > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
37
- > copies of the Software, and to permit persons to whom the Software is
38
- > furnished to do so, subject to the following conditions:
39
- >
40
- > The above copyright notice and this permission notice shall be included in
41
- > all copies or substantial portions of the Software.
42
- >
43
- > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
44
- > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
45
- > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
46
- > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
47
- > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
48
- > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
49
- > THE SOFTWARE.
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.1.2
data/init.rb DELETED
@@ -1 +0,0 @@
1
- require 'validates_url_format_of'
@@ -1,36 +0,0 @@
1
- # encoding: utf-8
2
- class Test::Unit::TestCase
3
- def self.should_validate_url_format_of(attribute, options = {})
4
- should_allow_values_for attribute,
5
- 'http://example.com',
6
- 'http://example.com/',
7
- 'http://www.example.com/',
8
- 'http://sub.domain.example.com/',
9
- 'http://bbc.co.uk',
10
- 'http://example.com?foo',
11
- 'http://example.com?url=http://example.com',
12
- 'http://example.com:8000',
13
- 'http://www.sub.example.com/page.html?foo=bar&baz=%23#anchor',
14
- 'http://user:pass@example.com',
15
- 'http://user:@example.com',
16
- 'http://example.com/~user',
17
- 'http://example.xy', # Not a real TLD, but we're fine with anything of 2-6 chars
18
- 'http://example.museum',
19
- 'http://1.0.255.249',
20
- 'http://1.2.3.4:80',
21
- 'HttP://example.com',
22
- 'https://example.com',
23
- 'http://räksmörgås.nu', # IDN
24
- 'http://xn--rksmrgs-5wao1o.nu', # Punycode
25
- 'http://example.com.', # Explicit TLD root period
26
- 'http://example.com./foo'
27
-
28
- should_not_allow_values_for attribute,
29
- "www.example.com",
30
- "http://ex ample.com",
31
- "http://example.com/foo bar",
32
- 'http://256.0.0.1',
33
- 'http://u:u:u@example.com',
34
- 'http://r?ksmorgas.com'
35
- end
36
- end