tty-color 0.4.3 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 64773204a9d6a5bb773df92a9ff890f9bc9e83ee3553fd75084676f42a5e421a
4
- data.tar.gz: f70c529028b7b01adc89521c8935f7f9e9280c3c9a974efdcb8b4ccf9ee7c49a
3
+ metadata.gz: 87b27bf2145b787f7a1b01a6f858f622a57b9c0e5414ca86362838fb54d2a4b0
4
+ data.tar.gz: 2f042b82d11b6077b6bd6d77f5a3acc119ce0a2d393098d5af6c820b7bea5128
5
5
  SHA512:
6
- metadata.gz: 9712ef7a8244e191667083ec9a23fb17bca5f17608f5d558f4008c1327c4bad933b3a8926e30764242ea7921f5c6e3bb58a0f40f67b273ec2d041272d38dc6e1
7
- data.tar.gz: 5b66fb35bd7e8df728a1f06f5809c0fdfd196a969d0f351e5ac5999224fd637fb3dae8f6eacdfd6479447f404bebd37637dfe786a1a4b905c8eaa3cfcc328ec6
6
+ metadata.gz: 58caee27992f3daccad7152795cec0edbb963c0ad0b7475d675a3923e0a4c37f2274af7b3318e0f6e08ca55d4cc6b724735526c6c4d1dd82825c359f86bec378
7
+ data.tar.gz: 88b3ba6fd56c5eb91e040ddb8fb9db170ea41b000544a9e84d1d3909c6a2b8011bbf5baa3b5be64bf77f61061eaaf9229478d23e50bad463e78e291e92288995
@@ -1,5 +1,11 @@
1
1
  # Change log
2
2
 
3
+ ## [v0.5.0] - 2019-05-29
4
+
5
+ ### Changed
6
+ * Change gemspec to load files without git
7
+ * Change to limit to Ruby >= 2.0.0
8
+
3
9
  ## [v0.4.3] - 2018-07-11
4
10
 
5
11
  ### Changed
@@ -53,10 +59,11 @@
53
59
 
54
60
  * Initial implementation and release
55
61
 
56
- [v0.4.3]: https://github.com/peter-murach/tty-color/compare/v0.4.2...v0.4.3
57
- [v0.4.2]: https://github.com/peter-murach/tty-color/compare/v0.4.1...v0.4.2
58
- [v0.4.1]: https://github.com/peter-murach/tty-color/compare/v0.4.0...v0.4.1
59
- [v0.4.0]: https://github.com/peter-murach/tty-color/compare/v0.3.0...v0.4.0
60
- [v0.3.0]: https://github.com/peter-murach/tty-color/compare/v0.2.0...v0.3.0
61
- [v0.2.0]: https://github.com/peter-murach/tty-color/compare/v0.1.0...v0.2.0
62
- [v0.1.0]: https://github.com/peter-murach/tty-color/compare/v0.1.0
62
+ [v0.5.0]: https://github.com/piotrmurach/tty-color/compare/v0.4.3...v0.5.0
63
+ [v0.4.3]: https://github.com/piotrmurach/tty-color/compare/v0.4.2...v0.4.3
64
+ [v0.4.2]: https://github.com/piotrmurach/tty-color/compare/v0.4.1...v0.4.2
65
+ [v0.4.1]: https://github.com/piotrmurach/tty-color/compare/v0.4.0...v0.4.1
66
+ [v0.4.0]: https://github.com/piotrmurach/tty-color/compare/v0.3.0...v0.4.0
67
+ [v0.3.0]: https://github.com/piotrmurach/tty-color/compare/v0.2.0...v0.3.0
68
+ [v0.2.0]: https://github.com/piotrmurach/tty-color/compare/v0.1.0...v0.2.0
69
+ [v0.1.0]: https://github.com/piotrmurach/tty-color/compare/v0.1.0
data/README.md CHANGED
@@ -1,3 +1,7 @@
1
+ <div align="center">
2
+ <a href="https://piotrmurach.github.io/tty" target="_blank"><img width="130" src="https://cdn.rawgit.com/piotrmurach/tty/master/images/tty.png" alt="tty logo" /></a>
3
+ </div>
4
+
1
5
  # TTY::Color [![Gitter](https://badges.gitter.im/Join%20Chat.svg)][gitter]
2
6
 
3
7
  [![Gem Version](https://badge.fury.io/rb/tty-color.svg)][gem]
@@ -40,8 +44,8 @@ Or install it yourself as:
40
44
  **TTY::Color** allows you to check if terminal supports color:
41
45
 
42
46
  ```ruby
43
- TTY::Color.color? # => true
44
- TTY::Color.supports? # => true
47
+ TTY::Color.color? # => true
48
+ TTY::Color.support? # => true
45
49
  ```
46
50
 
47
51
  Also you can get the number of colors supported by the terminal:
@@ -70,7 +74,7 @@ To check if terminal supports colors do:
70
74
  color -s
71
75
  ```
72
76
 
73
- and to check color mode:
77
+ And to check color mode:
74
78
 
75
79
  ```bash
76
80
  color -m
@@ -78,6 +82,8 @@ color -m
78
82
 
79
83
  ## Contributing
80
84
 
85
+ Bug reports and pull requests are welcome on GitHub at https://github.com/piotrmurach/tty-color. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
86
+
81
87
  1. Fork it ( https://github.com/piotrmurach/tty-color/fork )
82
88
  2. Create your feature branch (`git checkout -b my-new-feature`)
83
89
  3. Commit your changes (`git commit -am 'Add some feature'`)
@@ -86,4 +92,4 @@ color -m
86
92
 
87
93
  ## Copyright
88
94
 
89
- Copyright (c) 2016-2018 Piotr Murach. See LICENSE for further details.
95
+ Copyright (c) 2016 Piotr Murach. See LICENSE for further details.
data/Rakefile CHANGED
@@ -1,8 +1,8 @@
1
- # encoding: utf-8
2
-
3
1
  require "bundler/gem_tasks"
4
2
 
5
3
  FileList['tasks/**/*.rake'].each(&method(:import))
6
4
 
7
5
  desc 'Run all specs'
8
6
  task ci: %w[ spec ]
7
+
8
+ task default: :spec
@@ -24,11 +24,12 @@ module TTY
24
24
  # @return [Boolean]
25
25
  #
26
26
  # @api public
27
- def supports?
28
- Support.new(ENV, verbose: verbose).supports?
27
+ def support?
28
+ Support.new(ENV, verbose: verbose).support?
29
29
  end
30
- alias color? supports?
31
- alias supports_color? supports?
30
+ alias supports? support?
31
+ alias color? support?
32
+ alias supports_color? support?
32
33
 
33
34
  # Check how many colors this terminal supports
34
35
  #
@@ -21,6 +21,8 @@ module TTY
21
21
 
22
22
  TERM_8 = /vt100|xnuppc|wy350/x
23
23
 
24
+ METHODS = %w[from_term from_tput].freeze
25
+
24
26
  def initialize(env)
25
27
  @env = env
26
28
  end
@@ -35,7 +37,7 @@ module TTY
35
37
  return 0 unless TTY::Color.tty?
36
38
 
37
39
  value = 8
38
- %w(from_term from_tput).each do |from_check|
40
+ METHODS.each do |from_check|
39
41
  break if (value = public_send(from_check)) != NoValue
40
42
  end
41
43
  return 8 if value == NoValue
@@ -3,7 +3,8 @@
3
3
  module TTY
4
4
  module Color
5
5
  class Support
6
- SOURCES = %w(from_term from_tput from_env from_curses).freeze
6
+ SOURCES = %w[from_term from_tput from_env from_curses].freeze
7
+ ENV_VARS = %w[COLORTERM ANSICON].freeze
7
8
 
8
9
  # Initialize a color support
9
10
  # @api public
@@ -18,15 +19,14 @@ module TTY
18
19
  # true when terminal supports color, false otherwise
19
20
  #
20
21
  # @api public
21
- def supports?
22
+ def support?
22
23
  return false unless TTY::Color.tty?
23
24
 
24
25
  value = false
25
26
  SOURCES.each do |from_check|
26
27
  break if (value = public_send(from_check)) != NoValue
27
28
  end
28
- return false if value == NoValue
29
- value
29
+ value == NoValue ? false : value
30
30
  end
31
31
 
32
32
  # Inspect environment $TERM variable for color support
@@ -44,10 +44,9 @@ module TTY
44
44
  #
45
45
  # @api private
46
46
  def from_tput
47
+ return NoValue if !TTY::Color.command?("tput colors")
48
+
47
49
  cmd = %q(tput colors 2>/dev/null)
48
- if !TTY::Color.command?("tput colors")
49
- return NoValue
50
- end
51
50
  `#{cmd}`.to_i > 2
52
51
  rescue Errno::ENOENT
53
52
  NoValue
@@ -57,7 +56,7 @@ module TTY
57
56
  #
58
57
  # @api private
59
58
  def from_env
60
- ['COLORTERM', 'ANSICON'].any? { |key| @env.key?(key) } || NoValue
59
+ ENV_VARS.any? { |key| @env.key?(key) } || NoValue
61
60
  end
62
61
 
63
62
  # Attempt to load curses to check color support
@@ -67,6 +66,7 @@ module TTY
67
66
  # @api private
68
67
  def from_curses(curses_class = nil)
69
68
  return NoValue if TTY::Color.windows?
69
+
70
70
  require 'curses'
71
71
 
72
72
  if defined?(Curses)
@@ -1,7 +1,7 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  module TTY
4
4
  module Color
5
- VERSION = "0.4.3"
5
+ VERSION = '0.5.0'
6
6
  end # Color
7
7
  end # TTY
@@ -1,13 +1,13 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
- if RUBY_VERSION > '1.9' and (ENV['COVERAGE'] || ENV['TRAVIS'])
3
+ if ENV['COVERAGE'] || ENV['TRAVIS']
4
4
  require 'simplecov'
5
5
  require 'coveralls'
6
6
 
7
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
7
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
8
8
  SimpleCov::Formatter::HTMLFormatter,
9
9
  Coveralls::SimpleCov::Formatter
10
- ]
10
+ ])
11
11
 
12
12
  SimpleCov.start do
13
13
  command_name 'spec'
@@ -1,6 +1,14 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  RSpec.describe TTY::Color, 'integratation' do
4
+ it "defaults output to stderr" do
5
+ expect(TTY::Color.output).to eq($stderr)
6
+ end
7
+
8
+ it "defaults verbose mode to false" do
9
+ expect(TTY::Color.verbose).to eq(false)
10
+ end
11
+
4
12
  it "accesses color mode" do
5
13
  mode_instance = spy(:mode)
6
14
  allow(TTY::Color::Mode).to receive(:new).and_return(mode_instance)
@@ -14,8 +22,8 @@ RSpec.describe TTY::Color, 'integratation' do
14
22
  support_instance = spy(:support)
15
23
  allow(TTY::Color::Support).to receive(:new).and_return(support_instance)
16
24
 
17
- described_class.supports?
25
+ described_class.support?
18
26
 
19
- expect(support_instance).to have_received(:supports?)
27
+ expect(support_instance).to have_received(:support?)
20
28
  end
21
29
  end
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  RSpec.describe TTY::Color::Mode, 'detecting mode' do
4
4
  it "isn't terminal" do
@@ -1,10 +1,10 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
- RSpec.describe TTY::Color::Support, '#supports?' do
3
+ RSpec.describe TTY::Color::Support, '#support?' do
4
4
  it "doesn't check color support for non tty terminal" do
5
5
  support = described_class.new({})
6
6
  allow(TTY::Color).to receive(:tty?).and_return(false)
7
- expect(support.supports?).to eq(false)
7
+ expect(support.support?).to eq(false)
8
8
  end
9
9
 
10
10
  it "fails to find out color support" do
@@ -16,7 +16,7 @@ RSpec.describe TTY::Color::Support, '#supports?' do
16
16
  allow(support).to receive(:from_term).and_return(TTY::Color::NoValue)
17
17
  allow(support).to receive(:from_env).and_return(TTY::Color::NoValue)
18
18
 
19
- expect(support.supports?).to eq(false)
19
+ expect(support.support?).to eq(false)
20
20
 
21
21
  expect(support).to have_received(:from_term).ordered
22
22
  expect(support).to have_received(:from_tput).ordered
@@ -29,7 +29,7 @@ RSpec.describe TTY::Color::Support, '#supports?' do
29
29
  allow(TTY::Color).to receive(:tty?).and_return(true)
30
30
  allow(support).to receive(:from_tput)
31
31
 
32
- expect(support.supports?).to eq(true)
32
+ expect(support.support?).to eq(true)
33
33
  expect(support).to_not have_received(:from_tput)
34
34
  end
35
35
 
@@ -5,19 +5,23 @@ require 'tty/color/version'
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'tty-color'
7
7
  spec.version = TTY::Color::VERSION
8
- spec.authors = ['Piotr Murach']
9
- spec.email = [""]
8
+ spec.authors = ["Piotr Murach"]
9
+ spec.email = ["me@piotrmurach.com"]
10
10
  spec.summary = %q{Terminal color capabilities detection}
11
11
  spec.description = %q{Terminal color capabilities detection}
12
12
  spec.homepage = "http://piotrmurach.github.io/tty"
13
13
  spec.license = "MIT"
14
14
 
15
- spec.files = `git ls-files -z`.split("\x0")
15
+ spec.files = Dir['{lib,spec}/**/*.rb']
16
+ spec.files += Dir['tasks/*', 'tty-color.gemspec']
17
+ spec.files += Dir['README.md', 'CHANGELOG.md', 'LICENSE.txt', 'Rakefile']
16
18
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
19
  spec.test_files = spec.files.grep(%r{^spec})
18
20
  spec.require_paths = ["lib"]
19
21
 
20
- spec.add_development_dependency 'bundler', '>= 1.5.0', '< 2.0'
22
+ spec.required_ruby_version = '>= 2.0.0'
23
+
24
+ spec.add_development_dependency 'bundler', '>= 1.5.0'
21
25
  spec.add_development_dependency 'rspec', '~> 3.1'
22
26
  spec.add_development_dependency 'rake'
23
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tty-color
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.5.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: 2018-07-11 00:00:00.000000000 Z
11
+ date: 2019-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -17,9 +17,6 @@ dependencies:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 1.5.0
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: '2.0'
23
20
  type: :development
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
@@ -27,9 +24,6 @@ dependencies:
27
24
  - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: 1.5.0
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: '2.0'
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: rspec
35
29
  requirement: !ruby/object:Gem::Requirement
@@ -60,20 +54,15 @@ dependencies:
60
54
  version: '0'
61
55
  description: Terminal color capabilities detection
62
56
  email:
63
- - ''
57
+ - me@piotrmurach.com
64
58
  executables: []
65
59
  extensions: []
66
60
  extra_rdoc_files: []
67
61
  files:
68
- - ".gitignore"
69
- - ".rspec"
70
- - ".travis.yml"
71
62
  - CHANGELOG.md
72
- - Gemfile
73
63
  - LICENSE.txt
74
64
  - README.md
75
65
  - Rakefile
76
- - appveyor.yml
77
66
  - lib/tty-color.rb
78
67
  - lib/tty/color.rb
79
68
  - lib/tty/color/mode.rb
@@ -82,7 +71,7 @@ files:
82
71
  - spec/spec_helper.rb
83
72
  - spec/unit/color_spec.rb
84
73
  - spec/unit/mode_spec.rb
85
- - spec/unit/supports_spec.rb
74
+ - spec/unit/support_spec.rb
86
75
  - tasks/console.rake
87
76
  - tasks/coverage.rake
88
77
  - tasks/spec.rake
@@ -99,15 +88,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
99
88
  requirements:
100
89
  - - ">="
101
90
  - !ruby/object:Gem::Version
102
- version: '0'
91
+ version: 2.0.0
103
92
  required_rubygems_version: !ruby/object:Gem::Requirement
104
93
  requirements:
105
94
  - - ">="
106
95
  - !ruby/object:Gem::Version
107
96
  version: '0'
108
97
  requirements: []
109
- rubyforge_project:
110
- rubygems_version: 2.7.3
98
+ rubygems_version: 3.0.3
111
99
  signing_key:
112
100
  specification_version: 4
113
101
  summary: Terminal color capabilities detection
@@ -115,4 +103,4 @@ test_files:
115
103
  - spec/spec_helper.rb
116
104
  - spec/unit/color_spec.rb
117
105
  - spec/unit/mode_spec.rb
118
- - spec/unit/supports_spec.rb
106
+ - spec/unit/support_spec.rb
data/.gitignore DELETED
@@ -1,14 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
- *.bundle
11
- *.so
12
- *.o
13
- *.a
14
- mkmf.log
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --color
2
- --require spec_helper
3
- --warnings
@@ -1,24 +0,0 @@
1
- ---
2
- language: ruby
3
- sudo: false
4
- cache: bundler
5
- script: "bundle exec rake ci"
6
- rvm:
7
- - 2.0.0
8
- - 2.1.10
9
- - 2.2.6
10
- - 2.3.3
11
- - 2.4.4
12
- - 2.5.1
13
- - ruby-head
14
- - jruby-9.1.5.0
15
- - jruby-head
16
- matrix:
17
- allow_failures:
18
- - rvm: ruby-head
19
- - rvm: jruby-head
20
- fast_finish: true
21
- branches:
22
- only: master
23
- notifications:
24
- email: false
data/Gemfile DELETED
@@ -1,13 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec
4
-
5
- group :development do
6
- gem 'benchmark-ips', '~> 2.0.0'
7
- end
8
-
9
- group :metrics do
10
- gem 'coveralls', '~> 0.8.2'
11
- gem 'simplecov', '~> 0.10.0'
12
- gem 'yardstick', '~> 0.9.9'
13
- end
@@ -1,23 +0,0 @@
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: "200"
13
- - ruby_version: "200-x64"
14
- - ruby_version: "21"
15
- - ruby_version: "21-x64"
16
- - ruby_version: "22"
17
- - ruby_version: "22-x64"
18
- - ruby_version: "23"
19
- - ruby_version: "23-x64"
20
- - ruby_version: "24"
21
- - ruby_version: "24-x64"
22
- - ruby_version: "25"
23
- - ruby_version: "25-x64"