validates_url_format_of 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b3da9effc4336d14d3fcb83603fd2ce960053c94
4
+ data.tar.gz: 347857fd8cceeb25541252bc6b1912acf4165056
5
+ SHA512:
6
+ metadata.gz: ef0d57fa3ea78d62750171924434bcc176990c95dea3d4cbbe8ec8ddbdad2c50f07dd8a06e39ab2d324d47615877b228c0fb814d3013664a9a0b77b6cb5b9869
7
+ data.tar.gz: 435547d77d56fdc8899d78795566de08c3366d2d4aadb6586513372e46f261952b4d081efdecea6be3e2edcd48539a1c93975c0379c91a807b323b5d8345fe7b
data/Gemfile CHANGED
@@ -5,15 +5,25 @@ gem 'rake'
5
5
  gem 'yard'
6
6
 
7
7
  platforms :jruby do
8
- gem 'jruby-openssl'
9
8
  gem 'activerecord-jdbcsqlite3-adapter'
10
9
  gem 'jdbc-sqlite3'
10
+ gem 'jruby-openssl'
11
11
  end
12
12
 
13
13
  group :test do
14
+ gem 'backports'
14
15
  gem 'minitest'
16
+ gem 'rubocop', '>= 0.16', :platforms => [:ruby_19, :ruby_20, :ruby_21]
15
17
  gem 'simplecov', :require => false
16
18
  gem 'sqlite3', :platforms => :ruby
19
+ gem 'yardstick'
20
+ end
21
+
22
+ platforms :rbx do
23
+ gem 'racc'
24
+ gem 'rubinius-coverage', '~> 2.0'
25
+ gem 'rubysl', '~> 2.0'
26
+ gem 'rubysl-json', '~> 2.0'
17
27
  end
18
28
 
19
29
  gemspec
data/LICENSE.md CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2008 Erik-Michels-Ober, Henrik Nyh, Josh Nichols, Nicholas Silva.
1
+ Copyright (c) 2008 Erik Michels-Ober, Henrik Nyh, Josh Nichols, Nicholas Silva.
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to deal
data/Rakefile CHANGED
@@ -10,10 +10,29 @@ Rake::TestTask.new(:test) do |test|
10
10
  test.verbose = true
11
11
  end
12
12
 
13
- task :default => :test
13
+ begin
14
+ require 'rubocop/rake_task'
15
+ Rubocop::RakeTask.new
16
+ rescue LoadError
17
+ task :rubocop do
18
+ $stderr.puts 'Rubocop is disabled'
19
+ end
20
+ end
14
21
 
15
22
  require 'yard'
16
23
  YARD::Rake::YardocTask.new do |task|
17
- task.files = ['LICENSE.md', 'lib/**/*.rb']
18
- task.options = ['--markup', 'markdown']
24
+ task.files = %w[LICENSE.md lib/**/*.rb]
25
+ task.options = %w[--markup markdown]
26
+ end
27
+
28
+ require 'yardstick/rake/measurement'
29
+ Yardstick::Rake::Measurement.new do |measurement|
30
+ measurement.output = 'measurement/report.txt'
19
31
  end
32
+
33
+ require 'yardstick/rake/verify'
34
+ Yardstick::Rake::Verify.new do |verify|
35
+ verify.threshold = 50.0
36
+ end
37
+
38
+ task :default => [:test, :rubocop, :verify_measurements]
@@ -1,13 +1,13 @@
1
1
  require 'active_record'
2
2
 
3
3
  module ValidatesUrlFormatOf
