css-colour 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +6 -0
- data/css-colour.gemspec +2 -2
- data/lib/css-colour.rb +1 -2
- data/lib/css-colour/constants.rb +4 -8
- data/lib/css-colour/version.rb +1 -1
- data/test/validator_test.rb +7 -0
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a5dc8b9e9cc2900149305009d4a8a34efbbef24
|
4
|
+
data.tar.gz: a47fd47d0bfb7030713402d6f5161647882e1fbb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d18a460fa97ae37c07eeb4a07a15cf4c1584c14c23d2290e4eb67a7e299130df8566d3b2148861da509f9fdc4cf0afd494ecb4edfe8179cf5b87ae981bd4c2b
|
7
|
+
data.tar.gz: d9ceea29591f0c954fd75cdf1191c9ef649c23c69dd0caddfae1c3a49241cde5a6de2d61122ac2753383e7f4e5d0d464c455cd08884a202d84737a730ccfac86
|
data/.travis.yml
ADDED
data/css-colour.gemspec
CHANGED
@@ -30,6 +30,6 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.require_paths = ["lib"]
|
31
31
|
|
32
32
|
spec.add_development_dependency "bundler", "~> 1.5"
|
33
|
-
spec.add_development_dependency "rake"
|
34
|
-
spec.add_development_dependency "minitest"
|
33
|
+
spec.add_development_dependency "rake"
|
34
|
+
spec.add_development_dependency "minitest"
|
35
35
|
end
|
data/lib/css-colour.rb
CHANGED
@@ -9,8 +9,7 @@ module CssColour
|
|
9
9
|
|
10
10
|
def initialize(value); self.colour = value; end
|
11
11
|
|
12
|
-
def colour=(value); @colour =
|
13
|
-
def clean(value); value.downcase.gsub(SPACE, NO_SPACE); end
|
12
|
+
def colour=(value); @colour = value.downcase.strip; end
|
14
13
|
|
15
14
|
def valid?; inherit? or websafe? or hex? or rgb? or rgba? or hsl? or hsla?; end
|
16
15
|
|
data/lib/css-colour/constants.rb
CHANGED
@@ -1,9 +1,5 @@
|
|
1
1
|
module CssColour
|
2
2
|
module Constants
|
3
|
-
SPACE = /\s/
|
4
|
-
|
5
|
-
NO_SPACE = ''.freeze
|
6
|
-
|
7
3
|
INHERIT = 'inherit'.freeze
|
8
4
|
|
9
5
|
WEBSAFE = %w(aliceblue antiquewhite aqua aquamarine azure beige bisque black blanchedalmond blue
|
@@ -53,12 +49,12 @@ module CssColour
|
|
53
49
|
[01] # 0 or 1
|
54
50
|
}x
|
55
51
|
|
56
|
-
HSL = /^hsl\((#{RANGE_0_360})
|
52
|
+
HSL = /^hsl\(\s*(#{RANGE_0_360})\s*,\s*(#{RANGE_0_100}%)\s*,\s*(#{RANGE_0_100}%)\s*\)$/
|
57
53
|
|
58
|
-
HSLA = /^hsla\((#{RANGE_0_360})
|
54
|
+
HSLA = /^hsla\(\s*(#{RANGE_0_360})\s*,\s*(#{RANGE_0_100}%),\s*(#{RANGE_0_100}%)\s*,\s*(#{RANGE_ALPHA})\s*\)$/
|
59
55
|
|
60
|
-
RGB = /^rgb\((#{RANGE_0_255})
|
56
|
+
RGB = /^rgb\(\s*(#{RANGE_0_255})\s*,\s*(#{RANGE_0_255})\s*,\s*(#{RANGE_0_255})\s*\)$/
|
61
57
|
|
62
|
-
RGBA = /^rgba\((#{RANGE_0_255})
|
58
|
+
RGBA = /^rgba\(\s*(#{RANGE_0_255})\s*,\s*(#{RANGE_0_255})\s*,\s*(#{RANGE_0_255})\s*,\s*(#{RANGE_ALPHA})\s*\)$/
|
63
59
|
end
|
64
60
|
end
|
data/lib/css-colour/version.rb
CHANGED
data/test/validator_test.rb
CHANGED
@@ -15,8 +15,11 @@ describe 'validator test' do
|
|
15
15
|
|
16
16
|
it 'should validate HEX colours' do
|
17
17
|
assert CssColour::Validator.new('#123456').valid?
|
18
|
+
assert CssColour::Validator.new(' #123456').valid?
|
19
|
+
assert CssColour::Validator.new('#123456 ').valid?
|
18
20
|
assert CssColour::Validator.new('#123').valid?
|
19
21
|
assert CssColour::Validator.new('#FF1234').valid?
|
22
|
+
refute CssColour::Validator.new('#1 23456').valid?
|
20
23
|
refute CssColour::Validator.new('123456').valid?
|
21
24
|
refute CssColour::Validator.new('123').valid?
|
22
25
|
refute CssColour::Validator.new('#GG0000').valid?
|
@@ -25,6 +28,7 @@ describe 'validator test' do
|
|
25
28
|
|
26
29
|
it 'should validate HSL colours' do
|
27
30
|
assert CssColour::Validator.new('hsl(0,0%,0%)').valid?
|
31
|
+
assert CssColour::Validator.new('hsl(0, 0%, 0%)').valid?
|
28
32
|
assert CssColour::Validator.new('hsl(360,100%,100%)').valid?
|
29
33
|
refute CssColour::Validator.new('hsl 0,0%,0%)').valid?
|
30
34
|
refute CssColour::Validator.new('hsl(0,0%,0%').valid?
|
@@ -36,6 +40,7 @@ describe 'validator test' do
|
|
36
40
|
|
37
41
|
it 'should validate HSLA colours' do
|
38
42
|
assert CssColour::Validator.new('hsla(0,0%,0%,0)').valid?
|
43
|
+
assert CssColour::Validator.new('hsla(0, 0%, 0%, 0)').valid?
|
39
44
|
assert CssColour::Validator.new('hsla(0,0%,0%,0.0)').valid?
|
40
45
|
assert CssColour::Validator.new('hsla(360,100%,100%,1)').valid?
|
41
46
|
assert CssColour::Validator.new('hsla(360,100%,100%,1.0)').valid?
|
@@ -50,6 +55,7 @@ describe 'validator test' do
|
|
50
55
|
|
51
56
|
it 'should validate RGB colours' do
|
52
57
|
assert CssColour::Validator.new('rgb(0,0,0)').valid?
|
58
|
+
assert CssColour::Validator.new('rgb(0, 0, 0)').valid?
|
53
59
|
assert CssColour::Validator.new('rgb(255,255,255)').valid?
|
54
60
|
refute CssColour::Validator.new('rgb 0,0,0)').valid?
|
55
61
|
refute CssColour::Validator.new('rgb(0,0,0 ').valid?
|
@@ -63,6 +69,7 @@ describe 'validator test' do
|
|
63
69
|
|
64
70
|
it 'should validate RGBA colours' do
|
65
71
|
assert CssColour::Validator.new('rgba(0,0,0,0)').valid?
|
72
|
+
assert CssColour::Validator.new('rgba(0, 0, 0, 0)').valid?
|
66
73
|
assert CssColour::Validator.new('rgba(0,0,0,0.0)').valid?
|
67
74
|
assert CssColour::Validator.new('rgba(255,255,255,1)').valid?
|
68
75
|
assert CssColour::Validator.new('rgba(255,255,255,1.0)').valid?
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: css-colour
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Darío Javier Cravero
|
@@ -28,28 +28,28 @@ dependencies:
|
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: minitest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
description: "\n Ruby CSS Colour validator.\n\n It will tell if a colour is
|
@@ -62,6 +62,7 @@ extensions: []
|
|
62
62
|
extra_rdoc_files: []
|
63
63
|
files:
|
64
64
|
- ".gitignore"
|
65
|
+
- ".travis.yml"
|
65
66
|
- Gemfile
|
66
67
|
- LICENSE.txt
|
67
68
|
- README.md
|