color_divider 0.0.1
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 +7 -0
- data/lib/color_divider.rb +37 -0
- data/spec/color_divider_spec.rb +45 -0
- metadata +66 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ccf52c1037c04a0e4aba63540c00b22cf6292005
|
4
|
+
data.tar.gz: 457544856eca9dda847929d331722f3cf85e17bd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8d55215c74bbaee3efa0f0ebe6e0cf9f5cd88b70bd29f4ef587b2f1eeffc348d94822ddb06976e36fad7187c6628698732b4cc3ed0b1cc17d372c78f45fe8bc7
|
7
|
+
data.tar.gz: 090b62b9f761bdeecd8e8c2abd95c553f66d75136128ac73a7d9be10020f7237f1bffdc106b23fcc32610af2a8cfd5f650286934bb010472e391a6ee0b68439d
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'hex_to_rgb'
|
2
|
+
require 'rgb_to_hex_color'
|
3
|
+
|
4
|
+
class ColorDivider
|
5
|
+
def initialize(start_color, end_color)
|
6
|
+
@start_color = start_color
|
7
|
+
@end_color = end_color
|
8
|
+
end
|
9
|
+
|
10
|
+
def start_color
|
11
|
+
@start_color
|
12
|
+
end
|
13
|
+
|
14
|
+
def end_color
|
15
|
+
@end_color
|
16
|
+
end
|
17
|
+
|
18
|
+
def middle
|
19
|
+
start_r, start_g, start_b = hex_to_rgb(start_color).rgb
|
20
|
+
end_r, end_g, end_b = hex_to_rgb(end_color).rgb
|
21
|
+
|
22
|
+
middle_r = (end_r - start_r + 1)/2
|
23
|
+
middle_g = (end_g - start_g + 1)/2
|
24
|
+
middle_b = (end_b - start_b + 1)/2
|
25
|
+
|
26
|
+
[middle_r, middle_g, middle_b]
|
27
|
+
|
28
|
+
rgb_to_hex = RgbToHexColor.new(middle_r, middle_g, middle_b)
|
29
|
+
rgb_to_hex.hex
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
def hex_to_rgb(hex)
|
34
|
+
HexToRgb.new(hex)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'color_divider'
|
2
|
+
|
3
|
+
describe ColorDivider do
|
4
|
+
let(:expected_start_color) { '#000000' }
|
5
|
+
let(:expected_end_color) { '#FFFFFF' }
|
6
|
+
|
7
|
+
let(:color_divider) do
|
8
|
+
described_class.new(expected_start_color, expected_end_color)
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#initialize" do
|
12
|
+
subject { color_divider }
|
13
|
+
|
14
|
+
it "takes two colors" do
|
15
|
+
expect{subject}.not_to raise_exception
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "#start_color" do
|
20
|
+
subject { color_divider.start_color }
|
21
|
+
|
22
|
+
it "is the right color" do
|
23
|
+
expect(subject).to eq expected_start_color
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#end_color" do
|
28
|
+
subject { color_divider.end_color }
|
29
|
+
|
30
|
+
it "is the right color" do
|
31
|
+
expect(subject).to eq expected_end_color
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "#middle" do
|
36
|
+
let(:expected_middle_color) { "#808080" }
|
37
|
+
|
38
|
+
subject { color_divider.middle }
|
39
|
+
|
40
|
+
it "divides the color in two" do
|
41
|
+
expect(subject).to eq expected_middle_color
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
metadata
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: color_divider
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kyle Tolle
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.0'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 3.0.0
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.0'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 3.0.0
|
33
|
+
description:
|
34
|
+
email: kyle@nullsix.com
|
35
|
+
executables: []
|
36
|
+
extensions: []
|
37
|
+
extra_rdoc_files: []
|
38
|
+
files:
|
39
|
+
- lib/color_divider.rb
|
40
|
+
- spec/color_divider_spec.rb
|
41
|
+
homepage: https://github.com/kyletolle/color_divider
|
42
|
+
licenses:
|
43
|
+
- MIT
|
44
|
+
metadata: {}
|
45
|
+
post_install_message:
|
46
|
+
rdoc_options: []
|
47
|
+
require_paths:
|
48
|
+
- lib
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
requirements: []
|
60
|
+
rubyforge_project:
|
61
|
+
rubygems_version: 2.2.2
|
62
|
+
signing_key:
|
63
|
+
specification_version: 4
|
64
|
+
summary: Find the color that's between two other hex colors.
|
65
|
+
test_files: []
|
66
|
+
has_rdoc:
|