tty-color 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f283dfbe29783ae7e0c276ab7c0b826bb3a3597a
4
+ data.tar.gz: cd78c6a3723d0faa4bb9ca4e9d079f53ef6c495d
5
+ SHA512:
6
+ metadata.gz: 8ca5f9b0fb1a004ff63783bb39b39c8f4eb45323f2a1be4eafb01c747c3b35254ae1fac793c0d629503e246c3d1a8a54024fecf7bcabc19bd8fba5b96f4c5e7d
7
+ data.tar.gz: df3075abac7aa41d018fee562276a888a1dd346d8dee6b6c4df62cdcfbca0e56dc44ade95e09fe6a27e081cd743f59bd69c000901b1db7ad38fdfeb0b9cf389a
data/.gitignore ADDED
@@ -0,0 +1,14 @@
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 ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --require spec_helper
3
+ --warnings
data/.travis.yml ADDED
@@ -0,0 +1,23 @@
1
+ ---
2
+ language: ruby
3
+ sudo: false
4
+ cache: bundler
5
+ bundler_args: --without yard benchmarks
6
+ script: "bundle exec rake ci"
7
+ rvm:
8
+ - 1.9.3
9
+ - 2.0
10
+ - 2.1
11
+ - 2.2
12
+ - rbx-2
13
+ - jruby-19mode
14
+ - jruby
15
+ - jruby-head
16
+ - ruby-head
17
+ matrix:
18
+ allow_failures:
19
+ - rvm: ruby-head
20
+ - rvm: jruby-head
21
+ fast_finish: true
22
+ branches:
23
+ only: master
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # Change log
2
+
3
+ ## [v0.1.0] - 2016-01-02
4
+
5
+ * Initial implementation and release
6
+
7
+ [v0.1.0]: https://github.com/peter-murach/tty-color/compare/v0.1.0
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ gem 'rspec', '~> 3.4.0'
7
+ gem 'yard', '~> 0.8.7'
8
+ gem 'benchmark-ips', '~> 2.0.0'
9
+ end
10
+
11
+ group :metrics do
12
+ gem 'coveralls', '~> 0.8.2'
13
+ gem 'simplecov', '~> 0.10.0'
14
+ gem 'yardstick', '~> 0.9.9'
15
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2016 Piotr Murach
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,86 @@
1
+ # TTY::Color
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]
7
+
8
+ [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
13
+
14
+ > Terminal color capabilities detection.
15
+
16
+ **TTY::Color** provides independent color support detection component for [TTY](https://github.com/peter-murach/tty) toolkit.
17
+
18
+ ## Installation
19
+
20
+ Add this line to your application's Gemfile:
21
+
22
+ ```ruby
23
+ gem 'tty-color'
24
+ ```
25
+
26
+ And then execute:
27
+
28
+ $ bundle
29
+
30
+ Or install it yourself as:
31
+
32
+ $ gem install tty-color
33
+
34
+ ## Usage
35
+
36
+ **TTY::Color** allows you to check if terminal supports color:
37
+
38
+ ```ruby
39
+ TTY::Color.color? # => true
40
+ TTY::Color.supports? # => true
41
+ ```
42
+
43
+ Also you can get the number of colors supported by the terminal:
44
+
45
+ ```ruby
46
+ TTY::Color.mode # => 64
47
+ ```
48
+
49
+ **TTY::Color** is just a module hence you can include it into your scripts directly:
50
+
51
+ ```ruby
52
+ #!/usr/bin/env ruby
53
+
54
+ include TTY::Color
55
+
56
+ puts color?
57
+ ```
58
+
59
+ ## Command line tool
60
+
61
+ **TTY::Color** comes with a command line tool to detect color support in terminal. The results are redirected to standard output.
62
+
63
+ ```bash
64
+ color
65
+ color -s
66
+ color --support
67
+ ```
68
+
69
+ and to check number of colors:
70
+
71
+ ```bash
72
+ color -m
73
+ color --mode
74
+ ```
75
+
76
+ ## Contributing
77
+
78
+ 1. Fork it ( https://github.com/peter-murach/tty-color/fork )
79
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
80
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
81
+ 4. Push to the branch (`git push origin my-new-feature`)
82
+ 5. Create a new Pull Request
83
+
84
+ ## Copyright
85
+
86
+ Copyright (c) 2016 Piotr Murach. See LICENSE for further details.
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # encoding: utf-8
2
+
3
+ require "bundler/gem_tasks"
4
+
5
+ FileList['tasks/**/*.rake'].each(&method(:import))
6
+
7
+ desc 'Run all specs'
8
+ task ci: %w[ spec ]
data/bin/color ADDED
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ Signal.trap("INT") { exit 1 }
4
+
5
+ lib_dir = File.expand_path("../../lib", __FILE__)
6
+ $LOAD_PATH.unshift(lib_dir) if File.directory?(lib_dir)
7
+
8
+ require 'optparse'
9
+ require 'tty-color'
10
+
11
+ options = {}
12
+
13
+ parser = OptionParser.new do |opts|
14
+ opts.on('-s', '--support', 'Check if terminal supports colors') do
15
+ options[:color] = true
16
+ end
17
+
18
+ opts.on('-m', '--mode', 'Supported colors mode') do
19
+ options[:mode] = true
20
+ end
21
+
22
+ options[:verbose] = false
23
+ opts.on('-v', '--verbose', 'Output debug information' ) do
24
+ options[:verbose] = true
25
+ end
26
+
27
+ opts.on('-h', '--help', 'Display help' ) do
28
+ puts opts
29
+ exit
30
+ end
31
+ end
32
+
33
+ parser.parse!
34
+
35
+ TTY::Color.verbose = options[:verbose]
36
+
37
+ if options[:mode]
38
+ puts TTY::Color.mode
39
+ else
40
+ puts TTY::Color.color?
41
+ end
42
+
@@ -0,0 +1,77 @@
1
+ # encoding: utf-8
2
+
3
+ module TTY
4
+ module Color
5
+ class Mode
6
+ TERM_256 = /iTerm.app/x
7
+
8
+ TERM_64 = /^(hpterm-color|wy370|wy370-105k|wy370-EPC|wy370-nk|
9
+ wy370-rv|wy370-tek|wy370-vb|wy370-w|wy370-wvb)$/x
10
+
11
+ TERM_52 = /^(dg+ccc|dgunix+ccc|d430.*?[\-\+](dg|unix).*?[\-\+]ccc)$/x
12
+
13
+ TERM_16 = /^(amiga-vnc|d430-dg|d430-unix|d430-unix-25|d430-unix-s|
14
+ d430-unix-sr|d430-unix-w|d430c-dg|d430c-unix|d430c-unix-25|
15
+ d430c-unix-s|d430c-unix-sr|d430c-unix-w|d470|d470-7b|d470-dg|
16
+ d470c|d470c-7b|d470c-dg|dg+color|dg\+fixed|dgunix\+fixed|
17
+ dgmode\+color|hp\+color|ncr260wy325pp|ncr260wy325wpp|
18
+ ncr260wy350pp|ncr260wy350wpp|nsterm|nsterm-c|nsterm-c-acs|
19
+ nsterm-c-s|nsterm-c-s-7|nsterm-c-s-acs|nsterm\+c|
20
+ nsterm-7-c|nsterm-bce)$/x
21
+
22
+ TERM_8 = /vt100|xnuppc|wy350/x
23
+
24
+ def initialize(env)
25
+ @env = env
26
+ end
27
+
28
+ # Detect supported colors
29
+ #
30
+ # @return [Integer]
31
+ # out of 0, 8, 16, 52, 64, 256
32
+ #
33
+ # @api public
34
+ def mode
35
+ return 0 unless TTY::Color.tty?
36
+
37
+ value = 8
38
+ %w(from_tput from_term).each do |from_check|
39
+ break if (value = public_send(from_check)) != NoValue
40
+ end
41
+ return 8 if value == NoValue
42
+ value
43
+ end
44
+
45
+ # Check TERM environment for colors
46
+ #
47
+ # @return [NoValue, Integer]
48
+ #
49
+ # @api private
50
+ def from_term
51
+ case @env['TERM']
52
+ when /[\-\+](\d+)color/ then $1.to_i
53
+ when /[\-\+](\d+)bit/ then 2 ** $1.to_i
54
+ when TERM_256 then 256
55
+ when TERM_64 then 64
56
+ when TERM_52 then 52
57
+ when TERM_16 then 16
58
+ when TERM_8 then 8
59
+ when /dummy/ then 0
60
+ else NoValue
61
+ end
62
+ end
63
+
64
+ # Shell out to tput to check color support
65
+ #
66
+ # @return [NoValue, Integer]
67
+ #
68
+ # @api private
69
+ def from_tput
70
+ colors = %x(tput colors 2>/dev/null).to_i
71
+ colors >= 8 ? colors : NoValue
72
+ rescue Errno::ENOENT
73
+ NoValue
74
+ end
75
+ end # Mode
76
+ end # Color
77
+ end # TTY
@@ -0,0 +1,80 @@
1
+ # encoding: utf-8
2
+
3
+ module TTY
4
+ module Color
5
+ class Support
6
+ # Initialize a color support
7
+ # @api public
8
+ def initialize(env, options = {})
9
+ @env = env
10
+ @verbose = options.fetch(:verbose) { false }
11
+ end
12
+
13
+ # Detect if terminal supports color
14
+ #
15
+ # @return [Boolean]
16
+ # true when terminal supports color, false otherwise
17
+ #
18
+ # @api public
19
+ def supports?
20
+ return false unless TTY::Color.tty?
21
+
22
+ value = false
23
+ %w(from_curses from_tput from_term from_env).each do |from_check|
24
+ break if (value = public_send(from_check)) != NoValue
25
+ end
26
+ return false if value == NoValue
27
+ value
28
+ end
29
+
30
+ # Attempt to load curses to check color support
31
+ #
32
+ # @return [Boolean]
33
+ #
34
+ # @api private
35
+ def from_curses(curses_class = nil)
36
+ require 'curses'
37
+
38
+ if defined?(Curses)
39
+ curses_class ||= Curses
40
+ curses_class.init_screen
41
+ has_color = curses_class.has_colors?
42
+ curses_class.close_screen
43
+ has_color
44
+ else
45
+ NoValue
46
+ end
47
+ rescue LoadError
48
+ warn 'no native curses support' if @verbose
49
+ NoValue
50
+ end
51
+
52
+ # Shell out to tput to check color support
53
+ #
54
+ # @api private
55
+ def from_tput
56
+ %x(tput colors 2>/dev/null).to_i > 2
57
+ rescue Errno::ENOENT
58
+ NoValue
59
+ end
60
+
61
+ # Inspect environment $TERM variable for color support
62
+ #
63
+ # @api private
64
+ def from_term
65
+ case @env['TERM']
66
+ when 'dumb' then false
67
+ when /^screen|^xterm|^vt100|color|ansi|cygwin|linux/i then true
68
+ else NoValue
69
+ end
70
+ end
71
+
72
+ # Check if environment specifies color term
73
+ #
74
+ # @api private
75
+ def from_env
76
+ @env.include?('COLORTERM')
77
+ end
78
+ end # Support
79
+ end # Color
80
+ end # TTY
@@ -0,0 +1,7 @@
1
+ # encoding: utf-8
2
+
3
+ module TTY
4
+ module Color
5
+ VERSION = "0.1.0"
6
+ end # Color
7
+ end # TTY
data/lib/tty/color.rb ADDED
@@ -0,0 +1,42 @@
1
+ # encoding: utf-8
2
+
3
+ require 'tty/color/support'
4
+ require 'tty/color/mode'
5
+ require 'tty/color/version'
6
+
7
+ module TTY
8
+ # Responsible for checking terminal color support
9
+ #
10
+ # @api public
11
+ module Color
12
+ extend self
13
+
14
+ NoValue = Module.new
15
+
16
+ @verbose = false
17
+
18
+ @output = $stderr
19
+
20
+ attr_accessor :output, :verbose
21
+
22
+ def supports?
23
+ Support.new(ENV, verbose: verbose).supports?
24
+ end
25
+ alias_method :color?, :supports?
26
+ alias_method :supports_color?, :supports?
27
+
28
+ # Check how many colors this terminal supports
29
+ #
30
+ # @return [Integer]
31
+ #
32
+ # @api public
33
+ def mode
34
+ Mode.new(ENV).mode
35
+ end
36
+
37
+ # @api private
38
+ def tty?
39
+ output.tty?
40
+ end
41
+ end # Color
42
+ end # TTY
data/lib/tty-color.rb ADDED
@@ -0,0 +1,4 @@
1
+ # encoding: utf-8
2
+
3
+ require 'tty/color'
4
+ require "tty/color/version"
@@ -0,0 +1,45 @@
1
+ # encoding: utf-8
2
+
3
+ if RUBY_VERSION > '1.9' and (ENV['COVERAGE'] || ENV['TRAVIS'])
4
+ require 'simplecov'
5
+ require 'coveralls'
6
+
7
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
8
+ SimpleCov::Formatter::HTMLFormatter,
9
+ Coveralls::SimpleCov::Formatter
10
+ ]
11
+
12
+ SimpleCov.start do
13
+ command_name 'spec'
14
+ add_filter 'spec'
15
+ end
16
+ end
17
+
18
+ require 'tty-color'
19
+
20
+ RSpec.configure do |config|
21
+ config.expect_with :rspec do |expectations|
22
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
23
+ end
24
+
25
+ config.mock_with :rspec do |mocks|
26
+ mocks.verify_partial_doubles = true
27
+ end
28
+
29
+ # Limits the available syntax to the non-monkey patched syntax that is recommended.
30
+ config.disable_monkey_patching!
31
+
32
+ # This setting enables warnings. It's recommended, but in some cases may
33
+ # be too noisy due to issues in dependencies.
34
+ config.warnings = true
35
+
36
+ if config.files_to_run.one?
37
+ config.default_formatter = 'doc'
38
+ end
39
+
40
+ config.profile_examples = 2
41
+
42
+ config.order = :random
43
+
44
+ Kernel.srand config.seed
45
+ end
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+
3
+ RSpec.describe TTY::Color, 'integratation' do
4
+ it "accesses color mode" do
5
+ mode_instance = spy(:mode)
6
+ allow(TTY::Color::Mode).to receive(:new).and_return(mode_instance)
7
+
8
+ described_class.mode
9
+
10
+ expect(mode_instance).to have_received(:mode)
11
+ end
12
+
13
+ it "accesses color support" do
14
+ support_instance = spy(:support)
15
+ allow(TTY::Color::Support).to receive(:new).and_return(support_instance)
16
+
17
+ described_class.supports?
18
+
19
+ expect(support_instance).to have_received(:supports?)
20
+ end
21
+ end
@@ -0,0 +1,72 @@
1
+ # encoding: utf-8
2
+
3
+ RSpec.describe TTY::Color::Mode, 'detecting mode' do
4
+ it "isn't terminal" do
5
+ allow(TTY::Color).to receive(:tty?).and_return(false)
6
+ mode = described_class.new({})
7
+ expect(mode.mode).to eq(0)
8
+ end
9
+
10
+ it "cannot find from term, tput " do
11
+ allow(TTY::Color).to receive(:tty?).and_return(true)
12
+ mode = described_class.new({})
13
+ allow(mode).to receive(:from_term).and_return(TTY::Color::NoValue)
14
+ allow(mode).to receive(:from_tput).and_return(TTY::Color::NoValue)
15
+ expect(mode.mode).to eq(8)
16
+ end
17
+
18
+ it 'infers mode for xterm-256color' do
19
+ mode = described_class.new('TERM' => 'xterm-256color')
20
+ expect(mode.from_term).to eq(256)
21
+ end
22
+
23
+ it 'infers mode for iTerm.app' do
24
+ mode = described_class.new('TERM' => 'iTerm.app')
25
+ expect(mode.from_term).to eq(256)
26
+ end
27
+
28
+ it 'infers mode from terminal environment' do
29
+ mode = described_class.new('TERM' => 'amiga-8bit')
30
+ expect(mode.from_term).to eq(256)
31
+ end
32
+
33
+ it 'infers mode for wy730' do
34
+ mode = described_class.new('TERM' => 'wy370-105k')
35
+ expect(mode.from_term).to eq(64)
36
+ end
37
+
38
+ it 'infers mode for d430-unix-ccc' do
39
+ mode = described_class.new('TERM' => 'd430-unix-ccc')
40
+ expect(mode.from_term).to eq(52)
41
+ end
42
+
43
+ it 'infers mode for d430-unix-s-ccc' do
44
+ mode = described_class.new('TERM' => 'd430c-unix-s-ccc')
45
+ expect(mode.from_term).to eq(52)
46
+ end
47
+
48
+ it 'infers mode for nsterm-bce' do
49
+ mode = described_class.new('TERM' => 'nsterm-bce')
50
+ expect(mode.from_term).to eq(16)
51
+ end
52
+
53
+ it 'infers mode for d430-c' do
54
+ mode = described_class.new('TERM' => 'd430c-dg')
55
+ expect(mode.from_term).to eq(16)
56
+ end
57
+
58
+ it 'infers mode for d430-unix-w' do
59
+ mode = described_class.new('TERM' => 'd430-unix-w')
60
+ expect(mode.from_term).to eq(16)
61
+ end
62
+
63
+ it 'infers mode for vt100' do
64
+ mode = described_class.new('TERM' => 'konsole-vt100')
65
+ expect(mode.from_term).to eq(8)
66
+ end
67
+
68
+ it 'infers mode for xnuppc' do
69
+ mode = described_class.new('TERM' => 'xnuppc+basic')
70
+ expect(mode.from_term).to eq(8)
71
+ end
72
+ end
@@ -0,0 +1,70 @@
1
+ # encoding: utf-8
2
+
3
+ RSpec.describe TTY::Color::Support, '#supports?' do
4
+ it "doesn't check color support for non tty terminal" do
5
+ support = described_class.new({})
6
+ allow(TTY::Color).to receive(:tty?).and_return(false)
7
+ expect(support.supports?).to eq(false)
8
+ end
9
+
10
+ it "fails to find out color support" do
11
+ support = described_class.new({})
12
+ allow(TTY::Color).to receive(:tty?).and_return(true)
13
+
14
+ allow(support).to receive(:from_curses).and_return(TTY::Color::NoValue)
15
+ allow(support).to receive(:from_tput).and_return(TTY::Color::NoValue)
16
+ allow(support).to receive(:from_term).and_return(TTY::Color::NoValue)
17
+ allow(support).to receive(:from_env).and_return(TTY::Color::NoValue)
18
+
19
+ expect(support.supports?).to eq(false)
20
+ end
21
+
22
+ it "fails to load curses for color support" do
23
+ support = described_class.new({})
24
+ allow(support).to receive(:require).with('curses').
25
+ and_raise(LoadError)
26
+ allow(support).to receive(:warn)
27
+
28
+ expect(support.from_curses).to eq(TTY::Color::NoValue)
29
+ expect(support).to_not have_received(:warn)
30
+ end
31
+
32
+ it "sets verbose mode on" do
33
+ support = described_class.new({}, verbose: true)
34
+ allow(support).to receive(:require).with('curses').
35
+ and_raise(LoadError)
36
+ allow(support).to receive(:warn)
37
+
38
+ support.from_curses
39
+
40
+ expect(support).to have_received(:warn).with(/no native curses support/)
41
+ end
42
+
43
+ it "loads curses for color support" do
44
+ support = described_class.new({})
45
+ allow(support).to receive(:require).with('curses').and_return(true)
46
+ stub_const("Curses", Object.new)
47
+ curses = double(:curses)
48
+ allow(curses).to receive(:init_screen)
49
+ allow(curses).to receive(:has_colors?).and_return(true)
50
+ allow(curses).to receive(:close_screen)
51
+
52
+ expect(support.from_curses(curses)).to eql(true)
53
+ expect(curses).to have_received(:has_colors?)
54
+ end
55
+
56
+ it "fails to find color for dumb terminal" do
57
+ support = described_class.new('TERM' => 'dumb')
58
+ expect(support.from_term).to eq(false)
59
+ end
60
+
61
+ it "inspects term variable for color capabilities" do
62
+ support = described_class.new('TERM' => 'xterm')
63
+ expect(support.from_term).to eq(true)
64
+ end
65
+
66
+ it "inspects color terminal variable for support" do
67
+ support = described_class.new('COLORTERM' => true)
68
+ expect(support.from_env).to eq(true)
69
+ end
70
+ end
@@ -0,0 +1,10 @@
1
+ # encoding: utf-8
2
+
3
+ desc 'Load gem inside irb console'
4
+ task :console do
5
+ require 'irb'
6
+ require 'irb/completion'
7
+ require File.join(__FILE__, '../../lib/pastel')
8
+ ARGV.clear
9
+ IRB.start
10
+ end
@@ -0,0 +1,11 @@
1
+ # encoding: utf-8
2
+
3
+ desc 'Measure code coverage'
4
+ task :coverage do
5
+ begin
6
+ original, ENV['COVERAGE'] = ENV['COVERAGE'], 'true'
7
+ Rake::Task['spec'].invoke
8
+ ensure
9
+ ENV['COVERAGE'] = original
10
+ end
11
+ end
data/tasks/spec.rake ADDED
@@ -0,0 +1,29 @@
1
+ # encoding: utf-8
2
+
3
+ begin
4
+ require 'rspec/core/rake_task'
5
+
6
+ desc 'Run all specs'
7
+ RSpec::Core::RakeTask.new(:spec) do |task|
8
+ task.pattern = 'spec/{unit,integration}{,/*/**}/*_spec.rb'
9
+ end
10
+
11
+ namespace :spec do
12
+ desc 'Run unit specs'
13
+ RSpec::Core::RakeTask.new(:unit) do |task|
14
+ task.pattern = 'spec/unit{,/*/**}/*_spec.rb'
15
+ end
16
+
17
+ desc 'Run integration specs'
18
+ RSpec::Core::RakeTask.new(:integration) do |task|
19
+ task.pattern = 'spec/integration{,/*/**}/*_spec.rb'
20
+ end
21
+ end
22
+
23
+ rescue LoadError
24
+ %w[spec spec:unit spec:integration].each do |name|
25
+ task name do
26
+ $stderr.puts "In order to run #{name}, do `gem install rspec`"
27
+ end
28
+ end
29
+ end
data/tty-color.gemspec ADDED
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'tty/color/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'tty-color'
8
+ spec.version = TTY::Color::VERSION
9
+ spec.authors = ['Piotr Murach']
10
+ spec.email = [""]
11
+ spec.summary = %q{Terminal color capabilities detection}
12
+ spec.description = %q{Terminal color capabilities detection}
13
+ spec.homepage = "http://peter-murach.github.io/tty"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^spec})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency 'bundler', '>= 1.5.0', '< 2.0'
22
+ spec.add_development_dependency 'rake', '~> 10.0'
23
+ end
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tty-color
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Piotr Murach
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-01-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 1.5.0
20
+ - - <
21
+ - !ruby/object:Gem::Version
22
+ version: '2.0'
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 1.5.0
30
+ - - <
31
+ - !ruby/object:Gem::Version
32
+ version: '2.0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: rake
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ~>
38
+ - !ruby/object:Gem::Version
39
+ version: '10.0'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: '10.0'
47
+ description: Terminal color capabilities detection
48
+ email:
49
+ - ''
50
+ executables:
51
+ - color
52
+ extensions: []
53
+ extra_rdoc_files: []
54
+ files:
55
+ - .gitignore
56
+ - .rspec
57
+ - .travis.yml
58
+ - CHANGELOG.md
59
+ - Gemfile
60
+ - LICENSE.txt
61
+ - README.md
62
+ - Rakefile
63
+ - bin/color
64
+ - lib/tty-color.rb
65
+ - lib/tty/color.rb
66
+ - lib/tty/color/mode.rb
67
+ - lib/tty/color/support.rb
68
+ - lib/tty/color/version.rb
69
+ - spec/spec_helper.rb
70
+ - spec/unit/color_spec.rb
71
+ - spec/unit/mode_spec.rb
72
+ - spec/unit/supports_spec.rb
73
+ - tasks/console.rake
74
+ - tasks/coverage.rake
75
+ - tasks/spec.rake
76
+ - tty-color.gemspec
77
+ homepage: http://peter-murach.github.io/tty
78
+ licenses:
79
+ - MIT
80
+ metadata: {}
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ requirements: []
96
+ rubyforge_project:
97
+ rubygems_version: 2.0.3
98
+ signing_key:
99
+ specification_version: 4
100
+ summary: Terminal color capabilities detection
101
+ test_files:
102
+ - spec/spec_helper.rb
103
+ - spec/unit/color_spec.rb
104
+ - spec/unit/mode_spec.rb
105
+ - spec/unit/supports_spec.rb
106
+ has_rdoc: