term-ansicolor 1.10.2 → 1.10.4

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: 3cbfd241e244b761869192a65bdf1ca6a11ca79910c8daa6633ce6a5aec73d5f
4
- data.tar.gz: afe01235e057c5b6faa4b31a13369b8f86a00f9aca4bf07baf95a246ec7cf473
3
+ metadata.gz: d75f19d115fdee4233a120ece01a38b75c7f0cff14243e477def07b314f55b42
4
+ data.tar.gz: 9a3c5f4ac0abbd01a552ce2e5358bd1d3b2825c392495c941209e71cdbfb8e07
5
5
  SHA512:
6
- metadata.gz: ce2c8eaffdaa0e859738f01ab9276b70c2463fa5f647b5e2f5220b6c55c981eb5873a4255a404f17dfecf10479b4a6dfbd6a5bd7692ff1d2954a2d286658248c
7
- data.tar.gz: 93733afa943c51b91c530897ce1cda156c927fd993a24defac4f647db9582ce0b8bb791bb272eb4b59f40afcc59af728dbf03ecb725a742013bca5ecb4696d3a
6
+ metadata.gz: '015294663f0738e6cbeed73b3aa34d7ff6a19a9bc13be6ab683a750956cc854dae0d7630e606ff298252142f35f10b3a4cd02592761d72403bfd2d3de845be82'
7
+ data.tar.gz: 18741931918cf7c07192263ea683c69c7b6074d44572267e0d01d84d27a0f00ea66a0ae2d95ed2b96eee0e176bdf5f791f92d5aefb78a806ede47f2cc2a3b0ae
data/README.md CHANGED
@@ -22,13 +22,15 @@ The homepage of this library is located at
22
22
 
23
23
  The following executables are provided with Term::ANSIColor:
24
24
 
25
- * `cdiff`: colors a diff patch
26
- * `decolor`: decolors any text file that was colored with ANSI escape sequences
27
- * `colortab`: Displays a table of the 256 terminal colors with their indices and
25
+ * `term_cdiff`: colors a diff patch
26
+ * `term_colortab`: Displays a table of the 256 terminal colors with their indices and
28
27
  nearest html equivalents.
29
28
  * `term_display`: displays a ppm3 or ppm6 image file in the terminal. If the netpbm
30
29
  programs are installed it can handle a lot of other image file formats.
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.
32
34
 
33
35
  Additionally the file examples/example.rb in the source/gem-distribution shows
34
36
  how this library can be used.
data/Rakefile CHANGED
@@ -21,7 +21,7 @@ GemHadar do
21
21
  executables.merge Dir['bin/*'].map { |x| File.basename(x) }
22
22
 
23
23
  dependency 'tins', '~>1.0'
24
- dependency 'mize'
24
+ dependency 'mize', '~>0.5'
25
25
  development_dependency 'simplecov'
26
26
  development_dependency 'test-unit'
27
27
  development_dependency 'utils'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.10.2
1
+ 1.10.4
data/bin/term_mandel CHANGED
@@ -1,31 +1,32 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'term/ansicolor'
4
+ include Term::ANSIColor
4
5
  require 'tins/xt'
5
- require "complex"
6
6
  include Tins::GO
7
+ require "complex"
7
8
 
8
- @width, @height = Tins::Terminal.cols, Tins::Terminal.lines
9
+ $width, $height = Tins::Terminal.cols, Tins::Terminal.lines
10
+ $height *= 2
9
11
 
10
12
  def color_random
11
13
  (1..3).map { rand(255) }
12
14
  end
13
15
 
14
16
  def draw_set(rx, ry)
15
- sx = (rx.end - rx.begin).abs / @width
16
- sy = (ry.end - ry.begin).abs / @height
17
+ sx = (rx.end - rx.begin).abs / $width
18
+ sy = (ry.end - ry.begin).abs / $height
17
19
 
18
- ac = Term::ANSIColor
19
20
  steps = 16
20
- color = (5.times.map { color_random } + [ 0, 0, 0 ]).map { ac::Attribute[_1] }
21
+ color = (5.times.map { color_random } + [ 0, 0, 0 ]).map { Attribute[_1] }
21
22
  color = color[1..-1].inject(color[0,1]) { |c, x|
22
23
  c + c.last.gradient_to(x, steps:)
23
24
  }
24
25
  iters = color.size - 2
25
26
 
26
- text = ''
27
- for j in 0...@height
28
- for i in 0...@width
27
+ data = [ [] ]
28
+ for j in 0...$height
29
+ for i in 0...$width
29
30
  n, z_n = 0, Complex(0, 0)
30
31
  c = Complex(sx * i + rx.begin, sy * j + ry.begin)
31
32
  while n <= iters
@@ -33,11 +34,18 @@ def draw_set(rx, ry)
33
34
  z_n = z_n ** 2 + c
34
35
  n += 1
35
36
  end
36
- text << ac.on_color(color[n]) << ' '
37
+ data.last << n
38
+ end
39
+ data << []
40
+ end
41
+ screen = ''
42
+ (0...$height).step(2) do |j|
43
+ (0...$width).each do |i|
44
+ screen << color(color[data[j][i]]) <<
45
+ on_color(color[data[j + 1][i]]) << ?▀
37
46
  end
38
- text << ac.reset << "\n"
39
47
  end
40
- puts text
48
+ print move_home, screen, reset
41
49
  end
42
50
 
43
51
  opts = go 'x:y'
@@ -15,12 +15,12 @@ module Term
15
15
  dashed: '4:5',
16
16
  }.fetch(type) { raise ArgumentError, "invalid line type" }
17
17
  if color
18
- a = Term::ANSIColor::Attribute[color]
18
+ a = Term::ANSIColor::Attribute[color]
19
19
  color_code =
20
- if a.true_color? || a.rgb_color? || a.direct?
21
- color_code = "\e[58;2;#{a.rgb.to_a * ?;}"
20
+ if rgb = a.ask_and_send(:to_rgb_triple).full?(:to_a)
21
+ "\e[58;2;#{rgb * ?;}"
22
22
  else
23
- raise ArgumentError, "invalid color #{a.name.inspect}"
23
+ raise ArgumentError, "invalid color #{a&.name.inspect}"
24
24
  end
25
25
  code = "#{code}m#{color_code}"
26
26
  end
@@ -72,8 +72,8 @@ module Term
72
72
 
73
73
  def initialize(hue, saturation, lightness)
74
74
  @hue = Float(hue) % 360
75
- @saturation = [ [ Float(saturation), 0 ].max, 100 ].min
76
- @lightness = [ [ Float(lightness), 0 ].max, 100 ].min
75
+ @saturation = Float(saturation).clamp(0, 100)
76
+ @lightness = Float(lightness).clamp(0, 100)
77
77
  end
78
78
 
79
79
  attr_reader :hue
@@ -59,9 +59,7 @@ module Term
59
59
  end
60
60
 
61
61
  def initialize(red, green, blue)
62
- @values = [ red, green, blue ].map { |v|
63
- [ [ Integer(v), 0 ].max, 0xff ].min
64
- }
62
+ @values = [ red, green, blue ].map! { |v| v.clamp(0, 0xff) }
65
63
  end
66
64
 
67
65
  def red
@@ -1,6 +1,6 @@
1
1
  module Term::ANSIColor
2
2
  # Term::ANSIColor version
3
- VERSION = '1.10.2'
3
+ VERSION = '1.10.4'
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:
@@ -1,4 +1,5 @@
1
1
  require 'tins/xt/full'
2
+ require 'tins/xt/ask_and_send'
2
3
  require 'mize'
3
4
 
4
5
  module Term
@@ -1,14 +1,14 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: term-ansicolor 1.10.2 ruby lib
2
+ # stub: term-ansicolor 1.10.4 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "term-ansicolor".freeze
6
- s.version = "1.10.2".freeze
6
+ s.version = "1.10.4".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]
10
10
  s.authors = ["Florian Frank".freeze]
11
- s.date = "2024-06-22"
11
+ s.date = "2024-07-15"
12
12
  s.description = "This library uses ANSI escape sequences to control the attributes of terminal output".freeze
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_snow".freeze]
@@ -23,10 +23,10 @@ Gem::Specification.new do |s|
23
23
 
24
24
  s.specification_version = 4
25
25
 
26
- s.add_development_dependency(%q<gem_hadar>.freeze, ["~> 1.15.0".freeze])
26
+ s.add_development_dependency(%q<gem_hadar>.freeze, ["~> 1.16.0".freeze])
27
27
  s.add_development_dependency(%q<simplecov>.freeze, [">= 0".freeze])
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".freeze])
31
+ s.add_runtime_dependency(%q<mize>.freeze, ["~> 0.5".freeze])
32
32
  end
@@ -134,6 +134,14 @@ class ANSIColorTest < Test::Unit::TestCase
134
134
  assert_equal Term::ANSIColor.attributes, 'foo'.attributes
135
135
  end
136
136
 
137
+ def test_underline_invalid_type
138
+ assert_raises(ArgumentError) { Term::ANSIColor.underline(type: :nix) { 'foo' } }
139
+ end
140
+
141
+ def test_underline_invalid_color
142
+ assert_raises(ArgumentError) { Term::ANSIColor.underline(color: :nix) { 'foo' } }
143
+ end
144
+
137
145
  def test_underline
138
146
  foo = 'foo'
139
147
  assert_equal "\e[4mfoo\e[0m", Term::ANSIColor.underline { foo }
@@ -80,6 +80,6 @@ class HSLTripleTest < Test::Unit::TestCase
80
80
  end
81
81
 
82
82
  def test_method_missing
83
- assert_raise(NoMethodError) { @pastel_green_hsl.foo }
83
+ assert_raises(NoMethodError) { @pastel_green_hsl.foo }
84
84
  end
85
85
  end
@@ -43,7 +43,7 @@ class HyperlinkTest < Test::Unit::TestCase
43
43
  end
44
44
 
45
45
  def test_hyperlink_block_arg
46
- assert_raise(ArgumentError) { hyperlink(@link, 'bar') { 'baz' } }
46
+ assert_raises(ArgumentError) { hyperlink(@link, 'bar') { 'baz' } }
47
47
  assert_equal(
48
48
  "\e]8;;#@link\e\\foo\e]8;;\e\\",
49
49
  hyperlink(@link) { 'foo' }
@@ -96,6 +96,6 @@ class RgbTripleTest < Test::Unit::TestCase
96
96
  end
97
97
 
98
98
  def test_method_missing
99
- assert_raise(NoMethodError) { RGBTriple.new(0, 0, 0).foo }
99
+ assert_raises(NoMethodError) { RGBTriple.new(0, 0, 0).foo }
100
100
  end
101
101
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: term-ansicolor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.2
4
+ version: 1.10.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-22 00:00:00.000000000 Z
11
+ date: 2024-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gem_hadar
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.15.0
19
+ version: 1.16.0
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.15.0
26
+ version: 1.16.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: simplecov
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -84,16 +84,16 @@ dependencies:
84
84
  name: mize
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: '0.5'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: '0.5'
97
97
  description: This library uses ANSI escape sequences to control the attributes of
98
98
  terminal output
99
99
  email: flori@ping.de