tty-color 0.3.0 → 0.4.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 172ef7053be12d6a8034734dbdb8762aff8e586a
4
- data.tar.gz: f656a2a75764ceded9756d72a48e95d37605158a
3
+ metadata.gz: 03f11c4bd9e523a3e1cc9c8921345e959f55e478
4
+ data.tar.gz: 5ddadca9c0867662bf3985d4d32d976d61ca9026
5
5
  SHA512:
6
- metadata.gz: 2bd34dfe7dad34a85fd13429880c30fbd998e1a84e80c77788f9e5c4568e611d186d97b13d336cd4643ede0c641e5e07dc8ef98446a28183301a71b394375931
7
- data.tar.gz: fea1c61b20f4e201cadab45c43b05d5989c53ce6b01baae58edb96918d4e8f1b586e28004e09a54ad5eaa97cd1a4c3493528d9e03083e9f5e892a0c946553cfa
6
+ metadata.gz: f6b92ae8023568869637cc43a5c993f1fac4f4579daf9f5116d2fc6783ee8d761f5fb89755c8e0c8643a308f0191f6eaa0d91230965ea0b5cfc1163541be8537
7
+ data.tar.gz: 7210d36bcf7f5d7fff0477e45775fb33587a653b2d968e530e6f9ce7d112b9a66acdf5d3dfab9f89997751513f7b8bfae4888744fe13fec409b4b96c45df0594
@@ -2,22 +2,24 @@
2
2
  language: ruby
3
3
  sudo: false
4
4
  cache: bundler
5
- bundler_args: --without yard benchmarks
6
5
  script: "bundle exec rake ci"
7
6
  rvm:
8
7
  - 1.9.3
9
- - 2.0
10
- - 2.1
11
- - 2.2
12
- - rbx-2
13
- - jruby-19mode
14
- - jruby
15
- - jruby-head
8
+ - 2.0.0
9
+ - 2.1.10
10
+ - 2.2.5
11
+ - 2.3.1
16
12
  - ruby-head
13
+ - jruby-9000
14
+ - jruby-head
15
+ - rbx-2
17
16
  matrix:
18
17
  allow_failures:
19
18
  - rvm: ruby-head
20
19
  - rvm: jruby-head
20
+ - rvm: rbx-2
21
21
  fast_finish: true
22
22
  branches:
23
23
  only: master
24
+ notifications:
25
+ email: false
@@ -1,5 +1,18 @@
1
1
  # Change log
2
2
 
3
+ ## [v0.4.0] - 2016-12-27
4
+
5
+ ### Added
6
+ * Add #command? helper
7
+ * Add #windows? helper
8
+
9
+ ### Changed
10
+ * Change to stop checking curses on Windows
11
+
12
+ ### Fixed
13
+ * Fix Support#from_tput check to fail gracefully on non-unix systems
14
+ * Fix Mode#from_tput check to fail gracefuly on non-unix systems
15
+
3
16
  ## [v0.3.0] - 2016-01-13
4
17
 
5
18
  ### Fixed
@@ -20,6 +33,7 @@
20
33
 
21
34
  * Initial implementation and release
22
35
 
36
+ [v0.4.0]: https://github.com/peter-murach/tty-color/compare/v0.3.0...v0.4.0
23
37
  [v0.3.0]: https://github.com/peter-murach/tty-color/compare/v0.2.0...v0.3.0
24
38
  [v0.2.0]: https://github.com/peter-murach/tty-color/compare/v0.1.0...v0.2.0
25
39
  [v0.1.0]: https://github.com/peter-murach/tty-color/compare/v0.1.0
data/Gemfile CHANGED
@@ -3,7 +3,7 @@ source 'https://rubygems.org'
3
3
  gemspec
4
4
 
5
5
  group :development do
6
- gem 'rspec', '~> 3.4.0'
6
+ gem 'rspec', '~> 3.5.0'
7
7
  gem 'yard', '~> 0.8.7'
8
8
  gem 'benchmark-ips', '~> 2.0.0'
9
9
  end
@@ -12,4 +12,5 @@ group :metrics do
12
12
  gem 'coveralls', '~> 0.8.2'
13
13
  gem 'simplecov', '~> 0.10.0'
14
14
  gem 'yardstick', '~> 0.9.9'
15
+ gem 'term-ansicolor', '=1.3.2'
15
16
  end
