tty-color-cli 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1b4abe682744bc0a271555093a14f34cf9f1c369
4
+ data.tar.gz: 1bdf7246a7290743e9b58bbd8edd73c61546a885
5
+ SHA512:
6
+ metadata.gz: b1df4e72a666a5411f54f74c7ae4c89e3c66945bd9b9ab9d151987f0825d37e0c8ae5803b609899f3d6eacdcc1d559c45cc2c4bcfa9901ddf377f8e3cafd1efa
7
+ data.tar.gz: bae19435120a8eb91f361fd82ac40a911e6b96ef51d1f165f1a6fb6972188fd3f6f041f05e2b6e82cc3f9363eb124a6312b25e4343e520a784156965b2884417
data/.codeclimate.yml ADDED
@@ -0,0 +1,11 @@
1
+ ---
2
+ engines:
3
+ rubocop:
4
+ enabled: true
5
+ ratings:
6
+ paths:
7
+ - bin/*
8
+ exclude_paths:
9
+ - spec/**/*
10
+ - examples/**/*
11
+ - tasks/**/*
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/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.0.0
data/.travis.yml ADDED
@@ -0,0 +1,26 @@
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
+ - 2.3.0
13
+ - rbx-2
14
+ - jruby-9000
15
+ - jruby-head
16
+ - ruby-head
17
+ matrix:
18
+ allow_failures:
19
+ - rvm: ruby-head
20
+ - rvm: jruby-head
21
+ - rvm: jruby-9000
22
+ fast_finish: true
23
+ branches:
24
+ only: master
25
+ notifications:
26
+ email: false
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # Change log
2
+
3
+ ## [v0.1.0] - 2016-03-05
4
+
5
+ Initial release
6
+
7
+ [v0.1.0]: https://github.com/peter-murach/tty-color-cli/compare/v0.1.0
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :test do
6
+ gem 'rspec', '~> 3.4.0'
7
+ gem 'simplecov', '~> 0.11.2'
8
+ gem 'codeclimate-test-reporter', '~> 0.5.0'
9
+ 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,65 @@
1
+ # TTY::Color CLI
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/tty-color-cli.svg)][gem]
4
+ [![Build Status](https://secure.travis-ci.org/peter-murach/tty-color-cli.svg?branch=master)][travis]
5
+ [![Code Climate](https://codeclimate.com/github/peter-murach/tty-color-cli/badges/gpa.svg)][codeclimate]
6
+ [![Coverage Status](https://codeclimate.com/github/peter-murach/tty-color-cli/badges/coverage.svg)][codeclimate]
7
+
8
+ [gem]: http://badge.fury.io/rb/tty-color-cli
9
+ [travis]: http://travis-ci.org/peter-murach/tty-color-cli
10
+ [codeclimate]: https://codeclimate.com/github/peter-murach/tty-color-cli
11
+
12
+ > CLI tool for terminal color capabilities detection
13
+
14
+ **TTY::Color CLI** provides cli for [TTY::Color](https://github.com/peter-murach/tty-color)
15
+
16
+ ## Installation
17
+
18
+ Add this line to your application's Gemfile:
19
+
20
+ ```ruby
21
+ gem 'tty-color-cli'
22
+ ```
23
+
24
+ And then execute:
25
+
26
+ $ bundle
27
+
28
+ Or install it yourself as:
29
+
30
+ $ gem install tty-color-cli
31
+
32
+ ## Usage
33
+
34
+ Running `color` with `-h` or `--help` flats will display help information:
35
+
36
+ ```bash
37
+ $ color --help
38
+ ```
39
+
40
+ **TTY::Color** comes with a command line tool to detect color support in terminal. The results are redirected to standard output.
41
+
42
+ ```bash
43
+ color
44
+ color -s
45
+ color --support
46
+ ```
47
+
48
+ and to check number of colors:
49
+
50
+ ```bash
51
+ color -m
52
+ color --mode
53
+ ```
54
+
55
+ ## Contributing
56
+
57
+ 1. Fork it ( https://github.com/peter-murach/tty-color-cli/fork )
58
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
59
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
60
+ 4. Push to the branch (`git push origin my-new-feature`)
61
+ 5. Create a new Pull Request
62
+
63
+ ## Copyright
64
+
65
+ 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,34 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ Signal.trap("INT") { exit 1 }
4
+
5
+ require 'optparse'
6
+ require 'tty-color'
7
+
8
+ options = {}
9
+
10
+ parser = OptionParser.new do |opts|
11
+ opts.on('-s', '--support', 'Check if terminal supports colors') do
12
+ options[:color] = true
13
+ end
14
+
15
+ opts.on('-m', '--mode', 'Supported colors mode') do
16
+ options[:mode] = true
17
+ end
18
+
19
+ options[:verbose] = false
20
+ opts.on('-v', '--verbose', 'Output debug information' ) do
21
+ options[:verbose] = true
22
+ end
23
+
24
+ opts.on('-h', '--help', 'Display help' ) do
25
+ puts opts
26
+ exit
27
+ end
28
+ end
29
+
30
+ parser.parse!
31
+
32
+ TTY::Color.verbose = options[:verbose]
33
+
34
+ print(options[:mode] ? TTY::Color.mode : TTY::Color.color?)
@@ -0,0 +1,45 @@
1
+ # encoding: utf-8
2
+
3
+ $:.unshift File.expand_path("../../bin", __FILE__)
4
+
5
+ if RUBY_VERSION > '1.9' and (ENV['COVERAGE'] || ENV['TRAVIS'])
6
+ require 'simplecov'
7
+ require 'codeclimate-test-reporter'
8
+
9
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
10
+ SimpleCov::Formatter::HTMLFormatter,
11
+ CodeClimate::TestReporter::Formatter
12
+ ]
13
+
14
+ SimpleCov.start do
15
+ command_name 'spec'
16
+ add_filter 'spec'
17
+ end
18
+ end
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,30 @@
1
+ # encoding: utf-8
2
+
3
+ RSpec.describe 'color command' do
4
+
5
+ it 'runs without arguments' do
6
+ expect(`bin/color`).to match(/true/)
7
+ expect($?.exitstatus).to eq(0)
8
+ end
9
+
10
+ it 'shows help' do
11
+ expect(`bin/color --help`).to eq([
12
+ "Usage: color [options]\n",
13
+ " -s, --support Check if terminal supports colors\n",
14
+ " -m, --mode Supported colors mode\n",
15
+ " -v, --verbose Output debug information\n",
16
+ " -h, --help Display help\n"
17
+ ].join)
18
+ expect($?.exitstatus).to eq(0)
19
+ end
20
+
21
+ it "detects mode" do
22
+ expect(`bin/color --mode`).to match(/(\d+)/)
23
+ expect($?.exitstatus).to eq(0)
24
+ end
25
+
26
+ it "runs in verbose mode" do
27
+ expect(`bin/color --verbose --mode`).to match(/(\d+)/)
28
+ expect($?.exitstatus).to eq(0)
29
+ end
30
+ 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
@@ -0,0 +1,21 @@
1
+ # coding: utf-8
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = 'tty-color-cli'
5
+ spec.version = '0.1.0'
6
+ spec.authors = ['Piotr Murach']
7
+ spec.email = ['']
8
+ spec.summary = %q{CLI tool for terminal color capabilities detection}
9
+ spec.description = %q{CLI tool for terminal color capabilities detection}
10
+ spec.homepage = "http://peter-murach.github.io/tty/"
11
+ spec.license = "MIT"
12
+
13
+ spec.files = `git ls-files -z`.split("\x0")
14
+ spec.executables = ['color']
15
+ spec.test_files = spec.files.grep(%r{^spec/})
16
+
17
+ spec.add_dependency 'tty-color', '~> 0.3.0'
18
+
19
+ spec.add_development_dependency 'bundler', '>= 1.5.0', '< 2.0'
20
+ spec.add_development_dependency 'rake'
21
+ end
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tty-color-cli
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-03-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: tty-color
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 0.3.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 0.3.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: 1.5.0
34
+ - - <
35
+ - !ruby/object:Gem::Version
36
+ version: '2.0'
37
+ type: :development
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - '>='
42
+ - !ruby/object:Gem::Version
43
+ version: 1.5.0
44
+ - - <
45
+ - !ruby/object:Gem::Version
46
+ version: '2.0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ description: CLI tool for terminal color capabilities detection
62
+ email:
63
+ - ''
64
+ executables:
65
+ - color
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - .codeclimate.yml
70
+ - .gitignore
71
+ - .rspec
72
+ - .ruby-version
73
+ - .travis.yml
74
+ - CHANGELOG.md
75
+ - Gemfile
76
+ - LICENSE.txt
77
+ - README.md
78
+ - Rakefile
79
+ - bin/color
80
+ - spec/spec_helper.rb
81
+ - spec/unit/color_command_spec.rb
82
+ - tasks/coverage.rake
83
+ - tasks/spec.rake
84
+ - tty-color-cli.gemspec
85
+ homepage: http://peter-murach.github.io/tty/
86
+ licenses:
87
+ - MIT
88
+ metadata: {}
89
+ post_install_message:
90
+ rdoc_options: []
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - '>='
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ requirements: []
104
+ rubyforge_project:
105
+ rubygems_version: 2.0.3
106
+ signing_key:
107
+ specification_version: 4
108
+ summary: CLI tool for terminal color capabilities detection
109
+ test_files:
110
+ - spec/spec_helper.rb
111
+ - spec/unit/color_command_spec.rb