colored2 4.0.0 → 4.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 +4 -4
- data/{LICENSE → LICENSE.txt} +1 -0
- data/README.md +16 -6
- data/Rakefile +42 -13
- data/docs/badges/coverage_badge.svg +21 -0
- data/docs/img/colored2-session1.avif +0 -0
- data/docs/img/colored2-session2.avif +0 -0
- data/lib/colored2/ascii_decorator.rb +2 -1
- data/lib/colored2/codes.rb +15 -15
- data/lib/colored2/version.rb +1 -1
- data/lib/colored2.rb +2 -2
- metadata +8 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a30cfa9bcd56b29ef4168d36ae33b98bb75f3632b4602526fbe2942e0867df8b
|
|
4
|
+
data.tar.gz: e570b2329be8821eb4bfa5f66011d5c1a8c0d0acfe72585fb2a91bb78ae37a57
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f5c18014c5bf5cb1ae465ee1559ffe8cadd538e5eff78d06866f9b4f9c973c031a9b058cee13ddd09cfc7469f7d45dc9eafe1154116383dda81c52d491faaf28
|
|
7
|
+
data.tar.gz: dd4695e78af9f23e223b4397e96cadc6d1ead91300501aa39d3432ec02e53718c7483b45b39702e633d31e6fd8f71f5e0f86e6f7b73cb99270ccedfd670b3336
|
data/{LICENSE → LICENSE.txt}
RENAMED
data/README.md
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
|
|
2
2
|
[](https://github.com/kigster/colored2/actions/workflows/ruby-ci.yml)
|
|
3
3
|
[](https://github.com/kigster/colored2/actions/workflows/rubocop-ci.yml)
|
|
4
|
+

|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
[](https://gitter.im/colored2)
|
|
6
|
+
  [](https://app.gitter.im/#/room/#colored2:gitter.im)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
# Colored2
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
The most downloaded ANSI color gem you'll find :-)
|
|
11
|
+
|
|
12
|
+
[](https://rubygems.org/gems/colored2)
|
|
13
|
+
|
|
14
|
+
## Backstory
|
|
15
|
+
|
|
16
|
+
It's an actively maintained fork of Chris [@defunkt](https://github.com/defunkt) Wanstrath's gem [colored](https://github.com/defunkt/colored), which appears to be no longer supported. So instead of accepting this as a pull request, a new gem was born.
|
|
11
17
|
|
|
12
18
|
This fork comes with a slightly spruced up syntax, some additional features, and a test suite written in [RSpec](http://rspec.info/).
|
|
13
19
|
|
|
@@ -22,7 +28,7 @@ In addition to the simple syntax of the original gem, which affected only the st
|
|
|
22
28
|
|
|
23
29
|
If no block or argument is provided, the color is left open-ended, and must be explicitly reset – when using the 'bang' notation.
|
|
24
30
|
|
|
25
|
-

|
|
26
32
|
|
|
27
33
|
### Complete set of colors:
|
|
28
34
|
|
|
@@ -57,7 +63,7 @@ To color numbers, require the following file, which automatically decorates `Int
|
|
|
57
63
|
|
|
58
64
|
Below is an `IRB` — session that shows a slightly more advanced usage.
|
|
59
65
|
|
|
60
|
-

|
|
61
67
|
|
|
62
68
|
## Additional Helpers
|
|
63
69
|
|
|
@@ -87,6 +93,10 @@ Or install it yourself as:
|
|
|
87
93
|
|
|
88
94
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
89
95
|
|
|
96
|
+
## Support
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
90
100
|
## Contributing
|
|
91
101
|
|
|
92
102
|
Bug reports and pull requests are welcome on GitHub at [https://github.com/kigster/colored2](https://github.com/kigster/colored2).
|
data/Rakefile
CHANGED
|
@@ -1,17 +1,46 @@
|
|
|
1
1
|
# frozen_string_literal: false
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
5
|
-
require
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
3
|
+
require "bundler/gem_tasks"
|
|
4
|
+
require "rspec/core/rake_task"
|
|
5
|
+
require "timeout"
|
|
6
|
+
require "yard"
|
|
7
|
+
|
|
8
|
+
def shell(*args)
|
|
9
|
+
puts "running: #{args.join(' ')}"
|
|
10
|
+
system(args.join(" "))
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
task :clean do
|
|
14
|
+
shell("rm -rf pkg/ tmp/ coverage/ doc/")
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
task
|
|
17
|
+
task gem: [:build] do
|
|
18
|
+
shell("gem install pkg/*")
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
task permissions: [:clean] do
|
|
22
|
+
# One traversal replaces a six-level glob chain that printed "No such file
|
|
23
|
+
# or directory" for every level this project does not have, skipped dotfiles
|
|
24
|
+
# entirely, and silently stopped at depth six. .git is pruned: its objects
|
|
25
|
+
# have no business being group-readable.
|
|
26
|
+
shell("find . -path ./.git -prune -o -type d -exec chmod o+rx,g+rx {} + -o -type f -exec chmod o+r,g+r {} +")
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
desc "Build the gem locally"
|
|
30
|
+
task build: :permissions
|
|
31
|
+
|
|
32
|
+
desc 'Generate YARD docs into ./doc'
|
|
33
|
+
YARD::Rake::YardocTask.new("docs") do |t|
|
|
34
|
+
t.files = %w[lib/**/*.rb - README.md LICENSE.txt CHANGELOG.md docs/badge/coverage_badge.svg]
|
|
35
|
+
t.options = ['--protected', '--private']
|
|
36
|
+
t.options.unshift("--title", '"colored2: ANSI color any Ruby object"')
|
|
37
|
+
t.after = -> do
|
|
38
|
+
# correct the path to the badge in the docs
|
|
39
|
+
system(%q[sed -i '' 's|<img src="docs|<img src="../docs|g' doc/index.html])
|
|
40
|
+
exec("open doc/index.html")
|
|
41
|
+
end if RUBY_PLATFORM =~ /darwin/
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
RSpec::Core::RakeTask.new(:spec)
|
|
45
|
+
|
|
46
|
+
task default: :spec
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="99" height="20">
|
|
3
|
+
<linearGradient id="b" x2="0" y2="100%">
|
|
4
|
+
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
|
|
5
|
+
<stop offset="1" stop-opacity=".1"/>
|
|
6
|
+
</linearGradient>
|
|
7
|
+
<mask id="a">
|
|
8
|
+
<rect width="99" height="20" rx="3" fill="#fff"/>
|
|
9
|
+
</mask>
|
|
10
|
+
<g mask="url(#a)">
|
|
11
|
+
<path fill="#555" d="M0 0h63v20H0z"/>
|
|
12
|
+
<path fill="#4c1" d="M63 0h36v20H63z"/>
|
|
13
|
+
<path fill="url(#b)" d="M0 0h99v20H0z"/>
|
|
14
|
+
</g>
|
|
15
|
+
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11">
|
|
16
|
+
<text x="31.5" y="15" fill="#010101" fill-opacity=".3">coverage</text>
|
|
17
|
+
<text x="31.5" y="14">coverage</text>
|
|
18
|
+
<text x="80" y="15" fill="#010101" fill-opacity=".3">99%</text>
|
|
19
|
+
<text x="80" y="14">99%</text>
|
|
20
|
+
</g>
|
|
21
|
+
</svg>
|
|
Binary file
|
|
Binary file
|
|
@@ -56,6 +56,7 @@ module Colored2
|
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
extend Forwardable
|
|
59
|
+
|
|
59
60
|
def_delegators :@my_class, :enable!, :disable!
|
|
60
61
|
|
|
61
62
|
attr_accessor :string, :my_class
|
|
@@ -76,7 +77,7 @@ module Colored2
|
|
|
76
77
|
Colored2::Effect.new(options[:effect])
|
|
77
78
|
].compact.join
|
|
78
79
|
|
|
79
|
-
colored = ''
|
|
80
|
+
colored = +''
|
|
80
81
|
colored << escape_sequence if options[:beginning] == :on
|
|
81
82
|
colored << string
|
|
82
83
|
if options[:end]
|
data/lib/colored2/codes.rb
CHANGED
|
@@ -2,25 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
module Colored2
|
|
4
4
|
COLORS = {
|
|
5
|
-
black:
|
|
6
|
-
red:
|
|
7
|
-
green:
|
|
8
|
-
yellow:
|
|
9
|
-
blue:
|
|
5
|
+
black: 30,
|
|
6
|
+
red: 31,
|
|
7
|
+
green: 32,
|
|
8
|
+
yellow: 33,
|
|
9
|
+
blue: 34,
|
|
10
10
|
magenta: 35,
|
|
11
|
-
cyan:
|
|
12
|
-
white:
|
|
11
|
+
cyan: 36,
|
|
12
|
+
white: 37
|
|
13
13
|
}.freeze
|
|
14
14
|
|
|
15
15
|
EFFECTS = {
|
|
16
|
-
no_color:
|
|
17
|
-
bold:
|
|
18
|
-
dark:
|
|
19
|
-
italic:
|
|
16
|
+
no_color: 0,
|
|
17
|
+
bold: 1,
|
|
18
|
+
dark: 2,
|
|
19
|
+
italic: 3,
|
|
20
20
|
underlined: 4,
|
|
21
|
-
reversed:
|
|
22
|
-
plain:
|
|
23
|
-
normal:
|
|
21
|
+
reversed: 7,
|
|
22
|
+
plain: 21, # non-bold
|
|
23
|
+
normal: 22
|
|
24
24
|
}.freeze
|
|
25
25
|
|
|
26
26
|
class Code
|
|
@@ -59,7 +59,7 @@ module Colored2
|
|
|
59
59
|
|
|
60
60
|
class BackgroundColor < TextColor
|
|
61
61
|
def value
|
|
62
|
-
super
|
|
62
|
+
super(10)
|
|
63
63
|
end
|
|
64
64
|
end
|
|
65
65
|
end
|
data/lib/colored2/version.rb
CHANGED
data/lib/colored2.rb
CHANGED
|
@@ -52,7 +52,7 @@ module Colored2
|
|
|
52
52
|
surround_with_color(color:, color_self: true, string:, &block)
|
|
53
53
|
end
|
|
54
54
|
|
|
55
|
-
define_method("#{color}!"
|
|
55
|
+
define_method(:"#{color}!") do |string = nil, &block|
|
|
56
56
|
surround_with_color(color:, color_self: false, string:, &block)
|
|
57
57
|
end
|
|
58
58
|
end
|
|
@@ -64,7 +64,7 @@ module Colored2
|
|
|
64
64
|
surround_with_color(effect:, color_self: true, string:, &block)
|
|
65
65
|
end
|
|
66
66
|
|
|
67
|
-
define_method("#{effect}!"
|
|
67
|
+
define_method(:"#{effect}!") do |string = nil, &block|
|
|
68
68
|
surround_with_color(effect:, color_self: false, string:, &block)
|
|
69
69
|
end
|
|
70
70
|
end
|
metadata
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: colored2
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.
|
|
4
|
+
version: 4.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Chris Wanstrath
|
|
8
8
|
- Konstantin Gredeskoul
|
|
9
|
-
autorequire:
|
|
10
9
|
bindir: bin
|
|
11
10
|
cert_chain: []
|
|
12
|
-
date:
|
|
11
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
13
12
|
dependencies: []
|
|
14
13
|
description: |+
|
|
15
14
|
This is a heavily modified fork of http://github.com/defunkt/colored gem, with many
|
|
@@ -37,9 +36,12 @@ executables: []
|
|
|
37
36
|
extensions: []
|
|
38
37
|
extra_rdoc_files: []
|
|
39
38
|
files:
|
|
40
|
-
- LICENSE
|
|
39
|
+
- LICENSE.txt
|
|
41
40
|
- README.md
|
|
42
41
|
- Rakefile
|
|
42
|
+
- docs/badges/coverage_badge.svg
|
|
43
|
+
- docs/img/colored2-session1.avif
|
|
44
|
+
- docs/img/colored2-session2.avif
|
|
43
45
|
- lib/colored2.rb
|
|
44
46
|
- lib/colored2/ascii_decorator.rb
|
|
45
47
|
- lib/colored2/codes.rb
|
|
@@ -52,7 +54,6 @@ licenses:
|
|
|
52
54
|
- MIT
|
|
53
55
|
metadata:
|
|
54
56
|
rubygems_mfa_required: 'true'
|
|
55
|
-
post_install_message:
|
|
56
57
|
rdoc_options: []
|
|
57
58
|
require_paths:
|
|
58
59
|
- lib
|
|
@@ -67,9 +68,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
67
68
|
- !ruby/object:Gem::Version
|
|
68
69
|
version: '0'
|
|
69
70
|
requirements: []
|
|
70
|
-
rubygems_version:
|
|
71
|
-
signing_key:
|
|
71
|
+
rubygems_version: 4.0.23
|
|
72
72
|
specification_version: 4
|
|
73
|
-
summary:
|
|
73
|
+
summary: Zero dependencies ANSI coloring gem for Ruby objects.
|
|
74
74
|
test_files: []
|
|
75
75
|
...
|