iz 0.2.1 → 0.3.0

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: 9e5774c1487906f63622d4e5228e2b0f7d8eb767
4
- data.tar.gz: 049078ebdb821c89753537dec07685f38bf8ce3b
3
+ metadata.gz: ea09e4303256e6f3d30282602deecd73e574c3c1
4
+ data.tar.gz: 59c737295b6f0c7c2121d4696d6f1c6d969db545
5
5
  SHA512:
6
- metadata.gz: 296b08dbf6ead79c09cb6b70964f91aba4d100077593ffe8faea3deca236d3a493976a30ecc812ad63baa8b091c09a96631c008c8e280a644b7ae285bb67481f
7
- data.tar.gz: 05eaf9fb3cd88ebacdef60623b5ed4d4066598222915b72f803e199885b84e87e2dcd99cbf6870a0353390e7964be27c09eda7b0b60a39169f367e31414cd4ea
6
+ metadata.gz: 1aad320d00ec5f28a14574fc0bb6a851062e1da838a15d84cbad2ef9725b3603d9c1d630d13ac831851c2ac482e560ccc973b66313cd68995122779f94616645
7
+ data.tar.gz: 5d0dd294f21c550e1fd42900a1c9312766e4a396111b682686ced1164f799c65cf2593ec1612cf0a13a81419318166813b1b8142d6b616ba82cd4fefe21228cc
@@ -0,0 +1,23 @@
1
+ module Iz
2
+ class HexColor
3
+ REGEX = /^([0-9a-f]{3}|[0-9a-f]{6})$/i
4
+
5
+ attr_accessor :value
6
+
7
+ def initialize(hex_color)
8
+ self.value = hex_color
9
+ end
10
+
11
+ def valid?
12
+ !!Iz::HexColor.is_hex_color?(value)
13
+ end
14
+
15
+ def self.is_hex_color?(value)
16
+ val = value.to_s
17
+ return false unless val[0] == '#'
18
+
19
+ val[0] = ''
20
+ val =~ REGEX
21
+ end
22
+ end
23
+ end
data/lib/iz/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Iz
2
- VERSION = "0.2.1"
2
+ VERSION = '0.3.0'
3
3
  end
data/lib/iz.rb CHANGED
@@ -4,6 +4,8 @@ require 'iz/alphanumeric'
4
4
  require 'iz/phone_number'
5
5
  require 'iz/credit_card'
6
6
  require 'iz/hexadecimal'
7
+ require 'iz/hex_color'
8
+ require 'iz/hex_color'
7
9
  require 'iz/binary'
8
10
  require 'iz/email'
9
11
  require 'iz/mac'
@@ -18,6 +20,10 @@ module Iz
18
20
  !!Iz::Hexadecimal.is_hexadecimal?(hexadecimal)
19
21
  end
20
22
 
23
+ def self.hex_color?(hex_color)
24
+ !!Iz::HexColor.is_hex_color?(hex_color)
25
+ end
26
+
21
27
  def self.email?(email)
22
28
  !!Iz::Email.is_email?(email)
23
29
  end
@@ -0,0 +1,25 @@
1
+ require 'test/unit'
2
+ require 'iz'
3
+
4
+ class TestHexColor < Test::Unit::TestCase
5
+
6
+ def valid_hex_colors
7
+ ['#123', '#1bc', '#AB9', '#888aaa']
8
+ end
9
+
10
+ def invalid_hex_colors
11
+ [nil, false, -1, '', ' ', 'g', '#1234']
12
+ end
13
+
14
+ def test_that_hex_color_values_return_true
15
+ valid_hex_colors.each do |hex|
16
+ assert Iz.hex_color?(hex)
17
+ end
18
+ end
19
+
20
+ def test_that_invalid_hex_color_values_return_false
21
+ invalid_hex_colors.each do |hex|
22
+ assert !Iz.hex_color?(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.2.1
4
+ version: 0.3.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-10-01 00:00:00.000000000 Z
11
+ date: 2016-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -71,6 +71,7 @@ files:
71
71
  - lib/iz/binary.rb
72
72
  - lib/iz/credit_card.rb
73
73
  - lib/iz/email.rb
74
+ - lib/iz/hex_color.rb
74
75
  - lib/iz/hexadecimal.rb
75
76
  - lib/iz/mac.rb
76
77
  - lib/iz/phone_number.rb
@@ -80,6 +81,7 @@ files:
80
81
  - test/test_binary.rb
81
82
  - test/test_credit_card.rb
82
83
  - test/test_email.rb
84
+ - test/test_hex_color.rb
83
85
  - test/test_hexadecimal.rb
84
86
  - test/test_mac.rb
85
87
  - test/test_phone_number.rb
@@ -104,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
106
  version: '0'
105
107
  requirements: []
106
108
  rubyforge_project:
107
- rubygems_version: 2.4.5.1
109
+ rubygems_version: 2.5.1
108
110
  signing_key:
109
111
  specification_version: 4
110
112
  summary: All your type checking in one place.
@@ -113,6 +115,7 @@ test_files:
113
115
  - test/test_binary.rb
114
116
  - test/test_credit_card.rb
115
117
  - test/test_email.rb
118
+ - test/test_hex_color.rb
116
119
  - test/test_hexadecimal.rb
117
120
  - test/test_mac.rb
118
121
  - test/test_phone_number.rb