iz 0.1.0 → 0.2.0

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: d056d00e90c38e12c3b38407f049ca845dfefb73
4
- data.tar.gz: a67ceb3e8a9575fe824c05a4fb822a4d0bab5a6b
3
+ metadata.gz: 681d8ce4ad5124840e3702912a51286af3f6717e
4
+ data.tar.gz: a69484149c8392352655e28b720cc2b746c9a5df
5
5
  SHA512:
6
- metadata.gz: 54e09786c5ff94f2daf457d74ed33d181a74f483208aeb0a2142bf563cdd11ac370f6f36637da0303452bb0a34ea4f9b6d800a6414e4834a816f7fe5d3052d2e
7
- data.tar.gz: 16e8af40bd067c06e1f05f207cbcf1e0a692d5364d988fec18b4c727fc1ebc215dba9e359083066f044f3b60b6c17a8f8bc6f8bffeecda9949c9f1504545727b
6
+ metadata.gz: fb560dd9003cbcf7b518f1d97110a878705411774c5819692d6805b2b1eeee961768b67d698523b0d4e1496707d8404757cc60e2300f7d74dc274d33152e22f7
7
+ data.tar.gz: 8db13e2cf15b80acf1edf0e3f1e71bf904a543ac1f0100a7f9d0b60f03e6a4b3c9c1ad362070504337fb4c04af02d1741773539e2717eff10e6a6d5098c38922
data/README.md CHANGED
@@ -33,6 +33,9 @@ Iz.credit_card?('4242424242424242') # => true
33
33
  Iz.mac?('ababababab') # => true
34
34
  Iz.mac?(-1) # => false
35
35
 
36
+ Iz.email?('johnotander@gmail.com') # => true
37
+ Iz.email?(nil) # => false
38
+
36
39
  Iz.binary?('010101') # => true
37
40
  Iz.binary?('foo') # => false
38
41
 
data/Rakefile CHANGED
@@ -8,4 +8,4 @@ Rake::TestTask.new do |t|
8
8
  t.verbose = true
9
9
  end
10
10
 
11
- task :default => :test
11
+ task default: :test
data/lib/iz/email.rb ADDED
@@ -0,0 +1,19 @@
1
+ module Iz
2
+ class Email
3
+ REGEX = /.+@.+/
4
+
5
+ attr_accessor :value
6
+
7
+ def initialize(email)
8
+ self.value = email
9
+ end
10
+
11
+ def valid?
12
+ !!Iz::Email.is_email?(value)
13
+ end
14
+
15
+ def self.is_email?(value)
16
+ value.to_s =~ REGEX
17
+ end
18
+ end
19
+ end
data/lib/iz/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Iz
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/iz.rb CHANGED
@@ -5,6 +5,7 @@ require 'iz/phone_number'
5
5
  require 'iz/credit_card'
6
6
  require 'iz/hexadecimal'
7
7
  require 'iz/binary'
8
+ require 'iz/email'
8
9
  require 'iz/mac'
9
10
  require 'iz/url'
10
11
 
@@ -17,6 +18,10 @@ module Iz
17
18
  !!Iz::Hexadecimal.is_hexadecimal?(hexadecimal)
18
19
  end
19
20
 
21
+ def self.email?(email)
22
+ !!Iz::Email.is_email?(email)
23
+ end
24
+
20
25
  def self.binary?(binary)
21
26
  !!Iz::Binary.is_binary?(binary)
22
27
  end
@@ -0,0 +1,25 @@
1
+ require 'test/unit'
2
+ require 'iz'
3
+
4
+ class TestHexadecimal < Test::Unit::TestCase
5
+
6
+ def valid_emails
7
+ ['johnotander@gmail.com', 'foo@bar.com', 'j+j@j.j']
8
+ end
9
+
10
+ def invalid_emails
11
+ [nil, false, -1, '', ' ', 'g', '123g', 'foo@', '@foo']
12
+ end
13
+
14
+ def test_that_email_values_return_true
15
+ valid_emails.each do |hex|
16
+ assert Iz.email?(hex)
17
+ end
18
+ end
19
+
20
+ def test_that_invalid_email_values_return_false
21
+ invalid_emails.each do |hex|
22
+ assert !Iz.email?(hex)
23
+ end
24
+ end
25
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Otander
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-06 00:00:00.000000000 Z
11
+ date: 2015-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -70,6 +70,7 @@ files:
70
70
  - lib/iz/alphanumeric.rb
71
71
  - lib/iz/binary.rb
72
72
  - lib/iz/credit_card.rb
73
+ - lib/iz/email.rb
73
74
  - lib/iz/hexadecimal.rb
74
75
  - lib/iz/mac.rb
75
76
  - lib/iz/phone_number.rb
@@ -78,6 +79,7 @@ files:
78
79
  - test/test_alphanumeric.rb
79
80
  - test/test_binary.rb
80
81
  - test/test_credit_card.rb
82
+ - test/test_email.rb
81
83
  - test/test_hexadecimal.rb
82
84
  - test/test_mac.rb
83
85
  - test/test_phone_number.rb
@@ -102,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
104
  version: '0'
103
105
  requirements: []
104
106
  rubyforge_project:
105
- rubygems_version: 2.4.3
107
+ rubygems_version: 2.4.5.1
106
108
  signing_key:
107
109
  specification_version: 4
108
110
  summary: All your type checking in one place.
@@ -110,6 +112,7 @@ test_files:
110
112
  - test/test_alphanumeric.rb
111
113
  - test/test_binary.rb
112
114
  - test/test_credit_card.rb
115
+ - test/test_email.rb
113
116
  - test/test_hexadecimal.rb
114
117
  - test/test_mac.rb
115
118
  - test/test_phone_number.rb