term-ansicolor 1.11.0 → 1.11.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a99b1522303d7fa622793a7b924e74f897de9a031f775f723aac24bb3f7e6bf5
4
- data.tar.gz: 58f241a9bdbc068dae3c856aaf919939e3e1a25f831fa4fa6ed562d324365e55
3
+ metadata.gz: 35e1e389ded1bf66e7c0bfe078eac7953a411dcc334c817ed9c1261eb2094cf8
4
+ data.tar.gz: a1880a67537d5068df29c173d9196d9e29010657a14a867894cd3510d902323b
5
5
  SHA512:
6
- metadata.gz: 7e2716d88870533348a32230da0436fbb127d7dac440d4da5bbf292489b005d8d282f35b067bc14cd5919fbc4ad34ddfdbd1c2f016e5abc6d15fa11d09a988b9
7
- data.tar.gz: 4d9601059cdc1d848a0ca8a6b7aef4bc88656ac1e55c96f391269b4f8e53ef3ec216c7882d49af63f7dc45e7c2484d4354d0a88ee8544e3a27b580ef103fae01
6
+ metadata.gz: 2565679ee465ac18d4ec23630c380d26cbd4f014027bfa04308b8c10f6334eaca322688e2630ae9844ea18c75ba99e54483f066ec34f4f133ebdec00e01f07b2
7
+ data.tar.gz: 9d61627c7c7ae986b4d13cc43174d490b0d89da349f4f1337cc0f36f678c39ff7244ec48309056e9b1f54560b5e9e7e27e69eab011f8611ffd011135530d1cfd
data/README.md CHANGED
@@ -16,7 +16,7 @@ Use rubygems to install the gem:
16
16
 
17
17
  The homepage of this library is located at
18
18
 
19
- * http://flori.github.com/term-ansicolor
19
+ * https://github.com/flori/term-ansicolor
20
20
 
21
21
  ## Examples
22
22
 
@@ -29,10 +29,10 @@ The following executables are provided with Term::ANSIColor:
29
29
  programs are installed it can handle a lot of other image file formats.
30
30
  * `term_decolor`: decolors any text file that was colored with ANSI escape sequences
31
31
  * `term_mandel`: displays the mandelbrot set in the terminal
32
- * `term_snow`: displays falling snow in the terminal using ANSI movement
33
- sequences.
34
32
  * `term_plasma`: draws a plasma effect on the console, possibly animated and
35
33
  refreshed every `-n seconds`.
34
+ * `term_snow`: displays falling snow in the terminal using ANSI movement
35
+ sequences.
36
36
 
37
37
 
38
38
  Additionally the file examples/example.rb in the source/gem-distribution shows
data/Rakefile CHANGED
@@ -16,12 +16,14 @@ GemHadar do
16
16
  test_dir 'tests'
17
17
  ignore '.*.sw[pon]', 'pkg', 'Gemfile.lock', '.rvmrc', 'coverage',
18
18
  'tags', '.bundle', '.byebug_history', 'errors.lst', 'cscope.out'
19
+ package_ignore '.all_images.yml', '.tool-versions', '.gitignore', 'VERSION',
20
+ '.utilsrc', '.rspec', 'TODO',
21
+ *Dir.glob('.github/**/*', File::FNM_DOTMATCH)
19
22
 
20
23
  readme 'README.md'
21
24
  executables.merge Dir['bin/*'].map { |x| File.basename(x) }
22
25
 
23
26
  dependency 'tins', '~>1.0'
24
- dependency 'mize', '~>0.5'
25
27
  development_dependency 'simplecov'
26
28
  development_dependency 'test-unit'
27
29
  development_dependency 'utils'
@@ -50,7 +50,6 @@ module Term
50
50
  end
51
51
 
52
52
  class << self
53
- memoize method:
54
53
  def rgb_colors(options = {}, &block)
55
54
  colors = attributes.select(&:rgb_color?)
56
55
  if options.key?(:gray) && !options[:gray]
@@ -59,12 +58,10 @@ module Term
59
58
  colors.each(&block)
60
59
  end
61
60
 
62
- memoize method:
63
61
  def rgb_foreground_colors(options = {}, &block)
64
62
  rgb_colors(options).reject(&:background?).each(&block)
65
63
  end
66
64
 
67
- memoize method:
68
65
  def rgb_background_colors(options = {}, &block)
69
66
  rgb_colors(options).select(&:background?).each(&block)
70
67
  end
@@ -15,7 +15,7 @@ module Term
15
15
  end
16
16
  result = ''
17
17
  if Term::ANSIColor.coloring?
18
- result = "\e]8;#{"id=#{id}" unless id.nil?};" << link.to_str << "\e\\"
18
+ result = "\e]8;#{"id=#{id}" unless id.nil?};".dup << link.to_str << "\e\\"
19
19
  end
