colorb 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/colorb.rb +10 -5
  3. metadata +35 -42
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 31ccba0a7a211fcdb615302a5062e8aa3cb43116
4
+ data.tar.gz: 72af8becd9e2e2cadb74e11c9a8256e27ec6d19e
5
+ SHA512:
6
+ metadata.gz: f4da3412790d141e03893393e72ef6f756ecba51d09475fd9593d815d93dc788d08695350dc0eb8ce4376336fd6a0c6fc444e4f42aa52dd87dd6b8d840293d01
7
+ data.tar.gz: 7f58a2c7fecbd5b5fcd40b2ea31710537eab3c0b31cb45774c03fa0e121e005d9a80202675359eba17755ac0f42ca9bb2cd0e8c1b8ce8a4d2b07863028b9a9af
@@ -16,6 +16,7 @@
16
16
  #++
17
17
 
18
18
  require 'Win32/Console/ANSI' if RUBY_PLATFORM =~ /win32/
19
+ require 'color'
19
20
 
20
21
  class String
21
22
  Colors = {
@@ -70,12 +71,10 @@ class String
70
71
  string = (self.frozen?) ? self.dup : self
71
72
 
72
73
  if code.is_a?(Symbol) || code.is_a?(String)
73
- name = code.to_sym
74
-
75
74
  if !string.foreground
76
- string.foreground = name
75
+ string.foreground = code
77
76
  else
78
- string.background = name
77
+ string.background = code
79
78
  end
80
79
 
81
80
  string.lazy? ? string : string.colorify!
@@ -143,7 +142,13 @@ class String
143
142
 
144
143
  def self.color! (what, bg=false)
145
144
  if what.is_a?(Symbol) || what.is_a?(String)
146
- "\e[#{Colors[what.to_sym] + (bg ? 40 : 30)}m" if Colors[what.to_sym]
145
+ if Colors[what.to_sym]
146
+ "\e[#{Colors[what.to_sym] + (bg ? 40 : 30)}m"
147
+ else
148
+ color = Color::RGB.from_html(what.to_s)
149
+
150
+ "\e[#{bg ? 48 : 38};2;#{color.red.to_i};#{color.green.to_i};#{color.blue.to_i}m"
151
+ end
147
152
  elsif what.is_a?(Numeric)
148
153
  if what < 8
149
154
  "\e[#{what + (bg ? 40 : 30)}m"
metadata CHANGED
@@ -1,64 +1,57 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: colorb
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 0
8
- - 8
9
- version: 0.0.8
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.9
10
5
  platform: ruby
11
- authors:
6
+ authors:
12
7
  - meh.
13
8
  autorequire:
14
9
  bindir: bin
15
10
  cert_chain: []
16
-
17
- date: 2011-05-26 00:00:00 +02:00
18
- default_executable:
19
- dependencies: []
20
-
11
+ date: 2013-05-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: color
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
21
27
  description:
22
28
  email: meh@paranoici.org
23
29
  executables: []
24
-
25
30
  extensions: []
26
-
27
31
  extra_rdoc_files: []
28
-
29
- files:
32
+ files:
30
33
  - lib/colorb.rb
31
- has_rdoc: true
32
34
  homepage: http://github.com/meh/colorb
33
35
  licenses: []
34
-
36
+ metadata: {}
35
37
  post_install_message:
36
38
  rdoc_options: []
37
-
38
- require_paths:
39
+ require_paths:
39
40
  - lib
40
- required_ruby_version: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- segments:
46
- - 0
47
- version: "0"
48
- required_rubygems_version: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- segments:
54
- - 0
55
- version: "0"
41
+ required_ruby_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ required_rubygems_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - '>='
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
56
51
  requirements: []
57
-
58
52
  rubyforge_project:
59
- rubygems_version: 1.3.7
53
+ rubygems_version: 2.0.0
60
54
  signing_key:
61
- specification_version: 3
55
+ specification_version: 4
62
56
  summary: Colorify strings in your terminal, 256 colors supported.
63
57
  test_files: []
64
-