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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4f6f5160b9147fdb467f57053b4409e5bcad6be0
4
- data.tar.gz: 3242f8a8af232b6ee693589c84ea542fdbd6cd2a
3
+ metadata.gz: 3a5dc8b9e9cc2900149305009d4a8a34efbbef24
4
+ data.tar.gz: a47fd47d0bfb7030713402d6f5161647882e1fbb
5
5
  SHA512:
6
- metadata.gz: 6e5087cf210526af17d4d4cd5428bbefcc54e59a742d86d521ebcbee26e76b3c14d672664fc958da2f565c618e09d6fd81457db023255bdccb3b2820c8d124ea
7
- data.tar.gz: ffc1268bd37bfe4e38da07f8154b0556ee6835a931c7490fe4a4534550119fef026c5b23d0c5d8632eae4c59611446ad4e93b8daf66b550ea9b2ace0a6f5dea4
6
+ metadata.gz: 1d18a460fa97ae37c07eeb4a07a15cf4c1584c14c23d2290e4eb67a7e299130df8566d3b2148861da509f9fdc4cf0afd494ecb4edfe8179cf5b87ae981bd4c2b
7
+ data.tar.gz: d9ceea29591f0c954fd75cdf1191c9ef649c23c69dd0caddfae1c3a49241cde5a6de2d61122ac2753383e7f4e5d0d464c455cd08884a202d84737a730ccfac86
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.1.1
5
+ - jruby-19mode # JRuby in 1.9 mode
6
+ - rbx-2.1.1
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", '~> 0'
34
- spec.add_development_dependency "minitest", '~> 0'
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 = clean(value); end
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
 
@@ -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}),(#{RANGE_0_100}%),(#{RANGE_0_100}%)\)$/
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}),(#{RANGE_0_100}%),(#{RANGE_0_100}%),(#{RANGE_ALPHA})\)$/
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}),(#{RANGE_0_255}),(#{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}),(#{RANGE_0_255}),(#{RANGE_0_255}),(#{RANGE_ALPHA})\)$/
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
@@ -1,3 +1,3 @@
1
1
  module CssColour
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -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.1
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