color-generator 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2c0e53071b047cf14532a3dc3a802a8b0cef33df
4
+ data.tar.gz: 2644ae9c704f124e03ac54732a87854db0e05e51
5
+ SHA512:
6
+ metadata.gz: 948ca7652d941678e16437e155e4a63f3e4a45579887e11f08d1b9dbff2888109b987bd614ff17c84e040d2b3ff9e9fa0c18f059946f34501335907f100aa870
7
+ data.tar.gz: 18608f5f06374de49d3749684f0905d218060df81eb7c4cf66d5efa927f0db677a21837d0f47ba84d5751229e4f12c5878cb0177c89a17dffc567ed3a39918ab
@@ -1,3 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
+ - 1.8.7
4
+ - 1.9.2
3
5
  - 1.9.3
6
+ - 2.0.0
7
+ - ree
data/README.md CHANGED
@@ -1,7 +1,9 @@
1
1
  # Ruby Color Generator
2
2
 
3
+ [![Build Status](https://secure.travis-ci.org/opennorth/color-generator.png)](http://travis-ci.org/opennorth/color-generator)
3
4
  [![Dependency Status](https://gemnasium.com/opennorth/color-generator.png)](https://gemnasium.com/opennorth/color-generator)
4
- [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/opennorth/color-generator)
5
+ [![Coverage Status](https://coveralls.io/repos/opennorth/color-generator/badge.png?branch=master)](https://coveralls.io/r/opennorth/color-generator)
6
+ [![Code Climate](https://codeclimate.com/github/opennorth/color-generator.png)](https://codeclimate.com/github/opennorth/color-generator)
5
7
 
6
8
  This gem randomly generates very distinct colors with consistent lightness and saturation.
7
9
 
@@ -1,6 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "color-generator/version"
2
+ require File.expand_path('../lib/color-generator/version', __FILE__)
4
3
 
5
4
  Gem::Specification.new do |s|
6
5
  s.name = "color-generator"
@@ -10,6 +9,7 @@ Gem::Specification.new do |s|
10
9
  s.email = ["info@opennorth.ca"]
11
10
  s.homepage = "http://github.com/opennorth/color-generator"
12
11
  s.summary = %q{Randomly generate distinct colors with consistent lightness and saturation}
12
+ s.license = 'MIT'
13
13
 
14
14
  s.files = `git ls-files`.split("\n")
15
15
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -18,4 +18,5 @@ Gem::Specification.new do |s|
18
18
 
19
19
  s.add_development_dependency('rspec', '~> 2.10')
20
20
  s.add_development_dependency('rake')
21
+ s.add_development_dependency('coveralls')
21
22
  end
@@ -12,9 +12,14 @@ class ColorGenerator
12
12
  # @option opts [Float,Integer] :value value in the interval [0, 1], sets the
13
13
  # color representation to HSV
14
14
  # @option opts [Integer] :seed seed for the pseudorandom number generator
15
+ # @option opts [Float,Integer] :hue hue to use as the start in the interval [0, 1]
15
16
  def initialize(opts = {})
16
- srand(opts[:seed]) if opts.key?(:seed)
17
- @hue = rand
17
+ if opts.key?(:hue)
18
+ @hue = opts[:hue]
19
+ else
20
+ srand(opts[:seed]) if opts.key?(:seed)
21
+ @hue = rand
22
+ end
18
23
  @saturation = opts[:saturation].to_f
19
24
  if opts.has_key? :lightness
20
25
  @mode = :HSL
@@ -1,3 +1,3 @@
1
- module ColorGenerator
2
- VERSION = "0.0.3"
1
+ class ColorGenerator
2
+ VERSION = "0.0.4"
3
3
  end
@@ -0,0 +1,30 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe ColorGenerator do
4
+ it 'should accept a seed for the pseudorandom number generator' do
5
+ ColorGenerator.new(:saturation => 0.3, :value => 1.0, :seed => 1).create_hex.should == 'ffc3b3'
6
+ end
7
+
8
+ it 'should generate a random color as a hex triplet using the HSL color representation' do
9
+ ColorGenerator.new(:saturation => 0.3, :lightness => 0.75).create_hex.should match(/\A[0-9a-f]{6}\z/)
10
+ end
11
+
12
+ it 'should generate a random color as a hex triplet using the HSV color representation' do
13
+ ColorGenerator.new(:saturation => 0.3, :value => 1.0).create_hex.should match(/\A[0-9a-f]{6}\z/)
14
+ end
15
+
16
+ it 'should generate a random color as a decimal triplet' do
17
+ values = ColorGenerator.new(:saturation => 0.3, :value => 1.0).create_rgb
18
+ values.should be_an(Array)
19
+ values.each do |value|
20
+ value.should >= 0
21
+ value.should <= 255
22
+ end
23
+ end
24
+
25
+ it 'should use the provided hue' do
26
+ generator = ColorGenerator.new(:saturation => 0.3, :value => 1.0, :hue => 0.5)
27
+ generator.create_hex.should == 'ffe9b3'
28
+ generator.hue.should == 0.1180339887498949
29
+ end
30
+ end
@@ -0,0 +1,7 @@
1
+ require 'rubygems'
2
+
3
+ require 'coveralls'
4
+ Coveralls.wear!
5
+
6
+ require 'rspec'
7
+ require File.dirname(__FILE__) + '/../lib/color-generator'
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: color-generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
5
- prerelease:
4
+ version: 0.0.4
6
5
  platform: ruby
7
6
  authors:
8
7
  - Open North
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-02-05 00:00:00.000000000 Z
11
+ date: 2013-09-16 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rspec
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
@@ -30,17 +27,29 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: coveralls
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
44
53
  - !ruby/object:Gem::Version
45
54
  version: '0'
46
55
  description:
@@ -61,29 +70,32 @@ files:
61
70
  - color-generator.gemspec
62
71
  - lib/color-generator.rb
63
72
  - lib/color-generator/version.rb
73
+ - spec/color-generator_spec.rb
74
+ - spec/spec_helper.rb
64
75
  homepage: http://github.com/opennorth/color-generator
65
- licenses: []
76
+ licenses:
77
+ - MIT
78
+ metadata: {}
66
79
  post_install_message:
67
80
  rdoc_options: []
68
81
  require_paths:
69
82
  - lib
70
83
  required_ruby_version: !ruby/object:Gem::Requirement
71
- none: false
72
84
  requirements:
73
- - - ! '>='
85
+ - - '>='
74
86
  - !ruby/object:Gem::Version
75
87
  version: '0'
76
88
  required_rubygems_version: !ruby/object:Gem::Requirement
77
- none: false
78
89
  requirements:
79
- - - ! '>='
90
+ - - '>='
80
91
  - !ruby/object:Gem::Version
81
92
  version: '0'
82
93
  requirements: []
83
94
  rubyforge_project:
84
- rubygems_version: 1.8.24
95
+ rubygems_version: 2.0.8
85
96
  signing_key:
86
- specification_version: 3
97
+ specification_version: 4
87
98
  summary: Randomly generate distinct colors with consistent lightness and saturation
88
- test_files: []
89
- has_rdoc:
99
+ test_files:
100
+ - spec/color-generator_spec.rb
101
+ - spec/spec_helper.rb