easy-color 0.2.1 → 0.2.2

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 (2) hide show
  1. data/lib/easy-color.rb +15 -3
  2. metadata +1 -1
@@ -52,15 +52,27 @@ class String
52
52
  end
53
53
 
54
54
  def fg(color)
55
- "\033[#{$color[color]}m#{self}\033[0m" if valid(:color => color)
55
+ if $stdout.isatty
56
+ "\033[#{$color[color]}m#{self}\033[0m" if valid(:color => color)
57
+ else
58
+ "#{self}"
59
+ end
56
60
  end
57
61
 
58
62
  def bg(color)
59
- "\033[#{($color[color]+10)}m#{self}\033[0m" if valid(:color => color)
63
+ if $stdout.isatty
64
+ "\033[#{($color[color]+10)}m#{self}\033[0m" if valid(:color => color)
65
+ else
66
+ "#{self}"
67
+ end
60
68
  end
61
69
 
62
70
  def attr(attr)
63
- "\033[#{($attrs[attr])}m#{self}\033[0m" if valid(:attr => attr)
71
+ if $stdout.isatty
72
+ "\033[#{($attrs[attr])}m#{self}\033[0m" if valid(:attr => attr)
73
+ else
74
+ "#{self}"
75
+ end
64
76
  end
65
77
 
66
78
  def method_missing(m, *args, &block)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy-color
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: