any-validate 0.0.3 → 0.0.4

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
  SHA1:
3
- metadata.gz: 759a0550748387285552831db72cd4b0146cb01d
4
- data.tar.gz: 250a24676d4ea0639c2b4d391a08bd78f8ddfdd5
3
+ metadata.gz: 88e0dfc95111326865c3bfcaec5c59c2a3b273aa
4
+ data.tar.gz: e6dd0534bcf0c897bc03847e72a392ba705d2ac2
5
5
  SHA512:
6
- metadata.gz: 389ed64c2df2e3873aed906a83e0ece807c3622aea582766bd0da01595b751ac88d38524f8e57ef7df6fd5d3e3e287f75e6050b620b6054f507551cdc0d1f4f0
7
- data.tar.gz: e6f09fc573136c2078a2b75046e86db2a50bb913603f3862a62d00b9cf53a5aed152ceb15464830c66083cebe1a11538a98f9b1e2e5b2a3e7e35b008f8669906
6
+ metadata.gz: ce566e065e9be2f0d4fc03f9b526b0147b54e13a5eabe87384a32688edc991a05aa425882284d93914486697af95e96f778fb74c25fe4b439262710f93b061a9
7
+ data.tar.gz: e69469312f9e2fbdedf198a1d5f10c69a5690f5272b9c59c8a42a1027897a96ac0e2fdcb694a79fc00fe610fe86c5a95f109bae7794af79edd05087fe8f5d58a
data/README.md CHANGED
@@ -31,12 +31,15 @@ class Hoge
31
31
 
32
32
  valid_macaddress? mac: 'B4:B5:2F:63:0F:7C' #=> true
33
33
  valid_macaddress? mac: 'B4:B5:2F:63:0F:7G' #=> false
34
+
35
+ valid_uuid? uuid: 'FEAAF64D-6132-44DD-8779-C2E297B622B5' #=> true
36
+ valid_uuid? uuid: 'FEAAF64D-6132-44DD-8779-C2E297B622B51' #=> false
34
37
  end
35
38
  ```
36
39
 
37
40
  ## Contributing
38
41
 
39
- 1. Fork it ( https://github.com/[my-github-username]/any-validate/fork )
42
+ 1. Fork it ( https://github.com/youyo/any-validate/fork )
40
43
  2. Create your feature branch (`git checkout -b my-new-feature`)
41
44
  3. Commit your changes (`git commit -am 'Add some feature'`)
42
45
  4. Push to the branch (`git push origin my-new-feature`)
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["1003ni2@gmail.com"]
11
11
  spec.summary = %q{Validate the various things.}
12
12
  spec.description = %q{Validate the various things.}
13
- spec.homepage = ""
13
+ spec.homepage = "https://github.com/youyo/any-validate"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0")
@@ -2,7 +2,9 @@ require "any/validate/version"
2
2
  require "any/validate/ipaddress"
3
3
  require "any/validate/macaddress"
4
4
  require "any/validate/uuid"
5
+ require "any/validate/mailaddress"
5
6
 
6
7
  include Any::Validate::Ipaddress
7
8
  include Any::Validate::Macaddress
8
9
  include Any::Validate::Uuid
10
+ include Any::Validate::Mailaddress
@@ -0,0 +1,33 @@
1
+ module Any
2
+ module Validate
3
+ module Mailaddress
4
+
5
+ def valid_mailaddress? mail: nil
6
+ # http://tmtms.hatenablog.com/entry/2014/09/09/mailaddress-regexp
7
+ return true if mail =~
8
+ /\A
9
+ # 全体で256文字以下
10
+ (?=.{,256}\z)
11
+ # local-partは64文字以下でdomainは255文字以下
12
+ (?=.{,64}@.{,255}\z)
13
+ # local-part
14
+ (
15
+ # dot-atom
16
+ (?<atom>[0-9a-z!\#$%&'*+\-\/=?^_`{|}~]+)
17
+ (\.\g<atom>)*
18
+ |
19
+ # quoted-string
20
+ \"([\x09\x20\x21\x23-\x5b\x5d-\x7e]|\\[\x09\x20-\x7e])*\"
21
+ )@
22
+ # domain
23
+ (?<sub_domain>[0-9a-z]([0-9a-z-]{,61}[0-9a-z])?)
24
+ (\.\g<sub_domain>)*
25
+ \z/ix
26
+ return false
27
+ rescue
28
+ return false
29
+ end
30
+
31
+ end
32
+ end
33
+ end
@@ -1,5 +1,5 @@
1
1
  module Any
2
2
  module Validate
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
@@ -0,0 +1,41 @@
1
+ describe Any::Validate::Mailaddress do
2
+
3
+ describe '#valid_mailaddress?' do
4
+ context 'when mailaddress is test@example.com' do
5
+ it 'return true' do
6
+ expect( valid_mailaddress? mail: 'test@example.com' ).to be(true)
7
+ end
8
+ end
9
+ context 'when mailaddress is .test@example.com' do
10
+ it 'return false' do
11
+ expect( valid_mailaddress? mail: '.test@example.com' ).to be(false)
12
+ end
13
+ end
14
+ context 'when mailaddress is 1234567890123456789012345678901234567890123456789012345678901234@example.com' do
15
+ it 'return true' do
16
+ expect( valid_mailaddress? mail: '1234567890123456789012345678901234567890123456789012345678901234@example.com' ).to be(true)
17
+ end
18
+ end
19
+ context 'when mailaddress is 12345678901234567890123456789012345678901234567890123456789012345@example.com' do
20
+ it 'return false' do
21
+ expect( valid_mailaddress? mail: '12345678901234567890123456789012345678901234567890123456789012345@example.com' ).to be(false)
22
+ end
23
+ end
24
+ context 'when mailaddress is a@123456789012345678901234567890123456789012345678901234567890123.123456789012345678901234567890123456789012345678901234567890123.123456789012345678901234567890123456789012345678901234567890123.1234567890123456789012345678901234567890123456789012examle.com' do
25
+ it 'return true' do
26
+ expect( valid_mailaddress? mail: 'a@123456789012345678901234567890123456789012345678901234567890123.123456789012345678901234567890123456789012345678901234567890123.123456789012345678901234567890123456789012345678901234567890123.1234567890123456789012345678901234567890123456789012examle.com' ).to be(true)
27
+ end
28
+ end
29
+ context 'when mailaddress is a@123456789012345678901234567890123456789012345678901234567890123.123456789012345678901234567890123456789012345678901234567890123.123456789012345678901234567890123456789012345678901234567890123.12345678901234567890123456789012345678901234567890123examle.com' do
30
+ it 'return false' do
31
+ expect( valid_mailaddress? mail: 'a@123456789012345678901234567890123456789012345678901234567890123.123456789012345678901234567890123456789012345678901234567890123.123456789012345678901234567890123456789012345678901234567890123.12345678901234567890123456789012345678901234567890123examle.com' ).to be(false)
32
+ end
33
+ end
34
+ context 'when mailaddress is ab@123456789012345678901234567890123456789012345678901234567890123.123456789012345678901234567890123456789012345678901234567890123.123456789012345678901234567890123456789012345678901234567890123.1234567890123456789012345678901234567890123456789012examle.com' do
35
+ it 'return false' do
36
+ expect( valid_mailaddress? mail: 'ab@123456789012345678901234567890123456789012345678901234567890123.123456789012345678901234567890123456789012345678901234567890123.123456789012345678901234567890123456789012345678901234567890123.1234567890123456789012345678901234567890123456789012examle.com' ).to be(false)
37
+ end
38
+ end
39
+ end
40
+
41
+ end
@@ -1,8 +1,8 @@
1
1
  describe Any::Validate do
2
2
  describe 'VERSION' do
3
3
 
4
- it 'should be 0.0.3' do
5
- expect( Any::Validate::VERSION ).to eql('0.0.3')
4
+ it 'should be 0.0.4' do
5
+ expect( Any::Validate::VERSION ).to eql('0.0.4')
6
6
  end
7
7
  it 'should be a String' do
8
8
  expect( Any::Validate::VERSION ).to be_a(String)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: any-validate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - youyo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-21 00:00:00.000000000 Z
11
+ date: 2015-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -68,14 +68,16 @@ files:
68
68
  - lib/any/validate.rb
69
69
  - lib/any/validate/ipaddress.rb
70
70
  - lib/any/validate/macaddress.rb
71
+ - lib/any/validate/mailaddress.rb
71
72
  - lib/any/validate/uuid.rb
72
73
  - lib/any/validate/version.rb
73
74
  - spec/any/validate/ipaddress_spec.rb
74
75
  - spec/any/validate/macaddress_spec.rb
76
+ - spec/any/validate/mailaddress_spec.rb
75
77
  - spec/any/validate/uuid_spec.rb
76
78
  - spec/any/validate/version_spec.rb
77
79
  - spec/spec_helper.rb
78
- homepage: ''
80
+ homepage: https://github.com/youyo/any-validate
79
81
  licenses:
80
82
  - MIT
81
83
  metadata: {}
@@ -102,6 +104,7 @@ summary: Validate the various things.
102
104
  test_files:
103
105
  - spec/any/validate/ipaddress_spec.rb
104
106
  - spec/any/validate/macaddress_spec.rb
107
+ - spec/any/validate/mailaddress_spec.rb
105
108
  - spec/any/validate/uuid_spec.rb
106
109
  - spec/any/validate/version_spec.rb
107
110
  - spec/spec_helper.rb