4
- IPv4_PART = /\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]/ # 0-255
4
+ IPV4_PART = /\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]/ # 0-255
5
5
  REGEXP = %r{
6
6
  \A
7
7
  https?:// # http:// or https://
8
8
  ([^\s:@]+:[^\s:@]*@)? # optional username:pw@
9
- ( (xn--)?[a-z0-9]+([-.][a-z0-9]+)*\.[a-z]{2,6}\.? | # domain (including Punycode/IDN)...
10
- #{IPv4_PART}(\.#{IPv4_PART}){3} ) # or IPv4
9
+ ( (xn--)?(\-|[a-z0-9])+([-.][a-z0-9]+)*\.[a-z]{2,6}\.? | # domain (including Punycode/IDN)...
10
+ #{IPV4_PART}(\.#{IPV4_PART}){3} ) # or IPv4
11
11
  (:\d{1,5})? # optional port
12
12
  ([/?]\S*)? # optional /whatever or ?whatever
13
13
  \Z
@@ -17,14 +17,16 @@ module ValidatesUrlFormatOf
17
17
  DEFAULT_MESSAGE_URL = 'does not appear to be valid'
18
18
 
19
19
  def validates_url_format_of(*attr_names)
20
- options = { :allow_nil => false,
21
- :allow_blank => false,
22
- :with => REGEXP }
20
+ options = {
21
+ :allow_nil => false,
22
+ :allow_blank => false,
23
+ :with => REGEXP,
24
+ }
23
25
  options = options.merge(attr_names.pop) if attr_names.last.is_a?(Hash)
24
26
 
25
27
  attr_names.each do |attr_name|
26
28
  message = attr_name.to_s.match(/(_|\b)URL(_|\b)/i) ? DEFAULT_MESSAGE_URL : DEFAULT_MESSAGE
27
- validates_format_of(attr_name, { :message => message }.merge(options))
29
+ validates_format_of(attr_name, {:message => message}.merge(options))
28
30
  end
29
31
  end
30
32
  end
data/test/helper.rb CHANGED
@@ -1,13 +1,14 @@
1
- $:.unshift File.expand_path('..', __FILE__)
2
- $:.unshift File.expand_path('../../lib', __FILE__)
1
+ $LOAD_PATH.unshift File.expand_path('..', __FILE__)
2
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
3
3
  require 'simplecov'
4
- SimpleCov.start
4
+ SimpleCov.start do
5
+ add_filter '/spec/'
6
+ minimum_coverage(100)
7
+ end
5
8
  require 'validates_url_format_of'
6
9
  require 'active_record'
7
10
  require 'model'
8
- require 'minitest/unit'
9
-
10
- MiniTest::Unit.autorun
11
+ require 'minitest/autorun'
11
12
 
12
13
  unless ActiveRecord::Base.connected?
13
14
  ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ':memory:')
@@ -1,12 +1,11 @@
1
1
  require File.expand_path('../helper', __FILE__)
2
2
 
3
3
  class ValidatesUrlFormatOfTest < MiniTest::Unit::TestCase
4
-
5
4
  def setup
6
5
  @model = Model.new
7
6
  end
8
7
 
9
- def test_should_allow_valid_urls
8
+ def test_should_allow_valid_urls # rubocop:disable MethodLength
10
9
  [
11
10
  'http://example.com',
12
11
  'http://example.com/',
@@ -28,7 +27,8 @@ class ValidatesUrlFormatOfTest < MiniTest::Unit::TestCase
28
27
  'https://example.com',
29
28
  'http://xn--rksmrgs-5wao1o.nu', # Punycode
30
29
  'http://example.com.', # Explicit TLD root period
31
- 'http://example.com./foo'
30
+ 'http://example.com./foo',
31
+ 'http://innsofaurora--com.rztrkr.com/accommodations/?rzreturn=1&rzsource=nc'
32
32
  ].each do |url|
33
33
  @model.homepage = url
34
34
  @model.save
@@ -36,20 +36,20 @@ class ValidatesUrlFormatOfTest < MiniTest::Unit::TestCase
36
36
  end
37
37
  end
38
38
 
39
- def test_should_reject_invalid_urls
39
+ def test_should_reject_invalid_urls # rubocop:disable MethodLength
40
40
  [
41
- nil, 1, "", " ", "url",
42
- "www.example.com",
43
- "http://ex ample.com",
44
- "http://example.com/foo bar",
41
+ nil, 1, '', ' ', 'url',
42
+ 'www.example.com',
43
+ 'http://ex ample.com',
44
+ 'http://example.com/foo bar',
45
45
  'http://256.0.0.1',
46
46
  'http://u:u:u@example.com',
47
47
  'http://r?ksmorgas.com',
48
48
 
49
49
  # These can all be valid local URLs, but should not be considered valid
50
50
  # for public consumption.
51
- "http://example",
52
- "http://example.c",
51
+ 'http://example',
52
+ 'http://example.c',
53
53
  'http://example.toolongtld'
54
54
  ].each do |url|
55
55
  @model.homepage = url
@@ -71,5 +71,4 @@ class ValidatesUrlFormatOfTest < MiniTest::Unit::TestCase
71
71
  @model.save
72
72
  assert_equal 'custom message', @model.errors[:custom_url].first
73
73
  end
74
-
75
74
  end
@@ -1,18 +1,18 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.add_dependency 'activerecord', ['>= 3.1', '< 5']
3
3
  spec.add_development_dependency 'bundler', '~> 1.0'
4
- spec.authors = ["Erik-Michels-Ober", "Henrik Nyh", "Josh Nichols", "Nicholas Silva"]
4
+ spec.authors = ['Erik Michels-Ober', 'Henrik Nyh', 'Josh Nichols', 'Nicholas Silva']
5
5
  spec.description = %q{Rails plugin that provides a validates_url_format_of method to ActiveRecord models. URLs are validated by regexp.}
6
- spec.email = ['conickal@gmail.com']
7
- spec.files = %w(LICENSE.md README.md Gemfile Rakefile validates_url_format_of.gemspec)
8
- spec.files += Dir.glob("lib/**/*.rb")
9
- spec.files += Dir.glob("test/**/*")
6
+ spec.email = %w[conickal@gmail.com]
7
+ spec.files = %w[LICENSE.md README.md Gemfile Rakefile validates_url_format_of.gemspec]
8
+ spec.files += Dir.glob('lib/**/*.rb')
9
+ spec.files += Dir.glob('test/**/*')
10
10
  spec.homepage = 'http://github.com/conickal/validates_url_format_of'
11
- spec.licenses = ['MIT']
11
+ spec.licenses = %w[MIT]
12
12
  spec.name = 'validates_url_format_of'
13
- spec.require_paths = ['lib']
13
+ spec.require_paths = %w[lib]
14
14
  spec.required_rubygems_version = '>= 1.3.5'
15
15
  spec.summary = %q{ActiveRecord URL Validation}
16
- spec.test_files = Dir.glob("test/**/*")
17
- spec.version = '0.4.0'
16
+ spec.test_files = Dir.glob('test/**/*')
17
+ spec.version = '0.4.1'
18
18
  end
metadata CHANGED
@@ -1,55 +1,50 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: validates_url_format_of
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
5
- prerelease:
4
+ version: 0.4.1
6
5
  platform: ruby
7
6
  authors:
8
- - Erik-Michels-Ober
7
+ - Erik Michels-Ober
9
8
  - Henrik Nyh
10
9
  - Josh Nichols
11
10
  - Nicholas Silva
12
11
  autorequire:
13
12
  bindir: bin
14
13
  cert_chain: []
15
- date: 2013-11-20 00:00:00.000000000 Z
14
+ date: 2014-01-02 00:00:00.000000000 Z
16
15
  dependencies:
17
16
  - !ruby/object:Gem::Dependency
18
17
  name: activerecord
19
18
  requirement: !ruby/object:Gem::Requirement
20
- none: false
21
19
  requirements:
22
- - - ! '>='
20
+ - - ">="
23
21
  - !ruby/object:Gem::Version
24
22
  version: '3.1'
25
- - - <
23
+ - - "<"
26
24
  - !ruby/object:Gem::Version
27
25
  version: '5'
28
26
  type: :runtime
29
27
  prerelease: false
30
28
  version_requirements: !ruby/object:Gem::Requirement
31
- none: false
32
29
  requirements:
33
- - - ! '>='
30
+ - - ">="
34
31
  - !ruby/object:Gem::Version
35
32
  version: '3.1'
36
- - - <
33
+ - - "<"
37
34
  - !ruby/object:Gem::Version
38
35
  version: '5'
39
36
  - !ruby/object:Gem::Dependency
40
37
  name: bundler
41
38
  requirement: !ruby/object:Gem::Requirement
42
- none: false
43
39
  requirements:
44
- - - ~>
40
+ - - "~>"
45
41
  - !ruby/object:Gem::Version
46
42
  version: '1.0'
47
43
  type: :development
48
44
  prerelease: false
49
45
  version_requirements: !ruby/object:Gem::Requirement
50
- none: false
51
46
  requirements:
52
- - - ~>
47
+ - - "~>"
53
48
  - !ruby/object:Gem::Version
54
49
  version: '1.0'
55
50
  description: Rails plugin that provides a validates_url_format_of method to ActiveRecord
@@ -60,39 +55,38 @@ executables: []
60
55
  extensions: []
61
56
  extra_rdoc_files: []
62
57
  files:
58
+ - Gemfile
63
59
  - LICENSE.md
64
60
  - README.md
65
- - Gemfile
66
61
  - Rakefile
67
- - validates_url_format_of.gemspec
68
62
  - lib/validates_url_format_of.rb
69
63
  - test/helper.rb
70
64
  - test/model.rb
71
65
  - test/validates_url_format_of_test.rb
66
+ - validates_url_format_of.gemspec
72
67
  homepage: http://github.com/conickal/validates_url_format_of
73
68
  licenses:
74
69
  - MIT
70
+ metadata: {}
75
71
  post_install_message:
76
72
  rdoc_options: []
77
73
  require_paths:
78
74
  - lib
79
75
  required_ruby_version: !ruby/object:Gem::Requirement
80
- none: false
81
76
  requirements:
82
- - - ! '>='
77
+ - - ">="
83
78
  - !ruby/object:Gem::Version
84
79
  version: '0'
85
80
  required_rubygems_version: !ruby/object:Gem::Requirement
86
- none: false
87
81
  requirements:
88
- - - ! '>='
82
+ - - ">="
89
83
  - !ruby/object:Gem::Version
90
84
  version: 1.3.5
91
85
  requirements: []
92
86
  rubyforge_project:
93
- rubygems_version: 1.8.23
87
+ rubygems_version: 2.2.0
94
88
  signing_key:
95
- specification_version: 3
89
+ specification_version: 4
96
90
  summary: ActiveRecord URL Validation
97
91
  test_files:
98
92
  - test/helper.rb