ruby_regex 0.1.1 → 0.1.2

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: 8f3ca30f2c864850d5d12fe51a73f4374dd269de
4
+ data.tar.gz: 726537820b07ed6a0794db8d81e2595225b339ce
5
+ SHA512:
6
+ metadata.gz: 213eded349042ba25850aef71e27961d49155b8f01c7bf1d26c58da3f9500924a9170538706075feaabdc0ee9c867194363afab704b2845faa3ae364069bb7f8
7
+ data.tar.gz: eaa31ce49e1ae410412d45c55035ed8adc50e525f772fb3f8a797e4eb3e6eac8b309dcf8c7be84641f145861d72f61145af5c5ab11fd2340b2aa69ecd2b3af2c
data/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # RubyRegex
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/ruby_regex.svg)](http://badge.fury.io/rb/ruby_regex)
4
+ [![Build Status](https://travis-ci.org/eparreno/ruby_regex.svg)](https://travis-ci.org/eparreno/ruby_regex)
5
+ [![Code Climate](https://codeclimate.com/github/eparreno/ruby_regex/badges/gpa.svg)](https://codeclimate.com/github/eparreno/ruby_regex)
6
+
7
+ RubyRegex is a nice collection of regular expressions in Ruby
8
+
9
+ ## Regular expressions
10
+
11
+ ```
12
+ RubyRegex::Url
13
+ RubyRegex::Domain
14
+ RubyRegex::Email
15
+ RubyRegex::Username
16
+ RubyRegex::USSocialSecurity
17
+ RubyRegex::GeneralPostalCode
18
+ RubyRegex::ZIPCode
19
+ RubyRegex::CreditCard
20
+ RubyRegex::MasterCard
21
+ RubyRegex::Visa
22
+ RubyRegex::TwitterUsername
23
+ RubyRegex::DeliciousUsername
24
+ RubyRegex::SlideshareUsername
25
+ RubyRegex::GithubUsername
26
+ RubyRegex::UUID
27
+ RubyRegex::DBDate
28
+ RubyRegex::DBDatetime
29
+ RubyRegex::SpanishBankAccountNumber
30
+ RubyRegex::Dni
31
+ ```
32
+
33
+ ## Rails
34
+
35
+ Add to your Gemfile
36
+
37
+ gem 'ruby_regex'
38
+
39
+ In the models
40
+
41
+ validates_format_of :email, :with => RubyRegex::Email
42
+
43
+ ## Contribute
44
+
45
+ Of course, contributions will be apreciated.
46
+
47
+ If you want to contribute send me a pull request with new regular expressions (and their tests) or send me an email with your desired regular expression to emili@eparreno.com
48
+
49
+ ---
50
+
51
+ RubyRegex is released under the MIT-License and is Copyright (c)2010 Emili Parreño.
data/lib/ruby_regex.rb CHANGED
@@ -52,7 +52,7 @@ module RubyRegex
52
52
 
53
53
  # UUID
54
54
  # Validates a UUID as defined: http://en.wikipedia.org/wiki/Universally_unique_identifier
55
- UUID = /\A([0-9a-fA-F]{32}|[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})\z/
55
+ UUID = /\A(\h{32}|\h{8}-\h{4}-\h{4}-\h{4}-\h{12})\z/
56
56
 
57
57
  # Date DB format YYYY-MM-DD
58
58
  # I know it will validate 2001-02-31 but is I think we are focusing in formats more than in parsing
@@ -63,4 +63,12 @@ module RubyRegex
63
63
 
64
64
  # SpanishBankAccountNumber
65
65
  SpanishBankAccountNumber = /\A\d{4}[ -]?\d{4}[ -]?\d{2}[ -]?\d{10}\z/
66
+
67
+ # IBAN
68
+ # Source: http://snipplr.com/view/15322/iban-regex-all-ibans/
69
+ # You have to remove spaces or any separator character from the original field before use this regex
70
+ IBAN = /[a-zA-Z]{2}[0-9]{2}[a-zA-Z0-9]{4}[0-9]{7}([a-zA-Z0-9]?){0,16}/
71
+
72
+ # MacAddress
73
+ MacAddress = /\A([0-9A-F]{2}[:-]){5}([0-9A-F]{2})\z/i
66
74
  end
@@ -156,6 +156,24 @@ class RubyRegexTest < Test::Unit::TestCase
156
156
  check_invalid_regex RubyRegex::SpanishBankAccountNumber, load_fixture('spanish_bank_account_numbers')['invalid']
157
157
  end
158
158
 
159
+ # IBAN
160
+ def test_valid_iban
161
+ check_valid_regex RubyRegex::IBAN, load_fixture('ibans')['valid']
162
+ end
163
+
164
+ def test_invalid_iban
165
+ check_invalid_regex RubyRegex::IBAN, load_fixture('ibans')['invalid']
166
+ end
167
+
168
+ # MacAddress
169
+ def test_valid_mac_addresses
170
+ check_valid_regex RubyRegex::MacAddress, load_fixture('mac_addresses')['valid']
171
+ end
172
+
173
+ def test_invalid_mac_addresses
174
+ check_invalid_regex RubyRegex::SpanishBankAccountNumber, load_fixture('mac_addresses')['invalid']
175
+ end
176
+
159
177
  private
160
178
  def load_fixture( name )
161
179
  YAML.load( File.read( File.join( File.dirname(__FILE__), 'fixtures', "#{name}.yml" ) ) )
metadata CHANGED
@@ -1,27 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_regex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
5
- prerelease:
4
+ version: 0.1.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Emili Parreno
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-11-13 00:00:00.000000000 Z
11
+ date: 2017-02-08 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rake
16
- requirement: &70094318182900 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
- type: :runtime
20
+ type: :development
23
21
  prerelease: false
24
- version_requirements: *70094318182900
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: test-unit
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
25
41
  description: Ruby regular expressions library
26
42
  email: emili@eparreno.com
27
43
  executables: []
@@ -29,38 +45,36 @@ extensions: []
29
45
  extra_rdoc_files: []
30
46
  files:
31
47
  - CHANGELOG
32
- - README.rdoc
33
48
  - LICENSE
49
+ - README.md
34
50
  - lib/ruby_regex.rb
35
- - test/ruby_regex_test.rb
36
51
  - test/fixtures/emails.yml
52
+ - test/ruby_regex_test.rb
37
53
  homepage: http://github.com/eparreno/ruby_regex
38
54
  licenses: []
55
+ metadata: {}
39
56
  post_install_message:
40
57
  rdoc_options:
41
- - --main
58
+ - "--main"
42
59
  - README
43
60
  require_paths:
44
61
  - lib
45
62
  required_ruby_version: !ruby/object:Gem::Requirement
46
- none: false
47
63
  requirements:
48
- - - ! '>='
64
+ - - ">="
49
65
  - !ruby/object:Gem::Version
50
66
  version: '0'
51
67
  required_rubygems_version: !ruby/object:Gem::Requirement
52
- none: false
53
68
  requirements:
54
- - - ! '>='
69
+ - - ">="
55
70
  - !ruby/object:Gem::Version
56
71
  version: '0'
57
72
  requirements: []
58
73
  rubyforge_project:
59
- rubygems_version: 1.8.11
74
+ rubygems_version: 2.6.8
60
75
  signing_key:
61
- specification_version: 3
76
+ specification_version: 4
62
77
  summary: none
63
78
  test_files:
64
79
  - test/ruby_regex_test.rb
65
80
  - test/fixtures/emails.yml
66
- has_rdoc: true
data/README.rdoc DELETED
@@ -1,52 +0,0 @@
1
- = RubyRegex
2
-
3
- RubyRegex is a nice collection of regular expressions in Ruby
4
-
5
- == Regular expressions
6
-
7
- RubyRegex::Url
8
- RubyRegex::Domain
9
- RubyRegex::Email
10
- RubyRegex::Username
11
- RubyRegex::USSocialSecurity
12
- RubyRegex::GeneralPostalCode
13
- RubyRegex::ZIPCode
14
- RubyRegex::CreditCard
15
- RubyRegex::MasterCard
16
- RubyRegex::Visa
17
- RubyRegex::TwitterUsername
18
- RubyRegex::DeliciousUsername
19
- RubyRegex::SlidesahreUsername
20
- RubyRegex::GithubUsername
21
- RubyRegex::UUID
22
- RubyRegex::DBDate
23
- RubyRegex::DBDatetime
24
- RubyRegex::SpanishBankAccountNumber
25
-
26
- == Rails
27
-
28
- Add to your Gemfile
29
-
30
- gem 'ruby_regex'
31
-
32
- In the models
33
-
34
- validates_format_of :email, :with => RubyRegex::Email
35
-
36
- == Contribute
37
-
38
- Of course, contributions will be apreciated.
39
-
40
- If you want to contribute send me a pull request with new regular expressions (and their tests) or send me an email with your desired regular expression to emili@eparreno.com
41
-
42
- == Contributors
43
-
44
- - Lleïr Borràs
45
- - Jaime Iniesta
46
- - Fernando Guillen
47
- - Christopher Klapp
48
- - Guillermo Alvarez
49
-
50
- ---
51
-
52
- RubyRegex is released under the MIT-License and is Copyright (c)2010 Emili Parreño.