20
20
  if block_given?
21
21
  result << yield.to_s
@@ -94,6 +94,7 @@ module Term
94
94
  private
95
95
 
96
96
  def move_command(move, string = nil)
97
+ move = move.dup
97
98
  if block_given?
98
99
  move << yield.to_s
99
100
  elsif string.respond_to?(:to_str)
@@ -6,8 +6,12 @@ module Term
6
6
  def initialize(io, options = {})
7
7
  @io = io
8
8
  @options = options
9
- @buffer = ''
10
- @true_coloring = options[:true_coloring]
9
+ @buffer = ''.dup
10
+ if options[:true_coloring]
11
+ @color = -> pixel { on_color Attribute.true_color(pixel, @options) }
12
+ else
13
+ @color = -> pixel { on_color Attribute.nearest_rgb_color(pixel, @options) }
14
+ end
11
15
  end
12
16
 
13
17
  def reset_io
@@ -18,36 +22,32 @@ module Term
18
22
  parse_header
19
23
  end
20
24
 
21
- def each_row
25
+ def rows
22
26
  reset_io
23
- @height.times do
24
- yield parse_row
27
+
28
+ Enumerator.new do |yielder|
29
+ @height.times do
30
+ yielder.yield parse_row
31
+ end
25
32
  end
26
33
  end
27
34
 
28
35
  def to_a
29
- enum_for(:each_row).to_a
36
+ rows.to_a
30
37
  end
31
38
 
32
39
  def to_s
33
- result = ''
34
- each_row do |row|
40
+ rows.map do |row|
35
41
  last_pixel = nil
36
- for pixel in row
42
+ row.map do |pixel|
37
43
  if pixel != last_pixel
38
- color = if @true_coloring
39
- Attribute.true_color(pixel, @options)
40
- else
41
- Attribute.nearest_rgb_color(pixel, @options)
42
- end
43
- result << on_color(color)
44
44
  last_pixel = pixel
45
+ @color.(pixel) << ' '
46
+ else
47
+ ' '
45
48
  end
46
- result << ' '
47
- end
48
- result << reset << "\n"
49
- end
50
- result
49
+ end.join << reset << ?\n
50
+ end.join
51
51
  end
52
52
 
53
53
  private
@@ -103,9 +103,7 @@ module Term
103
103
  end
104
104
 
105
105
  def html
106
- s = '#'
107
- @values.each { |c| s << '%02x' % c }
108
- s
106
+ '#%02x%02x%02x' % @values
109
107
  end
110
108
 
111
109
  def css(percentage: false)
@@ -1,6 +1,6 @@
1
1
  module Term::ANSIColor
2
2
  # Term::ANSIColor version
3
- VERSION = '1.11.0'
3
+ VERSION = '1.11.1'
4
4
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
@@ -64,14 +64,14 @@ module Term
64
64
  elsif respond_to?(:to_str)
65
65
  to_str.gsub(COLORED_REGEXP, '')
66
66
  else
67
- ''
67
+ ''.dup
68
68
  end.extend(Term::ANSIColor)
69
69
  end
70
70
 
71
71
  alias uncolored uncolor
72
72
 
73
73
  def apply_code(code, string = nil, &block)
74
- result = ''
74
+ result = ''.dup
75
75
  result << "\e[#{code}m" if Term::ANSIColor.coloring?
76
76
  if block_given?
77
77
  result << yield.to_s
@@ -112,7 +112,7 @@ module Term
112
112
 
113
113
  class << self
114
114
  # Returns an array of all Term::ANSIColor attributes as symbols.
115
- memoize method: def term_ansicolor_attributes
115
+ def term_ansicolor_attributes
116
116
  ::Term::ANSIColor::Attribute.attributes.map(&:name)
117
117
  end
118
118
 
@@ -1,9 +1,9 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: term-ansicolor 1.11.0 ruby lib
2
+ # stub: term-ansicolor 1.11.1 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "term-ansicolor".freeze
6
- s.version = "1.11.0".freeze
6
+ s.version = "1.11.1".freeze
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib".freeze]
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
13
13
  s.email = "flori@ping.de".freeze
14
14
  s.executables = ["term_cdiff".freeze, "term_colortab".freeze, "term_decolor".freeze, "term_display".freeze, "term_mandel".freeze, "term_plasma".freeze, "term_snow".freeze]
