validate_url 1.0.0 → 1.0.2

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: 96f44ddca984d787f96ec16966b40dc93e3a6e99
4
- data.tar.gz: 4c769029b3a14ce585a894fb6be20441faacfe73
3
+ metadata.gz: 3a9370dd3549d270bff452c951a9de3ae4d0288b
4
+ data.tar.gz: 342adc16d0211b47d822d590f0395aa53ea74b8a
5
5
  SHA512:
6
- metadata.gz: 161b331bf596ea903da5a4a57f4b1c8478bcf8e3a5532e97830a63476221465766153b6aa87eae8e7c3d105fd2aee1b01dc298f00e97a8c762b6d0a2e6972aa4
7
- data.tar.gz: 4e4b02215f6245cdb3bb0aff2a979afddd3c0d31c91b3c407320a16137e2f69e49e6aa6385b22d8d8528539b707bd291ebb5b98aaba240811a338cc64c81d0a1
6
+ metadata.gz: ce037a673542945b111562d32cb1633dfcc955fa5a256ad16823b2094da17d8715fa28b9a4bf252ceb0809f52d88e797c3534a7f0f88d5a0c30e3024b8da3538
7
+ data.tar.gz: 702b42045a2f850bcc2f5595299177ce97171caa05ca0a4732d78f7ec5b9c81c83b84c700e0a2605c870ff175bbf60232871e04b3b3c7db2ec6735089fd7cebc
data/README.md CHANGED
@@ -26,6 +26,9 @@ class Pony < ActiveRecord::Base
26
26
 
27
27
  # with allow_blank
28
28
  validates :homepage, :url => {:allow_blank => true}
29
+
30
+ # without local hostnames
31
+ validates :homepage, :url => {:no_local => true}
29
32
  end
30
33
  ```
31
34
 
@@ -0,0 +1,4 @@
1
+ de:
2
+ errors:
3
+ messages:
4
+ url: ist keine gültige URL
@@ -0,0 +1,4 @@
1
+ ja:
2
+ errors:
3
+ messages:
4
+ url: は不正なURLです。
@@ -0,0 +1,4 @@
1
+ pt-BR:
2
+ errors:
3
+ messages:
4
+ url: não é uma URL válida
@@ -0,0 +1,4 @@
1
+ tr:
2
+ errors:
3
+ messages:
4
+ url: Geçerli bir URL değil
@@ -2,6 +2,8 @@ require 'addressable/uri'
2
2
  require 'active_model'
3
3
  require 'active_support/i18n'
4
4
  I18n.load_path << File.dirname(__FILE__) + '/locale/en.yml'
5
+ I18n.load_path << File.dirname(__FILE__) + '/locale/tr.yml'
6
+ I18n.load_path << File.dirname(__FILE__) + '/locale/ja.yml'
5
7
 
6
8
  module ActiveModel
7
9
  module Validations
@@ -10,6 +12,8 @@ module ActiveModel
10
12
  def initialize(options)
11
13
  options.reverse_merge!(:schemes => %w(http https))
12
14
  options.reverse_merge!(:message => :url)
15
+ options.reverse_merge!(:no_local => false)
16
+
13
17
  super(options)
14
18
  end
15
19
 
@@ -17,7 +21,7 @@ module ActiveModel
17
21
  schemes = [*options.fetch(:schemes)].map(&:to_s)
18
22
  begin
19
23
  uri = Addressable::URI.parse(value)
20
- unless uri && uri.host && schemes.include?(uri.scheme)
24
+ unless uri && uri.host && schemes.include?(uri.scheme) && (!options.fetch(:no_local) || uri.host.include?('.'))
21
25
  record.errors.add(attribute, options.fetch(:message), :value => value)
22
26
  end
23
27
  rescue Addressable::URI::InvalidURIError
metadata CHANGED
@@ -1,15 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: validate_url
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tanel Suurhans
8
8
  - Tarmo Lehtpuu
9
+ - Vladimir Krylov
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2014-11-13 00:00:00.000000000 Z
13
+ date: 2015-07-21 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: activemodel
@@ -69,8 +70,9 @@ dependencies:
69
70
  version: 1.1.2
70
71
  description: Library for validating urls in Rails.
71
72
  email:
72
- - tanel.suurhans@perfectline.ee
73
- - tarmo.lehtpuu@perfectline.ee
73
+ - tanel.suurhans@perfectline.co
74
+ - tarmo.lehtpuu@perfectline.co
75
+ - vladimir.krylov@perfectline.co
74
76
  executables: []
75
77
  extensions: []
76
78
  extra_rdoc_files:
@@ -81,8 +83,12 @@ files:
81
83
  - README.md
82
84
  - init.rb
83
85
  - install.rb
86
+ - lib/locale/de.yml
84
87
  - lib/locale/en.yml
85
88
  - lib/locale/it.yml
89
+ - lib/locale/ja.yml
90
+ - lib/locale/pt-BR.yml
91
+ - lib/locale/tr.yml
86
92
  - lib/validate_url.rb
87
93
  homepage: http://github.com/perfectline/validates_url/tree/master
88
94
  licenses: []
@@ -103,9 +109,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
109
  version: '0'
104
110
  requirements: []
105
111
  rubyforge_project:
106
- rubygems_version: 2.2.2
112
+ rubygems_version: 2.4.5
107
113
  signing_key:
108
114
  specification_version: 4
109
115
  summary: Library for validating urls in Rails.
110
116
  test_files: []
111
- has_rdoc: