amazing_print 1.4.0 → 1.5.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/CHANGELOG.md +6 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +43 -37
- data/README.md +1 -2
- data/lib/amazing_print/colorize.rb +5 -12
- data/lib/amazing_print/colors.rb +37 -0
- data/lib/amazing_print/formatters/array_formatter.rb +1 -1
- data/lib/amazing_print/formatters/dir_formatter.rb +10 -1
- data/lib/amazing_print/formatters/file_formatter.rb +10 -1
- data/lib/amazing_print/formatters/hash_formatter.rb +2 -1
- data/lib/amazing_print/formatters/mswin_helper.rb +63 -0
- data/lib/amazing_print/inspector.rb +1 -1
- data/lib/amazing_print/version.rb +1 -1
- data/lib/amazing_print.rb +1 -1
- data/spec/colors_spec.rb +9 -4
- data/spec/ext/action_controller_spec.rb +3 -3
- data/spec/ext/active_record_spec.rb +24 -58
- data/spec/ext/nokogiri_spec.rb +4 -4
- data/spec/ext/sequel_spec.rb +1 -1
- data/spec/formats_spec.rb +82 -77
- data/spec/misc_spec.rb +14 -60
- data/spec/spec_helper.rb +7 -1
- metadata +10 -156
- data/lib/amazing_print/core_ext/string.rb +0 -45
- data/spec/core_ext/string_spec.rb +0 -15
@@ -1,45 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
# Copyright (c) 2010-2016 Michael Dvorkin and contributors
|
3
|
-
#
|
4
|
-
# AmazingPrint is freely distributable under the terms of MIT license.
|
5
|
-
# See LICENSE file or http://www.opensource.org/licenses/mit-license.php
|
6
|
-
#------------------------------------------------------------------------------
|
7
|
-
|
8
|
-
# frozen_string_literal: true
|
9
|
-
|
10
|
-
class String
|
11
|
-
#
|
12
|
-
# ANSI color codes:
|
13
|
-
# \e => escape
|
14
|
-
# 30 => color base
|
15
|
-
# 1 => bright
|
16
|
-
# 0 => normal
|
17
|
-
#
|
18
|
-
# For HTML coloring we use <kbd> tag instead of <span> to require monospace
|
19
|
-
# font. Note that beloved <tt> has been removed from HTML5.
|
20
|
-
#
|
21
|
-
%w[gray red green yellow blue purple cyan white].zip(
|
22
|
-
%w[black darkred darkgreen brown navy darkmagenta darkcyan slategray]
|
23
|
-
).each_with_index do |(color, shade), i|
|
24
|
-
# NOTE: Format strings are created once only, for performance, and remembered by closures.
|
25
|
-
|
26
|
-
term_bright_seq = "\e[1;#{30 + i}m%s\e[0m"
|
27
|
-
html_bright_seq = %(<kbd style="color:#{color}">%s</kbd>)
|
28
|
-
|
29
|
-
define_method color do |html = false, *|
|
30
|
-
(html ? html_bright_seq : term_bright_seq) % self
|
31
|
-
end
|
32
|
-
|
33
|
-
term_normal_seq = "\e[0;#{30 + i}m%s\e[0m"
|
34
|
-
html_normal_seq = %(<kbd style="color:#{shade}">%s</kbd>)
|
35
|
-
|
36
|
-
define_method "#{color}ish" do |html = false, *|
|
37
|
-
(html ? html_normal_seq : term_normal_seq) % self
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
# Remove ANSI color codes.
|
42
|
-
def uncolor
|
43
|
-
gsub(/\e\[[0-9;]*m/, '')
|
44
|
-
end
|
45
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
RSpec.describe 'String extensions' do
|
6
|
-
%i[gray red green yellow blue purple cyan white].each_with_index do |color, i|
|
7
|
-
it "has #{color} color" do
|
8
|
-
expect(color.to_s.send(color)).to eq("\e[1;#{30 + i}m#{color}\e[0m")
|
9
|
-
end
|
10
|
-
|
11
|
-
it "has #{color}ish color" do
|
12
|
-
expect(color.to_s.send(:"#{color}ish")).to eq("\e[0;#{30 + i}m#{color}\e[0m")
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|