tty-screen 0.4.2 → 0.4.3
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 +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/tty/screen/color.rb +16 -7
- data/lib/tty/screen/version.rb +1 -1
- data/spec/unit/color_spec.rb +2 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf079c51ac4f0fcb5bb6c29031a77ed0d7bf6bb5
|
4
|
+
data.tar.gz: 415b2d5c8e694c8cc3d9b7261b7dedbc20e8b8dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bed4c21fb89f382f348ebf2548e9b0d0344ed9bd0ab46fbdd9448e405c1c2197dcad9a536c890c60dbd1d1ec104850839fd2edcc54834474aa23abc7e09068ff
|
7
|
+
data.tar.gz: 82eb587b1334c125bc509d11259cfb9680218c35d9405912af2f202dfa867c6e9fcbbf11649d06cfc3a27d7e4d4b5575ea9ebab2cfb80cec59cc2a4395f752db
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
0.4.3 (Nov 1, 2015)
|
2
|
+
|
3
|
+
* Fix issue with #from_curses method and remove ensure block
|
4
|
+
* Add NoValue to Color class to mark failure of reading color value
|
5
|
+
* Change Color class supports? to recognize lack of color value
|
6
|
+
|
1
7
|
0.4.2 (Oct 31, 2015)
|
2
8
|
|
3
9
|
* Change visibility of output to prevent warnings
|
data/lib/tty/screen/color.rb
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
module TTY
|
4
4
|
class Screen
|
5
5
|
class Color
|
6
|
+
NoValue = Module.new
|
7
|
+
|
6
8
|
# Initialize color support
|
7
9
|
#
|
8
10
|
# @api public
|
@@ -20,7 +22,12 @@ module TTY
|
|
20
22
|
def supports?
|
21
23
|
return false unless tty?
|
22
24
|
|
23
|
-
|
25
|
+
value = false
|
26
|
+
%w(from_curses from_tput from_term from_env).each do |from_check|
|
27
|
+
break if (value = public_send(from_check)) != NoValue
|
28
|
+
end
|
29
|
+
return false if value == NoValue
|
30
|
+
value
|
24
31
|
end
|
25
32
|
|
26
33
|
# Attempt to load curses to check color support
|
@@ -31,16 +38,18 @@ module TTY
|
|
31
38
|
def from_curses(curses_class = nil)
|
32
39
|
require 'curses'
|
33
40
|
|
34
|
-
|
41
|
+
if defined?(Curses)
|
35
42
|
curses_class ||= Curses
|
36
43
|
curses_class.init_screen
|
37
|
-
curses_class.has_colors?
|
38
|
-
ensure
|
44
|
+
has_color = curses_class.has_colors?
|
39
45
|
curses_class.close_screen
|
46
|
+
has_color
|
47
|
+
else
|
48
|
+
NoValue
|
40
49
|
end
|
41
50
|
rescue LoadError
|
42
51
|
warn 'no native curses support' if @verbose
|
43
|
-
|
52
|
+
NoValue
|
44
53
|
end
|
45
54
|
|
46
55
|
# Shell out to tput to check color support
|
@@ -49,7 +58,7 @@ module TTY
|
|
49
58
|
def from_tput
|
50
59
|
%x(tput colors 2>/dev/null).to_i > 2
|
51
60
|
rescue Errno::ENOENT
|
52
|
-
|
61
|
+
NoValue
|
53
62
|
end
|
54
63
|
|
55
64
|
# Inspect environment $TERM variable for color support
|
@@ -60,7 +69,7 @@ module TTY
|
|
60
69
|
false
|
61
70
|
elsif ENV['TERM'] =~ /^screen|^xterm|^vt100|color|ansi|cygwin|linux/i
|
62
71
|
true
|
63
|
-
else
|
72
|
+
else NoValue
|
64
73
|
end
|
65
74
|
end
|
66
75
|
|
data/lib/tty/screen/version.rb
CHANGED
data/spec/unit/color_spec.rb
CHANGED
@@ -17,11 +17,12 @@ RSpec.describe TTY::Screen::Color, '.supports?' do
|
|
17
17
|
allow(color).to receive(:require).with('curses').
|
18
18
|
and_raise(LoadError)
|
19
19
|
|
20
|
-
expect(color.from_curses).to eq(
|
20
|
+
expect(color.from_curses).to eq(described_class::NoValue)
|
21
21
|
end
|
22
22
|
|
23
23
|
it "loads curses for color support" do
|
24
24
|
allow(color).to receive(:require).with('curses').and_return(true)
|
25
|
+
stub_const("Curses", Object.new)
|
25
26
|
curses = double(:curses)
|
26
27
|
allow(curses).to receive(:init_screen)
|
27
28
|
allow(curses).to receive(:has_colors?).and_return(true)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tty-screen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Murach
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|