wasko 0.2.0 → 0.2.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.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- wasko (0.2.0)
4
+ wasko (0.2.1)
5
5
  color
6
6
  thor
7
7
  thor (~> 0.15.4)
data/bin/wasko CHANGED
@@ -39,7 +39,11 @@ module Wasko
39
39
  if color_name.empty?
40
40
  say Wasko.background_color
41
41
  else
42
- Wasko.set_background_color color_name
42
+ if Wasko::Color.color_from_string(color_name)
43
+ Wasko.set_background_color color_name
44
+ else
45
+ error "#{color_name} is not a color."
46
+ end
43
47
  end
44
48
  end
45
49
 
data/lib/wasko/color.rb CHANGED
@@ -43,9 +43,15 @@ module Wasko
43
43
  # At the moment support all named css-colors (like `red`, `aliceblue`, etc.)
44
44
  # and all hex-colors.
45
45
  def self.color_from_string(color_string)
46
- return ::Color::RGB.from_html(color_string) if hex_color?(color_string)
47
- return ::Color::RGB.from_html(names_hash[color_string]) if named_color?(color_string)
48
- false
46
+ color_string = color_string.downcase
47
+
48
+ if hex_color?(color_string)
49
+ return ::Color::RGB.from_html(color_string)
50
+ end
51
+
52
+ if named_color?(color_string)
53
+ return ::Color::RGB.from_html(names_hash[color_string])
54
+ end
49
55
  end
50
56
 
51
57
  # Looks through all the named css colors
data/lib/wasko/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Wasko
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
data/test/test_color.rb CHANGED
@@ -21,4 +21,12 @@ class TestWaskoColor < Test::Unit::TestCase
21
21
  should "convert aliceblue to Color" do
22
22
  assert_equal ::Color::RGB.from_html("#f0f8ff"), Wasko::Color.color_from_string("aliceblue")
23
23
  end
24
+
25
+ should "handle upcased css names to Color" do
26
+ assert_equal ::Color::RGB.from_html("#ff0000"), Wasko::Color.color_from_string("RED")
27
+ end
28
+
29
+ should "gracefully handle bogus input names" do
30
+ assert_nil Wasko::Color.color_from_string("poppycock")
31
+ end
24
32
  end
data/test/test_wasko.rb CHANGED
@@ -2,6 +2,14 @@ require 'helper'
2
2
 
3
3
  class TestWasko < Test::Unit::TestCase
4
4
 
5
+ should "set background color to tint" do
6
+ ata = mock()
7
+ ata.expects(:startup_background_color).returns("{0,0,0}")
8
+ ata.expects(:set_background_color).with("{16962, 0, 0}").returns(nil)
9
+ Wasko.stubs(:advanced_typing_apparatus).returns(ata)
10
+ Wasko.set_background_color("red")
11
+ end
12
+
5
13
  context "setting palette" do
6
14
  setup do
7
15
  @color = Wasko::Color.color_from_string("white")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wasko
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-24 00:00:00.000000000 Z
12
+ date: 2012-10-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
@@ -145,7 +145,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
145
145
  version: '0'
146
146
  segments:
147
147
  - 0
148
- hash: -1096904852995831411
148
+ hash: -2167249535749031942
149
149
  required_rubygems_version: !ruby/object:Gem::Requirement
150
150
  none: false
151
151
  requirements:
@@ -154,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
154
154
  version: '0'
155
155
  segments:
156
156
  - 0
157
- hash: -1096904852995831411
157
+ hash: -2167249535749031942
158
158
  requirements: []
159
159
  rubyforge_project:
160
160
  rubygems_version: 1.8.24