15
15
  s.extra_rdoc_files = ["README.md".freeze, "lib/term/ansicolor.rb".freeze, "lib/term/ansicolor/attribute.rb".freeze, "lib/term/ansicolor/attribute/color256.rb".freeze, "lib/term/ansicolor/attribute/color8.rb".freeze, "lib/term/ansicolor/attribute/intense_color8.rb".freeze, "lib/term/ansicolor/attribute/text.rb".freeze, "lib/term/ansicolor/attribute/underline.rb".freeze, "lib/term/ansicolor/hsl_triple.rb".freeze, "lib/term/ansicolor/hyperlink.rb".freeze, "lib/term/ansicolor/movement.rb".freeze, "lib/term/ansicolor/ppm_reader.rb".freeze, "lib/term/ansicolor/rgb_color_metrics.rb".freeze, "lib/term/ansicolor/rgb_triple.rb".freeze, "lib/term/ansicolor/version.rb".freeze]
16
- s.files = [".all_images.yml".freeze, ".gitignore".freeze, ".utilsrc".freeze, "CHANGES".freeze, "COPYING".freeze, "Gemfile".freeze, "README.md".freeze, "Rakefile".freeze, "VERSION".freeze, "bin/term_cdiff".freeze, "bin/term_colortab".freeze, "bin/term_decolor".freeze, "bin/term_display".freeze, "bin/term_mandel".freeze, "bin/term_plasma".freeze, "bin/term_snow".freeze, "examples/example.rb".freeze, "examples/lambda-red-plain.ppm".freeze, "examples/lambda-red.png".freeze, "examples/lambda-red.ppm".freeze, "lib/term/ansicolor.rb".freeze, "lib/term/ansicolor/.keep".freeze, "lib/term/ansicolor/attribute.rb".freeze, "lib/term/ansicolor/attribute/color256.rb".freeze, "lib/term/ansicolor/attribute/color8.rb".freeze, "lib/term/ansicolor/attribute/intense_color8.rb".freeze, "lib/term/ansicolor/attribute/text.rb".freeze, "lib/term/ansicolor/attribute/underline.rb".freeze, "lib/term/ansicolor/hsl_triple.rb".freeze, "lib/term/ansicolor/hyperlink.rb".freeze, "lib/term/ansicolor/movement.rb".freeze, "lib/term/ansicolor/ppm_reader.rb".freeze, "lib/term/ansicolor/rgb_color_metrics.rb".freeze, "lib/term/ansicolor/rgb_triple.rb".freeze, "lib/term/ansicolor/version.rb".freeze, "term-ansicolor.gemspec".freeze, "tests/ansicolor_test.rb".freeze, "tests/attribute_test.rb".freeze, "tests/hsl_triple_test.rb".freeze, "tests/hyperlink_test.rb".freeze, "tests/ppm_reader_test.rb".freeze, "tests/rgb_color_metrics_test.rb".freeze, "tests/rgb_triple_test.rb".freeze, "tests/test_helper.rb".freeze]
16
+ s.files = ["CHANGES".freeze, "COPYING".freeze, "Gemfile".freeze, "README.md".freeze, "Rakefile".freeze, "bin/term_cdiff".freeze, "bin/term_colortab".freeze, "bin/term_decolor".freeze, "bin/term_display".freeze, "bin/term_mandel".freeze, "bin/term_plasma".freeze, "bin/term_snow".freeze, "examples/example.rb".freeze, "examples/lambda-red-plain.ppm".freeze, "examples/lambda-red.png".freeze, "examples/lambda-red.ppm".freeze, "lib/term/ansicolor.rb".freeze, "lib/term/ansicolor/.keep".freeze, "lib/term/ansicolor/attribute.rb".freeze, "lib/term/ansicolor/attribute/color256.rb".freeze, "lib/term/ansicolor/attribute/color8.rb".freeze, "lib/term/ansicolor/attribute/intense_color8.rb".freeze, "lib/term/ansicolor/attribute/text.rb".freeze, "lib/term/ansicolor/attribute/underline.rb".freeze, "lib/term/ansicolor/hsl_triple.rb".freeze, "lib/term/ansicolor/hyperlink.rb".freeze, "lib/term/ansicolor/movement.rb".freeze, "lib/term/ansicolor/ppm_reader.rb".freeze, "lib/term/ansicolor/rgb_color_metrics.rb".freeze, "lib/term/ansicolor/rgb_triple.rb".freeze, "lib/term/ansicolor/version.rb".freeze, "term-ansicolor.gemspec".freeze, "tests/ansicolor_test.rb".freeze, "tests/attribute_test.rb".freeze, "tests/hsl_triple_test.rb".freeze, "tests/hyperlink_test.rb".freeze, "tests/ppm_reader_test.rb".freeze, "tests/rgb_color_metrics_test.rb".freeze, "tests/rgb_triple_test.rb".freeze, "tests/test_helper.rb".freeze]
17
17
  s.homepage = "https://github.com/flori/term-ansicolor".freeze
18
18
  s.licenses = ["Apache-2.0".freeze]
