teejayvanslyke-sassafras 0.1.3 → 0.1.4

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.
Files changed (3) hide show
  1. data/lib/sassafras.rb +2 -1
  2. data/spec/sassafras_spec.rb +31 -12
  3. metadata +1 -1
data/lib/sassafras.rb CHANGED
@@ -58,7 +58,8 @@ module Sassafras
58
58
  end
59
59
 
60
60
  def initialize(base)
61
- @base_rgb = Color::RGB.const_get(base.to_s.camelize)
61
+ is_hex = (base =~ /#.*/)
62
+ @base_rgb = is_hex ? Color::RGB.from_html(base) : Color::RGB.const_get(base.to_s.camelize)
62
63
  @colors = { 'base' =>
63
64
  Tints.new(@base_rgb).colors.merge(
64
65
  Shades.new(@base_rgb).colors)
@@ -3,6 +3,18 @@ require File.dirname(__FILE__) + '/spec_helper.rb'
3
3
  describe Sassafras do
4
4
 
5
5
  describe Sassafras::Theme do
6
+
7
+ def red_values
8
+ {
9
+ 'lightest' => '#ffe6e6',
10
+ 'lighter' => '#ffb3b3',
11
+ 'light' => '#ff8080',
12
+ 'mid' => '#ff0000',
13
+ 'dark' => '#800000',
14
+ 'darker' => '#4d0000',
15
+ 'darkest' => '#1a0000'
16
+ }
17
+ end
6
18
 
7
19
  describe "when creating a basic color scheme" do
8
20
 
@@ -10,18 +22,6 @@ describe Sassafras do
10
22
  @sassafras = Sassafras::Theme.basic(:red)
11
23
  end
12
24
 
13
- def red_values
14
- {
15
- 'lightest' => '#ffe6e6',
16
- 'lighter' => '#ffb3b3',
17
- 'light' => '#ff8080',
18
- 'mid' => '#ff0000',
19
- 'dark' => '#800000',
20
- 'darker' => '#4d0000',
21
- 'darkest' => '#1a0000'
22
- }
23
- end
24
-
25
25
  it "sets the base color" do
26
26
  @sassafras.base.should == "#ff0000"
27
27
  end
@@ -54,6 +54,25 @@ SASS
54
54
  @sassafras.colors.size.should == 1
55
55
  end
56
56
  end
57
+
58
+
59
+ describe "when creating a color scheme from hex" do
60
+
61
+ before :each do
62
+ @sassafras = Sassafras::Theme.basic('#ff0000')
63
+ end
64
+
65
+ it "sets the base color" do
66
+ @sassafras.base.should == "#ff0000"
67
+ end
68
+
69
+ it "generates the base tints and shades" do
70
+ red_values.each do |name, hex|
71
+ @sassafras.colors(:base).should have_key(name)
72
+ @sassafras.colors(:base)[name].should == hex
73
+ end
74
+ end
75
+ end
57
76
 
58
77
 
59
78
  describe "when generating Sass output" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teejayvanslyke-sassafras
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - T.J. VanSlyke