[DRE-commits] [ruby-rainbow] 01/03: New upstream version 2.2.2
Abhijith PA
abhijithpa-guest at moszumanska.debian.org
Tue Aug 29 17:37:08 UTC 2017
This is an automated email from the git hooks/post-receive script.
abhijithpa-guest pushed a commit to branch master
in repository ruby-rainbow.
commit 22d133cc9eb6eebd018c572212a4c8d8292a5fc3
Author: Abhijith PA <abhijith at openmailbox.org>
Date: Tue Aug 29 23:03:31 2017 +0530
New upstream version 2.2.2
---
.travis.yml | 29 +++--
Changelog.md | 14 +++
Gemfile | 2 +-
README.markdown | 182 ++++++------------------------
ext/mkrf_conf.rb | 22 ++++
lib/rainbow.rb | 3 +-
lib/rainbow/color.rb | 13 ++-
lib/rainbow/ext/string.rb | 4 +
lib/rainbow/null_presenter.rb | 11 ++
lib/rainbow/presenter.rb | 11 ++
lib/rainbow/version.rb | 2 +-
metadata.yml | 101 -----------------
rainbow.gemspec | 3 +
spec/integration/rainbow_spec.rb | 13 ++-
spec/integration/string_spec.rb | 4 +
spec/support/presenter_shared_examples.rb | 2 +-
spec/unit/null_presenter_spec.rb | 18 +++
spec/unit/presenter_spec.rb | 33 ++++++
18 files changed, 199 insertions(+), 268 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index ad44a2a..2bb8ee9 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,11 +1,22 @@
+language: ruby
+cache:
+ - bundler
+before_install:
+ - gem update --system
+ - gem install bundler
bundler_args: --without guard development
-rvm:
- - 1.9.2
- - 1.9.3
- - 2.0.0
- - 2.1.0
- - rbx
- - jruby
-script: "bundle exec rake"
-sudo: false
+matrix:
+ include:
+ - rvm: 2.0.0
+ - rvm: 2.1.9
+ - rvm: 2.2.6
+ - rvm: 2.3.3
+ - rvm: 2.4.0
+ - rvm: jruby-9.1.6.0
+ jdk: oraclejdk8
+ env:
+ - JRUBY_OPTS=--debug
+ - rvm: 2.2.6
+ install: true # This skips 'bundle install'
+ script: gem build rainbow && gem install *.gem
diff --git a/Changelog.md b/Changelog.md
index ff859d3..9704b29 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -71,3 +71,17 @@
* added X11 color support
* fixed `require` issue when rainbow is used as a dependency in another gem
* improved Windows support
+
+# 2.2.0 (2016-12-27)
+
+* improved Windows support
+* added Ruby 2.4 support
+* added `bold` alias method for `bright`
+
+# 2.2.1 (2016-12-28)
+
+* fixed gem installation (2.2.0 was a broken release)
+
+# 2.2.2 (2017-04-21)
+
+* added explicit rake dependency to fix installation issue
diff --git a/Gemfile b/Gemfile
index 844cdc2..bd74d67 100644
--- a/Gemfile
+++ b/Gemfile
@@ -6,7 +6,7 @@ gemspec
gem 'rake'
gem 'coveralls', require: false
gem 'mime-types', '< 2.0.0', platforms: [:ruby_18]
-gem 'rspec', '3.0.0beta2'
+gem 'rspec'
group :development do
gem 'mutant-rspec'
diff --git a/README.markdown b/README.markdown
index 2b80cbf..c64ca79 100644
--- a/README.markdown
+++ b/README.markdown
@@ -1,8 +1,8 @@
# Rainbow
-[](https://travis-ci.org/sickill/rainbow)
-[](https://codeclimate.com/github/sickill/rainbow)
-[](https://coveralls.io/r/sickill/rainbow)
+[](https://travis-ci.org/sickill/rainbow)
+[](https://codeclimate.com/github/sickill/rainbow)
+[](https://coveralls.io/r/sickill/rainbow)
Rainbow is a ruby gem for colorizing printed text on ANSI terminals.
@@ -38,7 +38,8 @@ Rainbow presenter adds the following methods to presented string:
* `blink`
* `inverse`
* `hide`
-* `italic` (not well supported by terminal emulators).
+* `faint` (not well supported by terminal emulators)
+* `italic` (not well supported by terminal emulators)
Text color can also be changed by calling a method named by a color:
@@ -155,7 +156,7 @@ instances that are used by formatters with file output.
## Windows support
-For Windows support, you should install the following gems:
+For Windows support on Ruby < 2.0, you should install the following gems:
```ruby
gem install windows-pr win32console
@@ -181,154 +182,35 @@ gem install rainbow
### ANSI colors
-* `black`
-* `red`
-* `green`
-* `yellow`
-* `blue`
-* `magenta`
-* `cyan`
-* `white`
+`black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white`
### X11 colors
-* `aqua`
-* `aquamarine`
-* `mediumaquamarine`
-* `azure`
-* `beige`
-* `bisque`
-* `blanchedalmond`
-* `darkblue`
-* `lightblue`
-* `mediumblue`
-* `aliceblue`
-* `cadetblue`
-* `dodgerblue`
-* `midnightblue`
-* `navyblue`
-* `powderblue`
-* `royalblue`
-* `skyblue`
-* `deepskyblue`
-* `lightskyblue`
-* `slateblue`
-* `darkslateblue`
-* `mediumslateblue`
-* `steelblue`
-* `lightsteelblue`
-* `brown`
-* `rosybrown`
-* `saddlebrown`
-* `sandybrown`
-* `burlywood`
-* `chartreuse`
-* `chocolate`
-* `coral`
-* `lightcoral`
-* `cornflower`
-* `cornsilk`
-* `crimson`
-* `darkcyan`
-* `lightcyan`
-* `firebrick`
-* `fuchsia`
-* `gainsboro`
-* `gold`
-* `goldenrod`
-* `darkgoldenrod`
-* `lightgoldenrod`
-* `palegoldenrod`
-* `gray`
-* `darkgray`
-* `dimgray`
-* `lightgray`
-* `slategray`
-* `lightslategray`
-* `webgray`
-* `darkgreen`
-* `lightgreen`
-* `palegreen`
-* `darkolivegreen`
-* `yellowgreen`
-* `forestgreen`
-* `lawngreen`
-* `limegreen`
-* `seagreen`
-* `darkseagreen`
-* `lightseagreen`
-* `mediumseagreen`
-* `springgreen`
-* `mediumspringgreen`
-* `webgreen`
-* `honeydew`
-* `indianred`
-* `indigo`
-* `ivory`
-* `khaki`
-* `darkkhaki`
-* `lavender`
-* `lavenderblush`
-* `lemonchiffon`
-* `lime`
-* `linen`
-* `darkmagenta`
-* `maroon`
-* `webmaroon`
-* `mintcream`
-* `mistyrose`
-* `moccasin`
-* `oldlace`
-* `olive`
-* `olivedrab`
-* `orange`
-* `darkorange`
-* `orchid`
-* `darkorchid`
-* `mediumorchid`
-* `papayawhip`
-* `peachpuff`
-* `peru`
-* `pink`
-* `deeppink`
-* `lightpink`
-* `hotpink`
-* `plum`
-* `purple`
-* `mediumpurple`
-* `rebeccapurple`
-* `webpurple`
-* `darkred`
-* `orangered`
-* `mediumvioletred`
-* `palevioletred`
-* `salmon`
-* `darksalmon`
-* `lightsalmon`
-* `seashell`
-* `sienna`
-* `silver`
-* `darkslategray`
-* `snow`
-* `tan`
-* `teal`
-* `thistle`
-* `tomato`
-* `turquoise`
-* `darkturquoise`
-* `mediumturquoise`
-* `paleturquoise`
-* `violet`
-* `darkviolet`
-* `blueviolet`
-* `wheat`
-* `antiquewhite`
-* `floralwhite`
-* `ghostwhite`
-* `navajowhite`
-* `whitesmoke`
-* `lightyellow`
-* `greenyellow`
+`aliceblue`, `antiquewhite`, `aqua`, `aquamarine`, `azure`, `beige`, `bisque`,
+`blanchedalmond`, `blueviolet`, `brown`, `burlywood`, `cadetblue`, `chartreuse`,
+`chocolate`, `coral`, `cornflower`, `cornsilk`, `crimson`, `darkblue`,
+`darkcyan`, `darkgoldenrod`, `darkgray`, `darkgreen`, `darkkhaki`,
+`darkmagenta`, `darkolivegreen`, `darkorange`, `darkorchid`, `darkred`,
+`darksalmon`, `darkseagreen`, `darkslateblue`, `darkslategray`, `darkturquoise`,
+`darkviolet`, `deeppink`, `deepskyblue`, `dimgray`, `dodgerblue`, `firebrick`,
+`floralwhite`, `forestgreen`, `fuchsia`, `gainsboro`, `ghostwhite`, `gold`,
+`goldenrod`, `gray`, `greenyellow`, `honeydew`, `hotpink`, `indianred`,
+`indigo`, `ivory`, `khaki`, `lavender`, `lavenderblush`, `lawngreen`,
+`lemonchiffon`, `lightblue`, `lightcoral`, `lightcyan`, `lightgoldenrod`,
+`lightgray`, `lightgreen`, `lightpink`, `lightsalmon`, `lightseagreen`,
+`lightskyblue`, `lightslategray`, `lightsteelblue`, `lightyellow`, `lime`,
+`limegreen`, `linen`, `maroon`, `mediumaquamarine`, `mediumblue`,
+`mediumorchid`, `mediumpurple`, `mediumseagreen`, `mediumslateblue`,
+`mediumspringgreen`, `mediumturquoise`, `mediumvioletred`, `midnightblue`,
+`mintcream`, `mistyrose`, `moccasin`, `navajowhite`, `navyblue`, `oldlace`,
+`olive`, `olivedrab`, `orange`, `orangered`, `orchid`, `palegoldenrod`,
+`palegreen`, `paleturquoise`, `palevioletred`, `papayawhip`, `peachpuff`,
+`peru`, `pink`, `plum`, `powderblue`, `purple`, `rebeccapurple`, `rosybrown`,
+`royalblue`, `saddlebrown`, `salmon`, `sandybrown`, `seagreen`, `seashell`,
+`sienna`, `silver`, `skyblue`, `slateblue`, `slategray`, `snow`, `springgreen`,
+`steelblue`, `tan`, `teal`, `thistle`, `tomato`, `turquoise`, `violet`,
+`webgray`, `webgreen`, `webmaroon`, `webpurple`, `wheat`, `whitesmoke`,
+`yellowgreen`
## Authors
diff --git a/ext/mkrf_conf.rb b/ext/mkrf_conf.rb
new file mode 100644
index 0000000..f557143
--- /dev/null
+++ b/ext/mkrf_conf.rb
@@ -0,0 +1,22 @@
+require 'rubygems'
+require 'rubygems/command'
+require 'rubygems/dependency_installer'
+
+begin
+ Gem::Command.build_args = ARGV
+rescue NoMethodError
+ exit 1
+end
+
+installer = Gem::DependencyInstaller.new
+
+begin
+ if RUBY_PLATFORM =~ /mswin|cygwin|mingw/ && RUBY_VERSION.to_i < 2
+ installer.install('windows-pr')
+ installer.install('win32console')
+ end
+rescue
+ exit 1
+end
+
+File.write(File.join(File.dirname(__FILE__), 'Rakefile'), "task :default\n")
diff --git a/lib/rainbow.rb b/lib/rainbow.rb
index e5d9746..4164487 100644
--- a/lib/rainbow.rb
+++ b/lib/rainbow.rb
@@ -13,8 +13,7 @@ module Rainbow
# On Windows systems, try to load the local ANSI support library if Ruby version < 2
# Ruby 2.x on Windows includes ANSI support.
- require 'rbconfig'
- if RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ && RUBY_VERSION.to_i < 2
+ if RUBY_PLATFORM =~ /mswin|cygwin|mingw/ && RUBY_VERSION.to_i < 2
begin
require 'Win32/Console/ANSI'
rescue LoadError
diff --git a/lib/rainbow/color.rb b/lib/rainbow/color.rb
index 8fe151b..1a29575 100644
--- a/lib/rainbow/color.rb
+++ b/lib/rainbow/color.rb
@@ -12,13 +12,22 @@ module Rainbow
color = values.size == 1 ? values.first : values
case color
- when Fixnum
+ # NOTE: Properly handle versions before/after Ruby 2.4.0.
+ # Ruby 2.4+ unifies Fixnum & Bignum into Integer.
+ # However previous versions would still use Fixnum.
+ # To avoid missing `Fixnum` input, call `0.class` which would
+ # return either `Integer` or `Fixnum`.
+ when 0.class
Indexed.new(ground, color)
when Symbol
if Named.color_names.include?(color)
Named.new(ground, color)
- else X11Named.color_names.include?(color)
+ elsif X11Named.color_names.include?(color)
X11Named.new(ground, color)
+ else
+ fail ArgumentError,
+ "Unknown color name, valid names: " +
+ (Named.color_names + X11Named.color_names).join(', ')
end
when Array
RGB.new(ground, *color)
diff --git a/lib/rainbow/ext/string.rb b/lib/rainbow/ext/string.rb
index d7161f9..15cfce7 100644
--- a/lib/rainbow/ext/string.rb
+++ b/lib/rainbow/ext/string.rb
@@ -24,6 +24,10 @@ module Rainbow
Rainbow(self).bright
end
+ def faint
+ Rainbow(self).faint
+ end
+
def italic
Rainbow(self).italic
end
diff --git a/lib/rainbow/null_presenter.rb b/lib/rainbow/null_presenter.rb
index 8b4961e..8cdaa1a 100644
--- a/lib/rainbow/null_presenter.rb
+++ b/lib/rainbow/null_presenter.rb
@@ -6,6 +6,7 @@ module Rainbow
def background(*values); self; end
def reset; self; end
def bright; self; end
+ def faint; self; end
def italic; self; end
def underline; self; end
def blink; self; end
@@ -21,9 +22,19 @@ module Rainbow
def cyan; self; end
def white; self; end
+ def method_missing(method_name,*args)
+ if Color::X11Named.color_names.include? method_name and args.empty? then
+ self
+ else
+ super
+ end
+ end
+
alias_method :foreground, :color
alias_method :fg, :color
alias_method :bg, :background
+ alias_method :bold, :bright
+ alias_method :dark, :faint
end
diff --git a/lib/rainbow/presenter.rb b/lib/rainbow/presenter.rb
index 242afe6..80f581e 100644
--- a/lib/rainbow/presenter.rb
+++ b/lib/rainbow/presenter.rb
@@ -9,6 +9,7 @@ module Rainbow
TERM_EFFECTS = {
reset: 0,
bright: 1,
+ faint: 2,
italic: 3,
underline: 4,
blink: 5,
@@ -44,6 +45,16 @@ module Rainbow
wrap_with_sgr(TERM_EFFECTS[:bright])
end
+ alias_method :bold, :bright
+
+ # Turns on faint/dark for this text (not well supported by terminal
+ # emulators).
+ def faint
+ wrap_with_sgr(TERM_EFFECTS[:faint])
+ end
+
+ alias_method :dark, :faint
+
# Turns on italic style for this text (not well supported by terminal
# emulators).
def italic
diff --git a/lib/rainbow/version.rb b/lib/rainbow/version.rb
index 0aaecaf..6ee0f82 100644
--- a/lib/rainbow/version.rb
+++ b/lib/rainbow/version.rb
@@ -1,3 +1,3 @@
module Rainbow
- VERSION = "2.1.0".freeze
+ VERSION = "2.2.2".freeze
end
diff --git a/metadata.yml b/metadata.yml
deleted file mode 100644
index 214aa60..0000000
--- a/metadata.yml
+++ /dev/null
@@ -1,101 +0,0 @@
---- !ruby/object:Gem::Specification
-name: rainbow
-version: !ruby/object:Gem::Version
- version: 2.1.0
-platform: ruby
-authors:
-- Marcin Kulik
-autorequire:
-bindir: bin
-cert_chain: []
-date: 2016-01-24 00:00:00.000000000 Z
-dependencies:
-- !ruby/object:Gem::Dependency
- name: bundler
- requirement: !ruby/object:Gem::Requirement
- requirements:
- - - "~>"
- - !ruby/object:Gem::Version
- version: '1.3'
- type: :development
- prerelease: false
- version_requirements: !ruby/object:Gem::Requirement
- requirements:
- - - "~>"
- - !ruby/object:Gem::Version
- version: '1.3'
-description: Colorize printed text on ANSI terminals
-email:
-- m at ku1ik.com
-executables: []
-extensions: []
-extra_rdoc_files: []
-files:
-- ".gitignore"
-- ".rubocop.yml"
-- ".travis.yml"
-- Changelog.md
-- Gemfile
-- Guardfile
-- LICENSE
-- README.markdown
-- Rakefile
-- lib/rainbow.rb
-- lib/rainbow/color.rb
-- lib/rainbow/ext/string.rb
-- lib/rainbow/global.rb
-- lib/rainbow/legacy.rb
-- lib/rainbow/null_presenter.rb
-- lib/rainbow/presenter.rb
-- lib/rainbow/string_utils.rb
-- lib/rainbow/version.rb
-- lib/rainbow/wrapper.rb
-- lib/rainbow/x11_color_names.rb
-- rainbow.gemspec
-- spec/integration/instance_spec.rb
-- spec/integration/rainbow_spec.rb
-- spec/integration/string_spec.rb
-- spec/spec_helper.rb
-- spec/support/presenter_shared_examples.rb
-- spec/unit/color_spec.rb
-- spec/unit/namespace_spec.rb
-- spec/unit/null_presenter_spec.rb
-- spec/unit/presenter_spec.rb
-- spec/unit/string_utils_spec.rb
-- spec/unit/wrapper_spec.rb
-homepage: https://github.com/sickill/rainbow
-licenses:
-- MIT
-metadata: {}
-post_install_message:
-rdoc_options: []
-require_paths:
-- lib
-required_ruby_version: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: 1.9.2
-required_rubygems_version: !ruby/object:Gem::Requirement
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- version: '0'
-requirements: []
-rubyforge_project:
-rubygems_version: 2.2.2
-signing_key:
-specification_version: 4
-summary: Colorize printed text on ANSI terminals
-test_files:
-- spec/integration/instance_spec.rb
-- spec/integration/rainbow_spec.rb
-- spec/integration/string_spec.rb
-- spec/spec_helper.rb
-- spec/support/presenter_shared_examples.rb
-- spec/unit/color_spec.rb
-- spec/unit/namespace_spec.rb
-- spec/unit/null_presenter_spec.rb
-- spec/unit/presenter_spec.rb
-- spec/unit/string_utils_spec.rb
-- spec/unit/wrapper_spec.rb
diff --git a/rainbow.gemspec b/rainbow.gemspec
index 10df63b..1d89862 100644
--- a/rainbow.gemspec
+++ b/rainbow.gemspec
@@ -19,5 +19,8 @@ Gem::Specification.new do |spec|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]
+ spec.add_dependency "rake"
+
spec.add_development_dependency "bundler", "~> 1.3"
+ spec.extensions = ["ext/mkrf_conf.rb"]
end
diff --git a/spec/integration/rainbow_spec.rb b/spec/integration/rainbow_spec.rb
index 4162206..fa594ad 100644
--- a/spec/integration/rainbow_spec.rb
+++ b/spec/integration/rainbow_spec.rb
@@ -77,6 +77,11 @@ describe 'Rainbow() wrapper' do
expect(result).to eq("\e[1mhello\e[0m")
end
+ it 'allows making text faint' do
+ result = Rainbow('hello').faint
+ expect(result).to eq("\e[2mhello\e[0m")
+ end
+
it 'allows making text italic' do
result = Rainbow('hello').italic
expect(result).to eq("\e[3mhello\e[0m")
@@ -111,6 +116,9 @@ describe 'Rainbow() wrapper' do
result = Rainbow('hello').
foreground(:red).
bright.
+ bold.
+ faint.
+ dark.
italic.
background('#ff8040').
underline.
@@ -120,7 +128,7 @@ describe 'Rainbow() wrapper' do
hide
expect(result).to eq(
- "\e[31m\e[1m\e[3m\e[48;5;215m\e[4m\e[34m\e[5m\e[7m\e[8mhello\e[0m"
+ "\e[31m\e[1m\e[1m\e[2m\e[2m\e[3m\e[48;5;215m\e[4m\e[34m\e[5m\e[7m\e[8mhello\e[0m"
)
end
@@ -134,6 +142,9 @@ describe 'Rainbow() wrapper' do
result = Rainbow('hello').
foreground(:red).
bright.
+ bold.
+ faint.
+ dark.
italic.
background('#ff8040').
underline.
diff --git a/spec/integration/string_spec.rb b/spec/integration/string_spec.rb
index cbe3171..39fc676 100644
--- a/spec/integration/string_spec.rb
+++ b/spec/integration/string_spec.rb
@@ -31,6 +31,10 @@ describe 'String mixin' do
expect('hello'.bright).to eq(Rainbow('hello').bright)
end
+ it 'proxies faint to Rainbow().faint' do
+ expect('hello'.faint).to eq(Rainbow('hello').faint)
+ end
+
it 'proxies italic to Rainbow().italic' do
expect('hello'.italic).to eq(Rainbow('hello').italic)
end
diff --git a/spec/support/presenter_shared_examples.rb b/spec/support/presenter_shared_examples.rb
index e819e75..a236169 100644
--- a/spec/support/presenter_shared_examples.rb
+++ b/spec/support/presenter_shared_examples.rb
@@ -1,5 +1,5 @@
shared_examples_for "presenter with shortcut color methods" do
- [:black, :red, :green, :yellow, :blue, :magenta, :cyan, :white].each do |name|
+ [:black, :red, :green, :yellow, :blue, :magenta, :cyan, :white, :aqua].each do |name|
describe "##{name}" do
subject { presenter.public_send(name) }
diff --git a/spec/unit/null_presenter_spec.rb b/spec/unit/null_presenter_spec.rb
index 5f3d4f7..4450407 100644
--- a/spec/unit/null_presenter_spec.rb
+++ b/spec/unit/null_presenter_spec.rb
@@ -58,6 +58,24 @@ module Rainbow
it_behaves_like "rainbow null string method"
end
+ describe '#bold' do
+ subject { presenter.bold }
+
+ it_behaves_like "rainbow null string method"
+ end
+
+ describe '#faint' do
+ subject { presenter.faint }
+
+ it_behaves_like "rainbow null string method"
+ end
+
+ describe '#dark' do
+ subject { presenter.dark }
+
+ it_behaves_like "rainbow null string method"
+ end
+
describe '#italic' do
subject { presenter.italic }
diff --git a/spec/unit/presenter_spec.rb b/spec/unit/presenter_spec.rb
index 36cb007..f65d04c 100644
--- a/spec/unit/presenter_spec.rb
+++ b/spec/unit/presenter_spec.rb
@@ -106,6 +106,39 @@ module Rainbow
end
end
+ describe '#bold' do
+ subject { presenter.bold }
+
+ it_behaves_like "rainbow string method"
+
+ it 'wraps with 1 code' do
+ subject
+ expect(StringUtils).to have_received(:wrap_with_sgr).with('hello', [1])
+ end
+ end
+
+ describe '#faint' do
+ subject { presenter.faint }
+
+ it_behaves_like "rainbow string method"
+
+ it 'wraps with 2 code' do
+ subject
+ expect(StringUtils).to have_received(:wrap_with_sgr).with('hello', [2])
+ end
+ end
+
+ describe '#dark' do
+ subject { presenter.dark }
+
+ it_behaves_like "rainbow string method"
+
+ it 'wraps with 2 code' do
+ subject
+ expect(StringUtils).to have_received(:wrap_with_sgr).with('hello', [2])
+ end
+ end
+
describe '#italic' do
subject { presenter.italic }
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-rainbow.git
More information about the Pkg-ruby-extras-commits
mailing list