data/README.md CHANGED
@@ -1,19 +1,22 @@
1
- # TTY::Color
1
+ # TTY::Color [![Gitter](https://badges.gitter.im/Join%20Chat.svg)][gitter]
2
2
  [![Gem Version](https://badge.fury.io/rb/tty-color.svg)][gem]
3
- [![Build Status](https://secure.travis-ci.org/peter-murach/tty-color.svg?branch=master)][travis]
4
- [![Code Climate](https://codeclimate.com/github/peter-murach/tty-color/badges/gpa.svg)][codeclimate]
5
- [![Coverage Status](https://coveralls.io/repos/peter-murach/tty-color/badge.svg)][coverage]
6
- [![Inline docs](http://inch-ci.org/github/peter-murach/tty-color.svg?branch=master)][inchpages]
3
+ [![Build Status](https://secure.travis-ci.org/piotrmurach/tty-color.svg?branch=master)][travis]
4
+ [![Build status](https://ci.appveyor.com/api/projects/status/j1nflklmnfrb2yrf?svg=true)][appveyor]
5
+ [![Code Climate](https://codeclimate.com/github/piotrmurach/tty-color/badges/gpa.svg)][codeclimate]
6
+ [![Coverage Status](https://coveralls.io/repos/github/piotrmurach/tty-color/badge.svg)][coverage]
7
+ [![Inline docs](http://inch-ci.org/github/piotrmurach/tty-color.svg?branch=master)][inchpages]
7
8
 
9
+ [gitter]: https://gitter.im/piotrmurach/tty
8
10
  [gem]: http://badge.fury.io/rb/tty-color
9
- [travis]: http://travis-ci.org/peter-murach/tty-color
10
- [codeclimate]: https://codeclimate.com/github/peter-murach/tty-color
11
- [coverage]: https://coveralls.io/r/peter-murach/tty-color
12
- [inchpages]: http://inch-ci.org/github/peter-murach/tty-color
11
+ [travis]: http://travis-ci.org/piotrmurach/tty-color
12
+ [appveyor]: https://ci.appveyor.com/project/piotrmurach/tty-color
13
+ [codeclimate]: https://codeclimate.com/github/piotrmurach/tty-color
14
+ [coverage]: https://coveralls.io/github/piotrmurach/tty-color
15
+ [inchpages]: http://inch-ci.org/github/piotrmurach/tty-color
13
16
 
14
17
  > Terminal color capabilities detection.
15
18
 
16
- **TTY::Color** provides independent color support detection component for [TTY](https://github.com/peter-murach/tty) toolkit.
19
+ **TTY::Color** provides independent color support detection component for [TTY](https://github.com/piotrmurach/tty) toolkit.
17
20
 
18
21
  ## Installation
19
22
 
@@ -58,7 +61,7 @@ puts color?
58
61
 
59
62
  ## Command line tool
60
63
 
61
- [tty-color-cli](https://github.com/peter-murach/tty-color-cli) is a command line tool for the **TTY::Color**.
64
+ [tty-color-cli](https://github.com/piotrmurach/tty-color-cli) is a command line tool for the **TTY::Color**.
62
65
 
63
66
  To check if terminal supports colors do:
64
67
 
@@ -74,7 +77,7 @@ color -m
74
77
 
75
78
  ## Contributing
76
79
 
77
- 1. Fork it ( https://github.com/peter-murach/tty-color/fork )
80
+ 1. Fork it ( https://github.com/piotrmurach/tty-color/fork )
78
81
  2. Create your feature branch (`git checkout -b my-new-feature`)
79
82
  3. Commit your changes (`git commit -am 'Add some feature'`)
80
83
  4. Push to the branch (`git push origin my-new-feature`)
@@ -0,0 +1,23 @@
1
+ ---
2
+ install:
3
+ - SET PATH=C:\Ruby%ruby_version%\bin;%PATH%
4
+ - ruby --version
5
+ - gem --version
6
+ - bundle install
7
+ build: off
8
+ test_script:
9
+ - bundle exec rake ci
10
+ environment:
11
+ matrix:
12
+ - ruby_version: "193"
13
+ - ruby_version: "200"
14
+ - ruby_version: "200-x64"
15
+ - ruby_version: "21"
16
+ - ruby_version: "21-x64"
17
+ - ruby_version: "22"
18
+ - ruby_version: "22-x64"
19
+ - ruby_version: "23"
20
+ - ruby_version: "23-x64"
21
+ matrix:
22
+ allow_failures:
23
+ - ruby_version: "193"
@@ -47,5 +47,23 @@ module TTY
47
47
  def tty?
48
48
  output.respond_to?(:tty?) && output.tty?
49
49
  end
50
+
51
+ # Check if command can be run
52
+ #
53
+ # @return [Boolean]
54
+ #
55
+ # @api public
56
+ def command?(cmd)
57
+ !!system(cmd, out: File::NULL, err: File::NULL)
58
+ end
59
+
60
+ # Check if Windowz
61
+ #
62
+ # @return [Boolean]
63
+ #
64
+ # @api public
65
+ def windows?
66
+ File::ALT_SEPARATOR == "\\"
67
+ end
50
68
  end # Color
51
69
  end # TTY
@@ -56,7 +56,7 @@ module TTY
56
56
  when TERM_52 then 52
57
57
  when TERM_16 then 16
58
58
  when TERM_8 then 8
59
- when /dummy/ then 0
59
+ when /dummy/ then 0
60
60
  else NoValue
61
61
  end
62
62
  end
@@ -67,6 +67,9 @@ module TTY
67
67
  #
68
68
  # @api private
69
69
  def from_tput
70
+ if !TTY::Color.command?("tput colors")
71
+ return NoValue
72
+ end
70
73
  colors = `tput colors 2>/dev/null`.to_i
71
74
  colors >= 8 ? colors : NoValue
72
75
  rescue Errno::ENOENT
@@ -44,7 +44,11 @@ module TTY
44
44
  #
45
45
  # @api private
46
46
  def from_tput
47
- `tput colors 2>/dev/null`.to_i > 2
47
+ cmd = %q(tput colors 2>/dev/null)
48
+ if !TTY::Color.command?("tput colors")
49
+ return NoValue
50
+ end
51
+ `#{cmd}`.to_i > 2
48
52
  rescue Errno::ENOENT
49
53
  NoValue
50
54
  end
@@ -62,6 +66,7 @@ module TTY
62
66
  #
63
67
  # @api private
64
68
  def from_curses(curses_class = nil)
69
+ return NoValue if TTY::Color.windows?
65
70
  require 'curses'
66
71
 
67
72
  if defined?(Curses)
@@ -69,10 +74,9 @@ module TTY
69
74
  curses_class.init_screen
70
75
  has_color = curses_class.has_colors?
71
76
  curses_class.close_screen
72
- has_color
73
- else
74
- NoValue
77
+ return has_color
75
78
  end
79
+ NoValue
76
80
  rescue LoadError
77
81
  warn 'no native curses support' if @verbose
78
82
  NoValue
@@ -2,6 +2,6 @@
2
2
 
3
3
  module TTY
4
4
  module Color
5
- VERSION = "0.3.0"
5
+ VERSION = "0.4.0"
6
6
  end # Color
7
7
  end # TTY
@@ -91,4 +91,13 @@ RSpec.describe TTY::Color::Mode, 'detecting mode' do
91
91
  expect(mode.from_term).to eq(TTY::Color::NoValue)
92
92
  end
93
93
  end
94
+
95
+ context '#from_tput' do
96
+ it "fails to find tput utilty" do
97
+ mode = described_class.new({})
98
+ cmd = "tput colors"
99
+ allow(TTY::Color).to receive(:command?).with(cmd).and_return(nil)
100
+ expect(mode.from_tput).to eq(TTY::Color::NoValue)
101
+ end
102
+ end
94
103
  end
@@ -36,8 +36,8 @@ RSpec.describe TTY::Color::Support, '#supports?' do
36
36
  context '#from_curses' do
37
37
  it "fails to load curses for color support" do
38
38
  support = described_class.new({})
39
- allow(support).to receive(:require).with('curses').
40
- and_raise(LoadError)
39
+ allow(TTY::Color).to receive(:windows?).and_return(false)
40
+ allow(support).to receive(:require).with('curses').and_raise(LoadError)
41
41
  allow(support).to receive(:warn)
42
42
 
43
43
  expect(support.from_curses).to eq(TTY::Color::NoValue)
@@ -46,6 +46,7 @@ RSpec.describe TTY::Color::Support, '#supports?' do
46
46
 
47
47
  it "fails to find Curses namespace" do
48
48
  support = described_class.new({})
49
+ allow(TTY::Color).to receive(:windows?).and_return(false)
49
50
  allow(support).to receive(:require).with('curses')
50
51
 
51
52
  expect(support.from_curses).to eq(TTY::Color::NoValue)
@@ -53,8 +54,8 @@ RSpec.describe TTY::Color::Support, '#supports?' do
53
54
 
54
55
  it "sets verbose mode on" do
55
56
  support = described_class.new({}, verbose: true)
56
- allow(support).to receive(:require).with('curses').
57
- and_raise(LoadError)
57
+ allow(TTY::Color).to receive(:windows?).and_return(false)
58
+ allow(support).to receive(:require).with('curses').and_raise(LoadError)
58
59
  allow(support).to receive(:warn)
59
60
 
60
61
  support.from_curses
@@ -64,6 +65,7 @@ RSpec.describe TTY::Color::Support, '#supports?' do
64
65
 
65
66
  it "loads curses for color support" do
66
67
  support = described_class.new({})
68
+ allow(TTY::Color).to receive(:windows?).and_return(false)
67
69
  allow(support).to receive(:require).with('curses').and_return(true)
68
70
  stub_const("Curses", Object.new)
69
71
  curses = double(:curses)
@@ -74,6 +76,12 @@ RSpec.describe TTY::Color::Support, '#supports?' do
74
76
  expect(support.from_curses(curses)).to eql(true)
75
77
  expect(curses).to have_received(:has_colors?)
76
78
  end
79
+
80
+ it "doesn't check on windows" do
81
+ support = described_class.new({})
82
+ allow(TTY::Color).to receive(:windows?).and_return(true)
83
+ expect(support.from_curses).to eq(TTY::Color::NoValue)
84
+ end
77
85
  end
78
86
 
79
87
  context '#form_term' do
@@ -93,6 +101,15 @@ RSpec.describe TTY::Color::Support, '#supports?' do
93
101
  end
94
102
  end
95
103
 
104
+ context '#from_tput' do
105
+ it "fails to find tput utilty" do
106
+ support = described_class.new({})
107
+ cmd = "tput colors"
108
+ allow(TTY::Color).to receive(:command?).with(cmd).and_return(nil)
109
+ expect(support.from_tput).to eq(TTY::Color::NoValue)
110
+ end
111
+ end
112
+
96
113
  context '#from_env' do
97
114
  it "finds color support in colorterm variable" do
98
115
  support = described_class.new('COLORTERM' => true)
@@ -8,3 +8,4 @@ task :console do
8
8
  ARGV.clear
9
9
  IRB.start
10
10
  end
11
+ task c: :console
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = [""]
11
11
  spec.summary = %q{Terminal color capabilities detection}
12
12
  spec.description = %q{Terminal color capabilities detection}
13
- spec.homepage = "http://peter-murach.github.io/tty"
13
+ spec.homepage = "http://piotrmurach.github.io/tty"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0")
metadata CHANGED
@@ -1,47 +1,47 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tty-color
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Murach
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-13 00:00:00.000000000 Z
11
+ date: 2016-12-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 1.5.0
20
- - - <
20
+ - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: '2.0'
23
23
  type: :development
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - '>='
27
+ - - ">="
28
28
  - !ruby/object:Gem::Version
29
29
  version: 1.5.0
30
- - - <
30
+ - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '2.0'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: rake
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - ~>
37
+ - - "~>"
38
38
  - !ruby/object:Gem::Version
39
39
  version: '10.0'
40
40
  type: :development
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - ~>
44
+ - - "~>"
45
45
  - !ruby/object:Gem::Version
46
46
  version: '10.0'
47
47
  description: Terminal color capabilities detection
@@ -51,14 +51,15 @@ executables: []
51
51
  extensions: []
52
52
  extra_rdoc_files: []
53
53
  files:
54
- - .gitignore
55
- - .rspec
56
- - .travis.yml
54
+ - ".gitignore"
55
+ - ".rspec"
56
+ - ".travis.yml"
57
57
  - CHANGELOG.md
58
58
  - Gemfile
59
59
  - LICENSE.txt
60
60
  - README.md
61
61
  - Rakefile
62
+ - appveyor.yml
62
63
  - lib/tty-color.rb
63
64
  - lib/tty/color.rb
64
65
  - lib/tty/color/mode.rb
@@ -72,7 +73,7 @@ files:
72
73
  - tasks/coverage.rake
73
74
  - tasks/spec.rake
74
75
  - tty-color.gemspec
75
- homepage: http://peter-murach.github.io/tty
76
+ homepage: http://piotrmurach.github.io/tty
76
77
  licenses:
77
78
  - MIT
78
79
  metadata: {}
@@ -82,17 +83,17 @@ require_paths:
82
83
  - lib
83
84
  required_ruby_version: !ruby/object:Gem::Requirement
84
85
  requirements:
85
- - - '>='
86
+ - - ">="
86
87
  - !ruby/object:Gem::Version
87
88
  version: '0'
88
89
  required_rubygems_version: !ruby/object:Gem::Requirement
89
90
  requirements:
90
- - - '>='
91
+ - - ">="
91
92
  - !ruby/object:Gem::Version
92
93
  version: '0'
93
94
  requirements: []
94
95
  rubyforge_project:
95
- rubygems_version: 2.0.3
96
+ rubygems_version: 2.5.1
96
97
  signing_key:
97
98
  specification_version: 4
98
99
  summary: Terminal color capabilities detection