buildkite-builder 1.0.0.beta.2 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +118 -14
- data/VERSION +1 -0
- data/bin/buildkite-builder +1 -1
- data/exe/buildkite-builder +6 -0
- data/lib/buildkite/builder.rb +12 -17
- data/lib/buildkite/builder/commands.rb +1 -0
- data/lib/buildkite/builder/commands/abstract.rb +1 -1
- data/lib/buildkite/builder/commands/preview.rb +10 -8
- data/lib/buildkite/builder/commands/run.rb +27 -0
- data/lib/buildkite/builder/context.rb +70 -0
- data/lib/buildkite/builder/loaders/abstract.rb +6 -10
- data/lib/buildkite/builder/loaders/manifests.rb +1 -1
- data/lib/buildkite/builder/loaders/processors.rb +2 -2
- data/lib/buildkite/builder/loaders/templates.rb +1 -1
- data/lib/buildkite/builder/manifest.rb +1 -1
- data/lib/buildkite/builder/processors/abstract.rb +7 -7
- data/lib/buildkite/builder/rainbow.rb +1 -1
- data/lib/buildkite/builder/runner.rb +26 -63
- data/lib/buildkite/pipelines.rb +1 -0
- data/lib/buildkite/pipelines/pipeline.rb +20 -9
- data/lib/buildkite/pipelines/step_context.rb +23 -0
- data/lib/buildkite/pipelines/steps/abstract.rb +4 -3
- data/lib/buildkite/pipelines/steps/block.rb +1 -0
- metadata +116 -36
- data/.gitignore +0 -11
- data/.rspec +0 -3
- data/CODE_OF_CONDUCT.md +0 -74
- data/Gemfile +0 -13
- data/Gemfile.lock +0 -56
- data/Rakefile +0 -6
- data/buildkite-builder.gemspec +0 -28
- data/lib/vendor/rainbow/Changelog.md +0 -101
- data/lib/vendor/rainbow/Gemfile +0 -30
- data/lib/vendor/rainbow/LICENSE +0 -20
- data/lib/vendor/rainbow/README.markdown +0 -225
- data/lib/vendor/rainbow/Rakefile +0 -11
- data/lib/vendor/rainbow/lib/rainbow.rb +0 -13
- data/lib/vendor/rainbow/lib/rainbow/color.rb +0 -150
- data/lib/vendor/rainbow/lib/rainbow/ext/string.rb +0 -64
- data/lib/vendor/rainbow/lib/rainbow/global.rb +0 -25
- data/lib/vendor/rainbow/lib/rainbow/null_presenter.rb +0 -100
- data/lib/vendor/rainbow/lib/rainbow/presenter.rb +0 -144
- data/lib/vendor/rainbow/lib/rainbow/refinement.rb +0 -14
- data/lib/vendor/rainbow/lib/rainbow/string_utils.rb +0 -22
- data/lib/vendor/rainbow/lib/rainbow/version.rb +0 -5
- data/lib/vendor/rainbow/lib/rainbow/wrapper.rb +0 -22
- data/lib/vendor/rainbow/lib/rainbow/x11_color_names.rb +0 -153
- data/lib/vendor/rainbow/rainbow.gemspec +0 -23
data/.gitignore
DELETED
data/.rspec
DELETED
data/CODE_OF_CONDUCT.md
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
# Contributor Covenant Code of Conduct
|
2
|
-
|
3
|
-
## Our Pledge
|
4
|
-
|
5
|
-
In the interest of fostering an open and welcoming environment, we as
|
6
|
-
contributors and maintainers pledge to making participation in our project and
|
7
|
-
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
-
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
-
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
-
orientation.
|
11
|
-
|
12
|
-
## Our Standards
|
13
|
-
|
14
|
-
Examples of behavior that contributes to creating a positive environment
|
15
|
-
include:
|
16
|
-
|
17
|
-
* Using welcoming and inclusive language
|
18
|
-
* Being respectful of differing viewpoints and experiences
|
19
|
-
* Gracefully accepting constructive criticism
|
20
|
-
* Focusing on what is best for the community
|
21
|
-
* Showing empathy towards other community members
|
22
|
-
|
23
|
-
Examples of unacceptable behavior by participants include:
|
24
|
-
|
25
|
-
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
-
advances
|
27
|
-
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
-
* Public or private harassment
|
29
|
-
* Publishing others' private information, such as a physical or electronic
|
30
|
-
address, without explicit permission
|
31
|
-
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
-
professional setting
|
33
|
-
|
34
|
-
## Our Responsibilities
|
35
|
-
|
36
|
-
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
-
behavior and are expected to take appropriate and fair corrective action in
|
38
|
-
response to any instances of unacceptable behavior.
|
39
|
-
|
40
|
-
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
-
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
-
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
-
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
-
threatening, offensive, or harmful.
|
45
|
-
|
46
|
-
## Scope
|
47
|
-
|
48
|
-
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
-
when an individual is representing the project or its community. Examples of
|
50
|
-
representing a project or community include using an official project e-mail
|
51
|
-
address, posting via an official social media account, or acting as an appointed
|
52
|
-
representative at an online or offline event. Representation of a project may be
|
53
|
-
further defined and clarified by project maintainers.
|
54
|
-
|
55
|
-
## Enforcement
|
56
|
-
|
57
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
-
reported by contacting the project team at andrew.lee@gusto.com. All
|
59
|
-
complaints will be reviewed and investigated and will result in a response that
|
60
|
-
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
-
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
-
Further details of specific enforcement policies may be posted separately.
|
63
|
-
|
64
|
-
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
-
faith may face temporary or permanent repercussions as determined by other
|
66
|
-
members of the project's leadership.
|
67
|
-
|
68
|
-
## Attribution
|
69
|
-
|
70
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
-
available at [https://contributor-covenant.org/version/1/4][version]
|
72
|
-
|
73
|
-
[homepage]: https://contributor-covenant.org
|
74
|
-
[version]: https://contributor-covenant.org/version/1/4/
|
data/Gemfile
DELETED
data/Gemfile.lock
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
buildkite-builder (1.0.0.beta.2)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
addressable (2.7.0)
|
10
|
-
public_suffix (>= 2.0.2, < 5.0)
|
11
|
-
byebug (11.1.3)
|
12
|
-
coderay (1.1.3)
|
13
|
-
crack (0.4.4)
|
14
|
-
diff-lcs (1.3)
|
15
|
-
hashdiff (1.0.1)
|
16
|
-
method_source (1.0.0)
|
17
|
-
pry (0.13.1)
|
18
|
-
coderay (~> 1.1)
|
19
|
-
method_source (~> 1.0)
|
20
|
-
pry-byebug (3.9.0)
|
21
|
-
byebug (~> 11.0)
|
22
|
-
pry (~> 0.13.0)
|
23
|
-
public_suffix (4.0.6)
|
24
|
-
rake (13.0.1)
|
25
|
-
rspec (3.9.0)
|
26
|
-
rspec-core (~> 3.9.0)
|
27
|
-
rspec-expectations (~> 3.9.0)
|
28
|
-
rspec-mocks (~> 3.9.0)
|
29
|
-
rspec-core (3.9.0)
|
30
|
-
rspec-support (~> 3.9.0)
|
31
|
-
rspec-expectations (3.9.0)
|
32
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
33
|
-
rspec-support (~> 3.9.0)
|
34
|
-
rspec-mocks (3.9.0)
|
35
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
36
|
-
rspec-support (~> 3.9.0)
|
37
|
-
rspec-support (3.9.0)
|
38
|
-
webmock (3.10.0)
|
39
|
-
addressable (>= 2.3.6)
|
40
|
-
crack (>= 0.3.2)
|
41
|
-
hashdiff (>= 0.4.0, < 2.0.0)
|
42
|
-
|
43
|
-
PLATFORMS
|
44
|
-
ruby
|
45
|
-
|
46
|
-
DEPENDENCIES
|
47
|
-
buildkite-builder!
|
48
|
-
bundler (~> 2.1)
|
49
|
-
byebug
|
50
|
-
pry-byebug
|
51
|
-
rake
|
52
|
-
rspec
|
53
|
-
webmock
|
54
|
-
|
55
|
-
BUNDLED WITH
|
56
|
-
2.1.4
|
data/Rakefile
DELETED
data/buildkite-builder.gemspec
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift File.expand_path('lib', __dir__)
|
2
|
-
require 'buildkite-builder'
|
3
|
-
|
4
|
-
Gem::Specification.new do |spec|
|
5
|
-
spec.name = "buildkite-builder"
|
6
|
-
spec.version = Buildkite::Builder::VERSION
|
7
|
-
spec.authors = ["Ngan Pham", "Andrew Lee"]
|
8
|
-
spec.email = ["gusto-opensource-buildkite@gusto.com"]
|
9
|
-
|
10
|
-
spec.summary = %q{Write a short summary, because RubyGems requires one.}
|
11
|
-
spec.description = %q{Write a longer description or delete this line.}
|
12
|
-
spec.homepage = 'https://github.com/Gusto/buildkite-builder'
|
13
|
-
spec.license = 'MIT'
|
14
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
15
|
-
|
16
|
-
spec.metadata["homepage_uri"] = spec.homepage
|
17
|
-
spec.metadata["source_code_uri"] = "https://github.com/Gusto/buildkite-builder"
|
18
|
-
spec.metadata["changelog_uri"] = "https://github.com/Gusto/buildkite-builder/blob/master/CHANGELOG.md"
|
19
|
-
spec.metadata["bug_tracker_uri"] = "https://github.com/Gusto/buildkite-builder/issues"
|
20
|
-
|
21
|
-
# Specify which files should be added to the gem when it is released.
|
22
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
-
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
24
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
-
end
|
26
|
-
spec.executables = ['buildkite-builder']
|
27
|
-
spec.require_paths = ["lib"]
|
28
|
-
end
|
@@ -1,101 +0,0 @@
|
|
1
|
-
# Rainbow changelog
|
2
|
-
|
3
|
-
## 3.1.0 (2020-08-26)
|
4
|
-
|
5
|
-
- added `cross_out` aka `strike`
|
6
|
-
- hexadecimal color names supported better, see #83
|
7
|
-
- gemspec: list files using a Ruby expression, avoiding git
|
8
|
-
|
9
|
-
## 3.0.0 (2017-11-29)
|
10
|
-
|
11
|
-
* added String refinement
|
12
|
-
* added new `Rainbow.uncolor` method
|
13
|
-
* dropped MRI 1.9.3 compatibility
|
14
|
-
* dropped MRI 2.0 compatibility
|
15
|
-
* removed Rake dependency
|
16
|
-
|
17
|
-
## 2.2.2 (2017-04-21)
|
18
|
-
|
19
|
-
* added explicit rake dependency to fix installation issue
|
20
|
-
|
21
|
-
## 2.2.1 (2016-12-28)
|
22
|
-
|
23
|
-
* fixed gem installation (2.2.0 was a broken release)
|
24
|
-
|
25
|
-
## 2.2.0 (2016-12-27)
|
26
|
-
|
27
|
-
* improved Windows support
|
28
|
-
* added Ruby 2.4 support
|
29
|
-
* added `bold` alias method for `bright`
|
30
|
-
|
31
|
-
## 2.1.0 (2016-01-24)
|
32
|
-
|
33
|
-
* added X11 color support
|
34
|
-
* fixed `require` issue when rainbow is used as a dependency in another gem
|
35
|
-
* improved Windows support
|
36
|
-
|
37
|
-
## 2.0.0 (2014-01-24)
|
38
|
-
|
39
|
-
* disable string mixin by default
|
40
|
-
|
41
|
-
## 1.99.2 (2014-01-24)
|
42
|
-
|
43
|
-
* bring back ruby 1.8 support
|
44
|
-
|
45
|
-
## 1.99.1 (2013-12-28)
|
46
|
-
|
47
|
-
* drop support for ruby 1.8
|
48
|
-
* `require "rainbow/string"` -> `require "rainbow/ext/string"`
|
49
|
-
* custom rainbow wrapper instances (with separate enabled/disabled state)
|
50
|
-
* shortcut methods for changing text color (`Rainbow("foo").red`)
|
51
|
-
|
52
|
-
## 1.99.0 (2013-12-26)
|
53
|
-
|
54
|
-
* preparation for dropping String monkey patching
|
55
|
-
* `require "rainbow/string"` if you want to use monkey patched String
|
56
|
-
* introduction of Rainbow() wrapper
|
57
|
-
* support for MRI 1.8.7, 1.9.2, 1.9.3, 2.0 and 2.1, JRuby and Rubinius
|
58
|
-
* deprecation of Sickill::Rainbow namespace (use Rainbow.enabled = true instead)
|
59
|
-
|
60
|
-
## 1.1.4 (2012-4-28)
|
61
|
-
|
62
|
-
* option for forcing coloring even when STDOUT is not a TTY (CLICOLOR_FORCE env var)
|
63
|
-
* fix for frozen strings
|
64
|
-
|
65
|
-
## 1.1.3 (2011-12-6)
|
66
|
-
|
67
|
-
* improved compatibility with MRI 1.8.7
|
68
|
-
* fix for regression with regards to original string mutation
|
69
|
-
|
70
|
-
## 1.1.2 (2011-11-13)
|
71
|
-
|
72
|
-
* improved compatibility with MRI 1.9.3
|
73
|
-
|
74
|
-
## 1.1.1 (2011-2-7)
|
75
|
-
|
76
|
-
* improved Windows support
|
77
|
-
|
78
|
-
## 1.1 (2010-6-7)
|
79
|
-
|
80
|
-
* option for enabling/disabling of escape code wrapping
|
81
|
-
* auto-disabling when STDOUT is not a TTY
|
82
|
-
|
83
|
-
## 1.0.4 (2009-11-27)
|
84
|
-
|
85
|
-
* support for 256 colors
|
86
|
-
|
87
|
-
## 1.0.3 (2009-7-26)
|
88
|
-
|
89
|
-
* rainbow methods don't mutate the original string object anymore
|
90
|
-
|
91
|
-
## 1.0.2 (2009-5-15)
|
92
|
-
|
93
|
-
* improved support for ruby 1.8.6 and 1.9.1
|
94
|
-
|
95
|
-
## 1.0.1 (2009-3-19)
|
96
|
-
|
97
|
-
* Windows support
|
98
|
-
|
99
|
-
## 1.0.0 (2008-7-21)
|
100
|
-
|
101
|
-
* initial version
|
data/lib/vendor/rainbow/Gemfile
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
source 'https://rubygems.org'
|
4
|
-
|
5
|
-
gemspec
|
6
|
-
|
7
|
-
gem 'rake'
|
8
|
-
|
9
|
-
group :test do
|
10
|
-
gem 'coveralls', require: false
|
11
|
-
gem 'rspec'
|
12
|
-
end
|
13
|
-
|
14
|
-
group :development do
|
15
|
-
gem 'mutant-rspec'
|
16
|
-
end
|
17
|
-
|
18
|
-
group :test, :development do
|
19
|
-
gem 'rubocop', '0.81.0', require: false # This version supports Ruby 2.3
|
20
|
-
end
|
21
|
-
|
22
|
-
group :guard do
|
23
|
-
gem 'guard'
|
24
|
-
gem 'guard-rspec'
|
25
|
-
end
|
26
|
-
|
27
|
-
platform :rbx do
|
28
|
-
gem 'json'
|
29
|
-
gem 'rubysl'
|
30
|
-
end
|
data/lib/vendor/rainbow/LICENSE
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright (c) Marcin Kulik
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -1,225 +0,0 @@
|
|
1
|
-
# Rainbow
|
2
|
-
|
3
|
-
[![Gem Version](https://badge.fury.io/rb/rainbow.svg)](https://rubygems.org/gems/rainbow)
|
4
|
-
[![Build Status](https://travis-ci.org/sickill/rainbow.svg?branch=master)](https://travis-ci.org/sickill/rainbow)
|
5
|
-
[![Build status](https://ci.appveyor.com/api/projects/status/vq4acb2c38642s5q?svg=true)](https://ci.appveyor.com/project/sickill/rainbow)
|
6
|
-
[![Code Climate](https://codeclimate.com/github/sickill/rainbow.svg)](https://codeclimate.com/github/sickill/rainbow)
|
7
|
-
[![Coverage Status](https://coveralls.io/repos/sickill/rainbow/badge.svg)](https://coveralls.io/r/sickill/rainbow)
|
8
|
-
|
9
|
-
Rainbow is a ruby gem for colorizing printed text on ANSI terminals.
|
10
|
-
|
11
|
-
It provides a string presenter object, which adds several methods to your
|
12
|
-
strings for wrapping them in [ANSI escape
|
13
|
-
codes](http://en.wikipedia.org/wiki/ANSI_escape_code). These codes when printed
|
14
|
-
in a terminal change text attributes like text color, background color,
|
15
|
-
intensity etc.
|
16
|
-
|
17
|
-
## Usage
|
18
|
-
|
19
|
-
To make your string colored wrap it with `Rainbow()` presenter and call
|
20
|
-
`.color(<color name>)` on it.
|
21
|
-
|
22
|
-
### Example
|
23
|
-
|
24
|
-
```ruby
|
25
|
-
require 'rainbow'
|
26
|
-
|
27
|
-
puts Rainbow("this is red").red + " and " + Rainbow("this on yellow bg").bg(:yellow) + " and " + Rainbow("even bright underlined!").underline.bright
|
28
|
-
|
29
|
-
# => "\e[31mthis is red\e[0m and \e[43mthis on yellow bg\e[0m and \e[4m\e[1meven bright underlined!\e[0m"
|
30
|
-
```
|
31
|
-
|
32
|
-
Or, [watch this video example](https://asciinema.org/a/J928KpHoUQ0sl54ulOSOLE71E?rows=20&speed=2.5)
|
33
|
-
|
34
|
-
### Rainbow presenter API
|
35
|
-
|
36
|
-
Rainbow presenter adds the following methods to presented string:
|
37
|
-
|
38
|
-
* `color(c)` (with `foreground`, and `fg` aliases)
|
39
|
-
* `background(c)` (with `bg` alias)
|
40
|
-
* `bright`
|
41
|
-
* `underline`
|
42
|
-
* `blink`
|
43
|
-
* `inverse`
|
44
|
-
* `hide`
|
45
|
-
* `faint` (not well supported by terminal emulators)
|
46
|
-
* `italic` (not well supported by terminal emulators)
|
47
|
-
* `cross_out`, `strike`
|
48
|
-
|
49
|
-
Text color can also be changed by calling a method named by a color:
|
50
|
-
|
51
|
-
* `black`
|
52
|
-
* `red`
|
53
|
-
* `green`
|
54
|
-
* `yellow`
|
55
|
-
* `blue`
|
56
|
-
* `magenta`
|
57
|
-
* `cyan`
|
58
|
-
* `white`
|
59
|
-
* `aqua`
|
60
|
-
* `silver`
|
61
|
-
* `aliceblue`
|
62
|
-
* `indianred`
|
63
|
-
|
64
|
-
All of the methods return `self` (the presenter object) so you can chain method
|
65
|
-
calls:
|
66
|
-
|
67
|
-
```ruby
|
68
|
-
Rainbow("hola!").blue.bright.underline
|
69
|
-
```
|
70
|
-
|
71
|
-
### Refinement
|
72
|
-
|
73
|
-
If you want to use the Refinements version, you can:
|
74
|
-
|
75
|
-
```ruby
|
76
|
-
require 'rainbow/refinement'
|
77
|
-
using Rainbow
|
78
|
-
puts "Hi!".green
|
79
|
-
```
|
80
|
-
|
81
|
-
Here's an IRB session example:
|
82
|
-
|
83
|
-
```
|
84
|
-
>> 'Hello, World!'.blue.bright.underline
|
85
|
-
NoMethodError: undefined method `blue' for "Hello, World!":String
|
86
|
-
(ripl):1:in `<main>'
|
87
|
-
>> using Rainbow
|
88
|
-
=> main
|
89
|
-
>> 'Hello, World!'.blue.bright.underline
|
90
|
-
=> "\e[34m\e[1m\e[4mHello, World!\e[0m"
|
91
|
-
```
|
92
|
-
|
93
|
-
### Color specification
|
94
|
-
|
95
|
-
Both `color` and `background` accept color specified in any
|
96
|
-
of the following ways:
|
97
|
-
|
98
|
-
* ANSI color number (where 0 is black, 1 is red, 2 is green and so on):
|
99
|
-
`Rainbow("hello").color(1)`
|
100
|
-
|
101
|
-
* [ANSI color](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors) name or [X11 color](https://en.wikipedia.org/wiki/X11_color_names) name as a symbol:
|
102
|
-
`Rainbow("hello").color(:yellow)`.
|
103
|
-
This can be simplified to `Rainbow("hello").yellow`
|
104
|
-
|
105
|
-
See [Color list](#user-content-color-list) for all available color names.
|
106
|
-
Note that ANSI colors can be changed in accordance with terminal setting.
|
107
|
-
But X11 color is just a syntax sugar for RGB triplet. So you always see what you specified.
|
108
|
-
|
109
|
-
* RGB triplet as separate values in the range 0-255:
|
110
|
-
`Rainbow("hello").color(115, 23, 98)`
|
111
|
-
|
112
|
-
* RGB triplet as a hex string:
|
113
|
-
`Rainbow("hello").color("FFC482")` or `Rainbow("hello").color("#FFC482")`
|
114
|
-
|
115
|
-
When you specify a color with a RGB triplet rainbow finds the nearest match
|
116
|
-
from 256 colors palette. Note that it requires a 256-colors capable terminal to
|
117
|
-
display correctly.
|
118
|
-
|
119
|
-
#### Example: Choose a random color
|
120
|
-
|
121
|
-
You can pick a random color with Rainbow, it's a one-liner:
|
122
|
-
|
123
|
-
```ruby
|
124
|
-
colors = Range.new(0,7).to_a
|
125
|
-
"whoop dee doop".chars.map { |char| Rainbow(char).color(colors.sample) }.join
|
126
|
-
# => "\e[36mw\e[0m\e[37mh\e[0m\e[34mo\e[0m\e[34mo\e[0m\e[37mp\e[0m\e[34m \e[0m\e[36md\e[0m\e[33me\e[0m\e[34me\e[0m\e[37m \e[0m\e[32md\e[0m\e[35mo\e[0m\e[33mo\e[0m\e[36mp\e[0m"
|
127
|
-
|
128
|
-
colors = [:aliceblue, :antiquewhite, :aqua, :aquamarine, :azure, :beige, :bisque, :blanchedalmond, :blueviolet]
|
129
|
-
"whoop dee doop".chars.map { |char| Rainbow(char).color(colors.sample) }.join
|
130
|
-
# => "\e[38;5;135mw\e[0m\e[38;5;230mh\e[0m\e[38;5;231mo\e[0m\e[38;5;135mo\e[0m\e[38;5;231mp\e[0m\e[38;5;231m \e[0m\e[38;5;122md\e[0m\e[38;5;231me\e[0m\e[38;5;231me\e[0m\e[38;5;230m \e[0m\e[38;5;122md\e[0m\e[38;5;51mo\e[0m\e[38;5;51mo\e[0m\e[38;5;51mp\e[0m"
|
131
|
-
```
|
132
|
-
|
133
|
-
### Configuration
|
134
|
-
|
135
|
-
Rainbow can be enabled/disabled globally by setting:
|
136
|
-
|
137
|
-
```ruby
|
138
|
-
Rainbow.enabled = true/false
|
139
|
-
```
|
140
|
-
|
141
|
-
When disabled all the methods return an unmodified string
|
142
|
-
(`Rainbow("hello").red == "hello"`).
|
143
|
-
|
144
|
-
It's enabled by default, unless STDOUT/STDERR is not a TTY or a terminal is
|
145
|
-
dumb.
|
146
|
-
|
147
|
-
### Advanced usage
|
148
|
-
|
149
|
-
`Rainbow()` and `Rainbow.enabled` operate on the global Rainbow wrapper
|
150
|
-
instance. If you would like to selectively enable/disable coloring in separate
|
151
|
-
parts of your application you can get a new Rainbow wrapper instance for each
|
152
|
-
of them and control the state of coloring during the runtime.
|
153
|
-
|
154
|
-
```ruby
|
155
|
-
rainbow_one = Rainbow.new
|
156
|
-
rainbow_two = Rainbow.new
|
157
|
-
|
158
|
-
rainbow_one.enabled = false
|
159
|
-
|
160
|
-
Rainbow("hello").red # => "\e[31mhello\e[0m" ("hello" if not on TTY)
|
161
|
-
rainbow_one.wrap("hello").red # => "hello"
|
162
|
-
rainbow_two.wrap("hello").red # => "\e[31mhello\e[0m" ("hello" if not on TTY)
|
163
|
-
```
|
164
|
-
|
165
|
-
By default each new instance inherits enabled/disabled state from the global
|
166
|
-
`Rainbow.enabled`.
|
167
|
-
|
168
|
-
This feature comes handy for example when you have multiple output formatters
|
169
|
-
in your application and some of them print to a terminal but others write to a
|
170
|
-
file. Normally rainbow would detect that STDIN/STDERR is a TTY and would
|
171
|
-
colorize all the strings, even the ones that go through file writing
|
172
|
-
formatters. You can easily solve that by disabling coloring for the Rainbow
|
173
|
-
instances that are used by formatters with file output.
|
174
|
-
|
175
|
-
## Installation
|
176
|
-
|
177
|
-
Add it to your Gemfile:
|
178
|
-
|
179
|
-
```ruby
|
180
|
-
gem 'rainbow'
|
181
|
-
```
|
182
|
-
|
183
|
-
Or just install it via rubygems:
|
184
|
-
|
185
|
-
```ruby
|
186
|
-
gem install rainbow
|
187
|
-
```
|
188
|
-
|
189
|
-
## Color list
|
190
|
-
|
191
|
-
### ANSI colors
|
192
|
-
|
193
|
-
`black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white`
|
194
|
-
|
195
|
-
### X11 colors
|
196
|
-
|
197
|
-
`aliceblue`, `antiquewhite`, `aqua`, `aquamarine`, `azure`, `beige`, `bisque`,
|
198
|
-
`blanchedalmond`, `blueviolet`, `brown`, `burlywood`, `cadetblue`, `chartreuse`,
|
199
|
-
`chocolate`, `coral`, `cornflower`, `cornsilk`, `crimson`, `darkblue`,
|
200
|
-
`darkcyan`, `darkgoldenrod`, `darkgray`, `darkgreen`, `darkkhaki`,
|
201
|
-
`darkmagenta`, `darkolivegreen`, `darkorange`, `darkorchid`, `darkred`,
|
202
|
-
`darksalmon`, `darkseagreen`, `darkslateblue`, `darkslategray`, `darkturquoise`,
|
203
|
-
`darkviolet`, `deeppink`, `deepskyblue`, `dimgray`, `dodgerblue`, `firebrick`,
|
204
|
-
`floralwhite`, `forestgreen`, `fuchsia`, `gainsboro`, `ghostwhite`, `gold`,
|
205
|
-
`goldenrod`, `gray`, `greenyellow`, `honeydew`, `hotpink`, `indianred`,
|
206
|
-
`indigo`, `ivory`, `khaki`, `lavender`, `lavenderblush`, `lawngreen`,
|
207
|
-
`lemonchiffon`, `lightblue`, `lightcoral`, `lightcyan`, `lightgoldenrod`,
|
208
|
-
`lightgray`, `lightgreen`, `lightpink`, `lightsalmon`, `lightseagreen`,
|
209
|
-
`lightskyblue`, `lightslategray`, `lightsteelblue`, `lightyellow`, `lime`,
|
210
|
-
`limegreen`, `linen`, `maroon`, `mediumaquamarine`, `mediumblue`,
|
211
|
-
`mediumorchid`, `mediumpurple`, `mediumseagreen`, `mediumslateblue`,
|
212
|
-
`mediumspringgreen`, `mediumturquoise`, `mediumvioletred`, `midnightblue`,
|
213
|
-
`mintcream`, `mistyrose`, `moccasin`, `navajowhite`, `navyblue`, `oldlace`,
|
214
|
-
`olive`, `olivedrab`, `orange`, `orangered`, `orchid`, `palegoldenrod`,
|
215
|
-
`palegreen`, `paleturquoise`, `palevioletred`, `papayawhip`, `peachpuff`,
|
216
|
-
`peru`, `pink`, `plum`, `powderblue`, `purple`, `rebeccapurple`, `rosybrown`,
|
217
|
-
`royalblue`, `saddlebrown`, `salmon`, `sandybrown`, `seagreen`, `seashell`,
|
218
|
-
`sienna`, `silver`, `skyblue`, `slateblue`, `slategray`, `snow`, `springgreen`,
|
219
|
-
`steelblue`, `tan`, `teal`, `thistle`, `tomato`, `turquoise`, `violet`,
|
220
|
-
`webgray`, `webgreen`, `webmaroon`, `webpurple`, `wheat`, `whitesmoke`,
|
221
|
-
`yellowgreen`
|
222
|
-
|
223
|
-
## Authors
|
224
|
-
|
225
|
-
[Marcin Kulik](http://ku1ik.com/) and [great open-source contributors](https://github.com/sickill/rainbow/graphs/contributors).
|