19
19
  s.rdoc_options = ["--title".freeze, "Term-ansicolor - Ruby library that colors strings using ANSI escape sequences".freeze, "--main".freeze, "README.md".freeze]
@@ -28,5 +28,4 @@ Gem::Specification.new do |s|
28
28
  s.add_development_dependency(%q<test-unit>.freeze, [">= 0".freeze])
29
29
  s.add_development_dependency(%q<utils>.freeze, [">= 0".freeze])
30
30
  s.add_runtime_dependency(%q<tins>.freeze, ["~> 1.0".freeze])
31
- s.add_runtime_dependency(%q<mize>.freeze, ["~> 0.5".freeze])
32
31
  end
@@ -195,7 +195,7 @@ class ANSIColorTest < Test::Unit::TestCase
195
195
  end
196
196
 
197
197
  def test_frozen
198
- string = 'foo'
198
+ string = 'foo'.dup
199
199
  red = string.red
200
200
  string.extend(Term::ANSIColor).freeze
201
201
  assert string.frozen?
@@ -51,7 +51,7 @@ class HyperlinkTest < Test::Unit::TestCase
51
51
  end
52
52
 
53
53
  def test_with_stringy_self
54
- string = 'foo'
54
+ string = 'foo'.dup
55
55
  string.extend Term::ANSIColor
56
56
  assert_equal "\e]8;;#@link\e\\foo\e]8;;\e\\", string.hyperlink(@link)
57
57
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: term-ansicolor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.0
4
+ version: 1.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank
@@ -80,20 +80,6 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '1.0'
83
- - !ruby/object:Gem::Dependency
84
- name: mize
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '0.5'
90
- type: :runtime
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '0.5'
97
83
  description: This library uses ANSI escape sequences to control the attributes of
98
84
  terminal output
99
85
  email: flori@ping.de
@@ -123,15 +109,11 @@ extra_rdoc_files:
123
109
  - lib/term/ansicolor/rgb_triple.rb
124
110
  - lib/term/ansicolor/version.rb
125
111
  files:
126
- - ".all_images.yml"
127
- - ".gitignore"
128
- - ".utilsrc"
129
112
  - CHANGES
130
113
  - COPYING
131
114
  - Gemfile
132
115
  - README.md
133
116
  - Rakefile
134
- - VERSION
135
117
  - bin/term_cdiff
136
118
  - bin/term_colortab
137
119
  - bin/term_decolor
data/.all_images.yml DELETED
@@ -1,27 +0,0 @@
1
- dockerfile: |-
2
- RUN apk add --no-cache build-base git bash
3
- RUN bash <<NUR
4
- if [[ "$(ruby -e 'print RUBY_VERSION')" > '3' ]]
5
- then
6
- gem update --system
7
- gem install gem_hadar bundler
8
- else
9
- gem install gem_hadar
10
- gem install bundler -v 2.4.22
11
- fi
12
- NUR
13
-
14
- script: &script |-
15
- echo -e "\e[1m"
16
- ruby -v
17
- echo -e "\e[0m"
18
- bundle
19
- rake test
20
-
21
- images:
22
- ruby:3.3-alpine: *script
23
- ruby:3.2-alpine: *script
24
- ruby:3.1-alpine: *script
25
- ruby:3.0-alpine: *script
26
- ruby:2.7-alpine: *script
27
- ruby:2.6-alpine: *script
data/.gitignore DELETED
@@ -1,10 +0,0 @@
1
- .*.sw[pon]
2
- .bundle
3
- .byebug_history
4
- .rvmrc
5
- Gemfile.lock
6
- coverage
7
- cscope.out
8
- errors.lst
9
- pkg
10
- tags
data/.utilsrc DELETED
@@ -1,26 +0,0 @@
1
- # vim: set ft=ruby:
2
-
3
- search do
4
- prune_dirs /\A(\.svn|\.git|CVS|tmp|tags|coverage|pkg)\z/
5
- skip_files /(\A\.|\.sw[pon]\z|\.(log|fnm|jpg|jpeg|png|pdf|svg)\z|tags|~\z)/i
6
- end
7
-
8
- discover do
9
- prune_dirs /\A(\.svn|\.git|CVS|tmp|tags|coverage|pkg)\z/
10
- skip_files /(\A\.|\.sw[pon]\z|\.log\z|~\z)/
11
- binary false
12
- end
13
-
14
- strip_spaces do
15
- prune_dirs /\A(\..*|CVS|pkg)\z/
16
- skip_files /(\A\.|\.sw[pon]\z|\.log\z|~\z)/
17
- end
18
-
19
- probe do
20
- test_framework :"test-unit"
21
- end
22
-
23
- ssh_tunnel do
24
- terminal_multiplexer :tmux
25
- end
26
-
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 1.11.0