![](https://seccdn.libravatar.org/avatar/e2145bc5cf53dda95c308a3c75e8fef3.jpg?s=120&d=mm&r=g)
Hello community, here is the log from the commit of package rubygem-term-ansicolor for openSUSE:Factory checked in at 2017-04-11 09:40:25 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-term-ansicolor (Old) and /work/SRC/openSUSE:Factory/.rubygem-term-ansicolor.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "rubygem-term-ansicolor" Tue Apr 11 09:40:25 2017 rev:13 rq:484841 version:1.5.0 Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-term-ansicolor/rubygem-term-ansicolor.changes 2016-10-10 16:22:59.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.rubygem-term-ansicolor.new/rubygem-term-ansicolor.changes 2017-04-11 09:40:39.551255966 +0200 @@ -1,0 +2,14 @@ +Wed Mar 29 04:33:26 UTC 2017 - coolo@suse.com + +- updated to version 1.5.0 + see installed CHANGES + +------------------------------------------------------------------- +Sat Mar 25 05:37:03 UTC 2017 - coolo@suse.com + +- updated to version 1.4.1 + see installed CHANGES + + 2017-03-24 - 1.4.1 * Correct triple html color support + +------------------------------------------------------------------- Old: ---- term-ansicolor-1.4.0.gem New: ---- term-ansicolor-1.5.0.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-term-ansicolor.spec ++++++ --- /var/tmp/diff_new_pack.0Y1PCd/_old 2017-04-11 09:40:42.766801729 +0200 +++ /var/tmp/diff_new_pack.0Y1PCd/_new 2017-04-11 09:40:42.770801164 +0200 @@ -1,7 +1,7 @@ # # spec file for package rubygem-term-ansicolor # -# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -24,7 +24,7 @@ # Name: rubygem-term-ansicolor -Version: 1.4.0 +Version: 1.5.0 Release: 0 %define mod_name term-ansicolor %define mod_full_name %{mod_name}-%{version} ++++++ term-ansicolor-1.4.0.gem -> term-ansicolor-1.5.0.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/.gitignore new/.gitignore --- old/.gitignore 2016-09-27 12:16:09.000000000 +0200 +++ new/.gitignore 2017-03-28 10:40:15.000000000 +0200 @@ -1,5 +1,6 @@ .*.sw[pon] .bundle +.byebug_history .rvmrc Gemfile.lock coverage diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/.travis.yml new/.travis.yml --- old/.travis.yml 2016-09-27 12:16:09.000000000 +0200 +++ new/.travis.yml 2017-03-28 10:40:15.000000000 +0200 @@ -3,12 +3,11 @@ - 2.1 - 2.2 - 2.3.1 + - 2.4.1 - ruby-head - jruby matrix: allow_failures: - rvm: ruby-head - rvm: jruby -env: - - CODECLIMATE_REPO_TOKEN=ef2c31d6fd3c385eef57dcb62374be51b56af36dd4405763d3e43a1c06330b33 sudo: false diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CHANGES new/CHANGES --- old/CHANGES 2016-09-27 12:16:09.000000000 +0200 +++ new/CHANGES 2017-03-28 10:40:15.000000000 +0200 @@ -1,3 +1,4 @@ +2017-03-24 - 1.4.1 * Correct triple html color support 2016-09-27 - 1.4.0 * Extend colorized strings with Term::ANSIColor 2015-06-23 - 1.3.2 * Fix release 1.3.1 2014-06-17 - 1.3.1 * This release was a bit premature, yanked it. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Gemfile new/Gemfile --- old/Gemfile 2016-09-27 12:16:09.000000000 +0200 +++ new/Gemfile 2017-03-28 10:40:15.000000000 +0200 @@ -3,5 +3,3 @@ source 'https://rubygems.org' gemspec - -gem "codeclimate-test-reporter", :group => :test, :require => nil diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Rakefile new/Rakefile --- old/Rakefile 2016-09-27 12:16:09.000000000 +0200 +++ new/Rakefile 2017-03-28 10:40:15.000000000 +0200 @@ -13,25 +13,15 @@ description 'This library uses ANSI escape sequences to control the attributes of terminal output' licenses << 'GPL-2' test_dir 'tests' - ignore '.*.sw[pon]', 'pkg', 'Gemfile.lock', '.rvmrc', 'coverage', 'tags', '.bundle' + ignore '.*.sw[pon]', 'pkg', 'Gemfile.lock', '.rvmrc', 'coverage', + 'tags', '.bundle', '.byebug_history' + readme 'README.rdoc' executables.merge Dir['bin/*'].map { |x| File.basename(x) } dependency 'tins', '~>1.0' development_dependency 'simplecov' - development_dependency 'minitest_tu_shim' + development_dependency 'test-unit' required_ruby_version '>= 2.0' - - install_library do - destdir = "#{ENV['DESTDIR']}" - libdir = CONFIG["sitelibdir"] - cd 'lib' do - for file in Dir['**/*.rb'] - dest = destdir + File.join(libdir, File.dirname(file)) - mkdir_p dest - install file, dest - end - end - end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/VERSION new/VERSION --- old/VERSION 2016-09-27 12:16:09.000000000 +0200 +++ new/VERSION 2017-03-28 10:40:15.000000000 +0200 @@ -1 +1 @@ -1.4.0 +1.5.0 Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/term/ansicolor/attribute.rb new/lib/term/ansicolor/attribute.rb --- old/lib/term/ansicolor/attribute.rb 2016-09-27 12:16:09.000000000 +0200 +++ new/lib/term/ansicolor/attribute.rb 2017-03-28 10:40:15.000000000 +0200 @@ -34,6 +34,7 @@ case when self === name then name when Array === name then nearest_rgb_color name + when name.respond_to?(:to_rgb_triple) then nearest_rgb_color(name.to_rgb_triple.to_a) when name.to_s =~ /\A(on_)?(\d+)\z/ then get "#$1color#$2" when name.to_s =~ /\A#([0-9a-f]{3}){1,2}\z/i then nearest_rgb_color name when name.to_s =~ /\Aon_#([0-9a-f]{3}){1,2}\z/i then nearest_rgb_on_color name diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/term/ansicolor/hsl_triple.rb new/lib/term/ansicolor/hsl_triple.rb --- old/lib/term/ansicolor/hsl_triple.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/term/ansicolor/hsl_triple.rb 2017-03-28 10:40:15.000000000 +0200 @@ -0,0 +1,169 @@ +module Term + module ANSIColor + class HSLTriple + def self.from_rgb_triple(rgb) + ps = rgb.to_a.map { |x| x / 255.0 } + p_min = ps.min + p_max = ps.max + p_red, p_green, p_blue = ps + + diff = p_max - p_min + l = (p_max + p_min) / 2 + + if diff.zero? + h = s = 0.0 + else + if l < 0.5 + s = diff / (p_max + p_min) + else + s = diff / (2 - p_max - p_min) + end + + diff_r = ( ( ( p_max - p_red ) / 6 ) + ( diff / 2 ) ) / diff + diff_g = ( ( ( p_max - p_green ) / 6 ) + ( diff / 2 ) ) / diff + diff_b = ( ( ( p_max - p_blue ) / 6 ) + ( diff / 2 ) ) / diff + + h = case p_max + when p_red + diff_b - diff_g + when p_green + (1 / 3.0) + diff_r - diff_b + when p_blue + (2 / 3.0) + diff_g - diff_r + end + + h < 0 and h += 1 + h > 1 and h -= 1 + end + from_hash( + hue: 360 * h, + saturation: 100 * s, + lightness: 100 * l + ) + end + + def self.from_css(css) + case css + when /\A\s*hsl\(\s*([^,\s]+)\s*,\s*([^%\s]+)\s*%\s*,\s*([^%\s]+)\s*%\s*\)\z/ + new(Float($1), Float($2), Float($3)) + end + end + + def self.from_hash(options) + new( + options[:hue].to_f, + options[:saturation].to_f, + options[:lightness].to_f + ) + end + + def self.[](thing) + case + when thing.respond_to?(:to_hsl_triple) then thing.to_hsl_triple + when thing.respond_to?(:to_hash) then from_hash(thing.to_hash) + when thing.respond_to?(:to_str) + thing = thing.to_str + from_css(thing.to_str) || + Term::ANSIColor::RGBTriple.from_html(thing).full?(:to_hsl_triple) || + Term::ANSIColor::RGBTriple.from_css(thing).full?(:to_hsl_triple) + else raise ArgumentError, "cannot convert #{thing.inspect} into #{self}" + end + end + + def initialize(hue, saturation, lightness) + @hue = Float(hue) % 360 + @saturation = [ [ Float(saturation), 0 ].max, 100 ].min + @lightness = [ [ Float(lightness), 0 ].max, 100 ].min + end + + attr_reader :hue + + attr_reader :saturation + + attr_reader :lightness + + def lighten(percentage) + self.class.new(@hue, @saturation, @lightness + percentage) + end + + def darken(percentage) + self.class.new(@hue, @saturation, @lightness - percentage) + end + + def saturate(percentage) + self.class.new(@hue, @saturation + percentage, @lightness) + end + + def desaturate(percentage) + self.class.new(@hue, @saturation - percentage, @lightness) + end + + def adjust_hue(degree) + self.class.new(@hue + degree, @saturation, @lightness) + end + + def grayscale + self.class.new(@hue, 0, @lightness) + end + + def complement + adjust_hue(180) + end + + def hue2rgb(x, y, h) + h < 0 and h += 1 + h > 1 and h -= 1 + (6 * h) < 1 and return x + (y - x) * 6 * h + (2 * h) < 1 and return y + (3 * h) < 2 and return x + (y - x) * ( (2 / 3.0) - h ) * 6 + x + end + private :hue2rgb + + def to_rgb_triple + h = @hue / 360.0 + s = @saturation / 100.0 + l = @lightness / 100.0 + + if s.zero? + r = 255 * l + g = 255 * l + b = 255 * l + else + if l < 0.5 + y = l * (1 + s) + else + y = (l + s) - (s * l) + end + + x = 2 * l - y + + r = 255 * hue2rgb(x, y, h + (1 / 3.0)) + g = 255 * hue2rgb(x, y, h) + b = 255 * hue2rgb(x, y, h - (1 / 3.0)) + end + Term::ANSIColor::RGBTriple.new(r.round, g.round, b.round) + end + + def to_hsl_triple + self + end + + def css + "hsl(%s,%s%%,%s%%)" % [ @hue, @saturation, @lightness ] + end + + def ==(other) + to_rgb_triple == other.to_rgb_triple + end + + def method_missing(name, *args, &block) + if Term::ANSIColor::RGBTriple.method_defined?(name) + to_rgb_triple.send(name, *args, &block) + else + super + end + end + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/term/ansicolor/rgb_triple.rb new/lib/term/ansicolor/rgb_triple.rb --- old/lib/term/ansicolor/rgb_triple.rb 2016-09-27 12:16:09.000000000 +0200 +++ new/lib/term/ansicolor/rgb_triple.rb 2017-03-28 10:40:15.000000000 +0200 @@ -5,11 +5,11 @@ class RGBTriple include Term::ANSIColor::RGBColorMetricsHelpers::WeightedEuclideanDistance - def self.convert_value(color) + def self.convert_value(color, max: 255) color.nil? and raise ArgumentError, "missing color value" color = Integer(color) - (0..0xff) === color or raise ArgumentError, - "color value #{color.inspect} not between 0 and 255" + (0..max) === color or raise ArgumentError, + "color value #{color.inspect} not between 0 and #{max}" color end @@ -20,7 +20,16 @@ when /\A#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})\z/i new(*$~.captures.map { |c| convert_value(c.to_i(16)) }) when /\A#([0-9a-f])([0-9a-f])([0-9a-f])\z/i - new(*$~.captures.map { |c| convert_value(c.to_i(16) << 4) }) + new(*$~.captures.map { |c| convert_value((c + c).to_i(16)) }) + end + end + + def self.from_css(css) + case css + when /\A\s*rgb\(\s*([^%\s]+)\s*%\s*,\s*([^%\s]+)\s*%\s*,\s*([^%\s]+)\s*%\s*\)\z/ + new(*$~.captures.map { |c| convert_value(((Float(c) / 100) * 0xff).round) }) + when /\A\s*rgb\(\s*([^,\s]+)\s*,\s*([^,\s]+)\s*,\s*([^\)\s]+)\s*\)\z/ + new(*$~.captures.map { |c| convert_value((Float(c)).round) }) end end @@ -38,16 +47,21 @@ def self.[](thing) case - when thing.respond_to?(:to_rgb_triple) then thing - when thing.respond_to?(:to_ary) then RGBTriple.from_array(thing.to_ary) - when thing.respond_to?(:to_str) then RGBTriple.from_html(thing.to_str.sub(/\Aon_/, '')) # XXX somewhat hacky - when thing.respond_to?(:to_hash) then RGBTriple.from_hash(thing.to_hash) + when thing.respond_to?(:to_rgb_triple) then thing.to_rgb_triple + when thing.respond_to?(:to_ary) then from_array(thing.to_ary) + when thing.respond_to?(:to_str) + thing = thing.to_str + from_html(thing.sub(/\Aon_/, '')) || from_css(thing) || + Term::ANSIColor::HSLTriple.from_css(thing).full?(:to_rgb_triple) + when thing.respond_to?(:to_hash) then from_hash(thing.to_hash) else raise ArgumentError, "cannot convert #{thing.inspect} into #{self}" end end def initialize(red, green, blue) - @values = [ red, green, blue ] + @values = [ red, green, blue ].map { |v| + [ [ Integer(v), 0 ].max, 0xff ].min + } end def red @@ -62,6 +76,26 @@ @values[2] end + def percentages + @percentages ||= @values.map { |v| 100 * v / 255.0 } + end + + def red_p + percentages[0] + end + + def green_p + percentages[1] + end + + def blue_p + percentages[2] + end + + def invert + self.class.new(255 - red, 255 - green, 255 - blue) + end + def gray? red != 0 && red != 0xff && red == green && green == blue && blue == red end @@ -72,10 +106,22 @@ s end + def css(percentage: false) + if percentage + "rgb(%s%%,%s%%,%s%%)" % @values.map { |v| 100.0 * v / 255 } + else + "rgb(%u,%u,%u)" % @values + end + end + def to_rgb_triple self end + def to_hsl_triple + Term::ANSIColor::HSLTriple.from_rgb_triple(self) + end + attr_reader :values protected :values @@ -84,7 +130,11 @@ end def ==(other) - @values == other.values + @values == other.to_rgb_triple.values + end + + def color(string) + Term::ANSIColor.color(self, string) end def distance_to(other, options = {}) @@ -116,6 +166,14 @@ end gradient << other end + + def method_missing(name, *args, &block) + if Term::ANSIColor::HSLTriple.method_defined?(name) + to_hsl_triple.send(name, *args, &block) + else + super + end + end end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/term/ansicolor/version.rb new/lib/term/ansicolor/version.rb --- old/lib/term/ansicolor/version.rb 2016-09-27 12:16:09.000000000 +0200 +++ new/lib/term/ansicolor/version.rb 2017-03-28 10:40:15.000000000 +0200 @@ -1,6 +1,6 @@ module Term::ANSIColor # Term::ANSIColor version - VERSION = '1.4.0' + VERSION = '1.5.0' VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc: VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc: VERSION_MINOR = VERSION_ARRAY[1] # :nodoc: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/term/ansicolor.rb new/lib/term/ansicolor.rb --- old/lib/term/ansicolor.rb 2016-09-27 12:16:09.000000000 +0200 +++ new/lib/term/ansicolor.rb 2017-03-28 10:40:15.000000000 +0200 @@ -1,3 +1,5 @@ +require 'tins/xt/full' + module Term # The ANSIColor module can be used for namespacing and mixed into your own @@ -6,6 +8,7 @@ require 'term/ansicolor/version' require 'term/ansicolor/attribute' require 'term/ansicolor/rgb_triple' + require 'term/ansicolor/hsl_triple' require 'term/ansicolor/ppm_reader' require 'term/ansicolor/attribute/text' require 'term/ansicolor/attribute/color8' @@ -83,7 +86,7 @@ result = '' result << "\e[#{attribute.code}m" if Term::ANSIColor.coloring? if block_given? - result << yield + result << yield.to_s elsif string.respond_to?(:to_str) result << string.to_str elsif respond_to?(:to_str) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2016-09-27 12:16:09.000000000 +0200 +++ new/metadata 2017-03-28 10:40:15.000000000 +0200 @@ -1,14 +1,14 @@ --- !ruby/object:Gem::Specification name: term-ansicolor version: !ruby/object:Gem::Version - version: 1.4.0 + version: 1.5.0 platform: ruby authors: - Florian Frank autorequire: bindir: bin cert_chain: [] -date: 2016-09-27 00:00:00.000000000 Z +date: 2017-03-28 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: gem_hadar @@ -16,14 +16,14 @@ requirements: - - "~>" - !ruby/object:Gem::Version - version: 1.8.0 + version: 1.9.1 type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version - version: 1.8.0 + version: 1.9.1 - !ruby/object:Gem::Dependency name: simplecov requirement: !ruby/object:Gem::Requirement @@ -39,7 +39,7 @@ - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency - name: minitest_tu_shim + name: test-unit requirement: !ruby/object:Gem::Requirement requirements: - - ">=" @@ -84,6 +84,7 @@ - lib/term/ansicolor/attribute/color8.rb - lib/term/ansicolor/attribute/intense_color8.rb - lib/term/ansicolor/attribute/text.rb +- lib/term/ansicolor/hsl_triple.rb - lib/term/ansicolor/ppm_reader.rb - lib/term/ansicolor/rgb_color_metrics.rb - lib/term/ansicolor/rgb_triple.rb @@ -119,6 +120,7 @@ - lib/term/ansicolor/attribute/color8.rb - lib/term/ansicolor/attribute/intense_color8.rb - lib/term/ansicolor/attribute/text.rb +- lib/term/ansicolor/hsl_triple.rb - lib/term/ansicolor/ppm_reader.rb - lib/term/ansicolor/rgb_color_metrics.rb - lib/term/ansicolor/rgb_triple.rb @@ -126,6 +128,7 @@ - term-ansicolor.gemspec - tests/ansicolor_test.rb - tests/attribute_test.rb +- tests/hsl_triple_test.rb - tests/ppm_reader_test.rb - tests/rgb_color_metrics_test.rb - tests/rgb_triple_test.rb @@ -154,13 +157,14 @@ version: '0' requirements: [] rubyforge_project: -rubygems_version: 2.5.1 +rubygems_version: 2.6.11 signing_key: specification_version: 4 summary: Ruby library that colors strings using ANSI escape sequences test_files: - tests/ansicolor_test.rb - tests/attribute_test.rb +- tests/hsl_triple_test.rb - tests/ppm_reader_test.rb - tests/rgb_color_metrics_test.rb - tests/rgb_triple_test.rb diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/term-ansicolor.gemspec new/term-ansicolor.gemspec --- old/term-ansicolor.gemspec 2016-09-27 12:16:09.000000000 +0200 +++ new/term-ansicolor.gemspec 2017-03-28 10:40:15.000000000 +0200 @@ -1,45 +1,45 @@ # -*- encoding: utf-8 -*- -# stub: term-ansicolor 1.4.0 ruby lib +# stub: term-ansicolor 1.5.0 ruby lib Gem::Specification.new do |s| - s.name = "term-ansicolor" - s.version = "1.4.0" + s.name = "term-ansicolor".freeze + s.version = "1.5.0" - s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= - s.require_paths = ["lib"] - s.authors = ["Florian Frank"] - s.date = "2016-09-27" - s.description = "This library uses ANSI escape sequences to control the attributes of terminal output" - s.email = "flori@ping.de" - s.executables = ["term_cdiff", "term_colortab", "term_decolor", "term_display", "term_mandel"] - s.extra_rdoc_files = ["README.rdoc", "lib/term/ansicolor.rb", "lib/term/ansicolor/attribute.rb", "lib/term/ansicolor/attribute/color256.rb", "lib/term/ansicolor/attribute/color8.rb", "lib/term/ansicolor/attribute/intense_color8.rb", "lib/term/ansicolor/attribute/text.rb", "lib/term/ansicolor/ppm_reader.rb", "lib/term/ansicolor/rgb_color_metrics.rb", "lib/term/ansicolor/rgb_triple.rb", "lib/term/ansicolor/version.rb"] - s.files = [".gitignore", ".travis.yml", "CHANGES", "COPYING", "Gemfile", "README.rdoc", "Rakefile", "VERSION", "bin/term_cdiff", "bin/term_colortab", "bin/term_decolor", "bin/term_display", "bin/term_mandel", "examples/ColorTest.gif", "examples/Mona_Lisa.jpg", "examples/Stilleben.jpg", "examples/example.rb", "examples/lambda-red-plain.ppm", "examples/lambda-red.png", "examples/lambda-red.ppm", "examples/pacman.jpg", "examples/smiley.png", "examples/wool.jpg", "lib/term/ansicolor.rb", "lib/term/ansicolor/.keep", "lib/term/ansicolor/attribute.rb", "lib/term/ansicolor/attribute/color256.rb", "lib/term/ansicolor/attribute/color8.rb", "lib/term/ansicolor/attribute/intense_color8.rb", "lib/term/ansicolor/attribute/text.rb", "lib/term/ansicolor/ppm_reader.rb", "lib/term/ansicolor/rgb_color_metrics.rb", "lib/term/ansicolor/rgb_triple.rb", "lib/term/ansicolor/version.rb", "term-ansicolor.gemspec", "tests/ansicolor_test.rb", "tests/attribute_test.rb", "tests/ppm_reader_test.rb", "tests/rgb_color_metrics_test.rb", "tests/rgb_triple_test.rb", "tests/test_helper.rb"] - s.homepage = "http://flori.github.com/term-ansicolor" - s.licenses = ["GPL-2"] - s.rdoc_options = ["--title", "Term-ansicolor - Ruby library that colors strings using ANSI escape sequences", "--main", "README.rdoc"] - s.required_ruby_version = Gem::Requirement.new(">= 2.0") - s.rubygems_version = "2.5.1" - s.summary = "Ruby library that colors strings using ANSI escape sequences" - s.test_files = ["tests/ansicolor_test.rb", "tests/attribute_test.rb", "tests/ppm_reader_test.rb", "tests/rgb_color_metrics_test.rb", "tests/rgb_triple_test.rb", "tests/test_helper.rb"] + s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= + s.require_paths = ["lib".freeze] + s.authors = ["Florian Frank".freeze] + s.date = "2017-03-28" + s.description = "This library uses ANSI escape sequences to control the attributes of terminal output".freeze + s.email = "flori@ping.de".freeze + s.executables = ["term_cdiff".freeze, "term_colortab".freeze, "term_decolor".freeze, "term_display".freeze, "term_mandel".freeze] + s.extra_rdoc_files = ["README.rdoc".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/hsl_triple.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] + s.files = [".gitignore".freeze, ".travis.yml".freeze, "CHANGES".freeze, "COPYING".freeze, "Gemfile".freeze, "README.rdoc".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, "examples/ColorTest.gif".freeze, "examples/Mona_Lisa.jpg".freeze, "examples/Stilleben.jpg".freeze, "examples/example.rb".freeze, "examples/lambda-red-plain.ppm".freeze, "examples/lambda-red.png".freeze, "examples/lambda-red.ppm".freeze, "examples/pacman.jpg".freeze, "examples/smiley.png".freeze, "examples/wool.jpg".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/hsl_triple.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/ppm_reader_test.rb".freeze, "tests/rgb_color_metrics_test.rb".freeze, "tests/rgb_triple_test.rb".freeze, "tests/test_helper.rb".freeze] + s.homepage = "http://flori.github.com/term-ansicolor".freeze + s.licenses = ["GPL-2".freeze] + s.rdoc_options = ["--title".freeze, "Term-ansicolor - Ruby library that colors strings using ANSI escape sequences".freeze, "--main".freeze, "README.rdoc".freeze] + s.required_ruby_version = Gem::Requirement.new(">= 2.0".freeze) + s.rubygems_version = "2.6.11".freeze + s.summary = "Ruby library that colors strings using ANSI escape sequences".freeze + s.test_files = ["tests/ansicolor_test.rb".freeze, "tests/attribute_test.rb".freeze, "tests/hsl_triple_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] if s.respond_to? :specification_version then s.specification_version = 4 if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then - s.add_development_dependency(%q<gem_hadar>, ["~> 1.8.0"]) - s.add_development_dependency(%q<simplecov>, [">= 0"]) - s.add_development_dependency(%q<minitest_tu_shim>, [">= 0"]) - s.add_runtime_dependency(%q<tins>, ["~> 1.0"]) + s.add_development_dependency(%q<gem_hadar>.freeze, ["~> 1.9.1"]) + s.add_development_dependency(%q<simplecov>.freeze, [">= 0"]) + s.add_development_dependency(%q<test-unit>.freeze, [">= 0"]) + s.add_runtime_dependency(%q<tins>.freeze, ["~> 1.0"]) else - s.add_dependency(%q<gem_hadar>, ["~> 1.8.0"]) - s.add_dependency(%q<simplecov>, [">= 0"]) - s.add_dependency(%q<minitest_tu_shim>, [">= 0"]) - s.add_dependency(%q<tins>, ["~> 1.0"]) + s.add_dependency(%q<gem_hadar>.freeze, ["~> 1.9.1"]) + s.add_dependency(%q<simplecov>.freeze, [">= 0"]) + s.add_dependency(%q<test-unit>.freeze, [">= 0"]) + s.add_dependency(%q<tins>.freeze, ["~> 1.0"]) end else - s.add_dependency(%q<gem_hadar>, ["~> 1.8.0"]) - s.add_dependency(%q<simplecov>, [">= 0"]) - s.add_dependency(%q<minitest_tu_shim>, [">= 0"]) - s.add_dependency(%q<tins>, ["~> 1.0"]) + s.add_dependency(%q<gem_hadar>.freeze, ["~> 1.9.1"]) + s.add_dependency(%q<simplecov>.freeze, [">= 0"]) + s.add_dependency(%q<test-unit>.freeze, [">= 0"]) + s.add_dependency(%q<tins>.freeze, ["~> 1.0"]) end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tests/attribute_test.rb new/tests/attribute_test.rb --- old/tests/attribute_test.rb 2016-09-27 12:16:09.000000000 +0200 +++ new/tests/attribute_test.rb 2017-03-28 10:40:15.000000000 +0200 @@ -39,14 +39,14 @@ def test_nearest_rgb_color assert_equal Attribute.get(:color0).rgb, Attribute.nearest_rgb_color('#000').rgb assert_equal Attribute.get(:color15).rgb, Attribute.nearest_rgb_color('#ffffff').rgb - assert_equal :color247, Attribute.nearest_rgb_color('#aaa').name + assert_equal :color248, Attribute.nearest_rgb_color('#aaa').name assert_equal :color109, Attribute.nearest_rgb_color('#aaa', :gray => false).name end def test_nearest_rgb_on_color assert_equal Attribute.get(:on_color0).rgb, Attribute.nearest_rgb_on_color('#000').rgb assert_equal Attribute.get(:on_color15).rgb, Attribute.nearest_rgb_on_color('#ffffff').rgb - assert_equal :on_color247, Attribute.nearest_rgb_on_color('#aaa').name + assert_equal :on_color248, Attribute.nearest_rgb_on_color('#aaa').name assert_equal :on_color109, Attribute.nearest_rgb_on_color('#aaa', :gray => false).name end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tests/hsl_triple_test.rb new/tests/hsl_triple_test.rb --- old/tests/hsl_triple_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/tests/hsl_triple_test.rb 2017-03-28 10:40:15.000000000 +0200 @@ -0,0 +1,85 @@ +require 'test_helper' + +class HSLTripleTest < Test::Unit::TestCase + include Term::ANSIColor + + def setup + @pastel_green_rgb = Term::ANSIColor::RGBTriple['#85e085'] + @pastel_green_hsl = Term::ANSIColor::HSLTriple.new(120, 59.4, 70) + @soft_red_rgb = Term::ANSIColor::RGBTriple['#e08585'] + @soft_blue_rgb = Term::ANSIColor::RGBTriple['#8585e0'] + @gray_rgb = Term::ANSIColor::RGBTriple['#888'] + end + + def test_hsl_cast + assert_equal '#85e085', HSLTriple[ @pastel_green_hsl ].html + assert_equal '#85e085', HSLTriple[ :hue => 120, :saturation => 59.4, :lightness => 70 ].html + assert_equal '#11ddff', HSLTriple[ '#1df' ].html + assert_equal '#8000ff', HSLTriple[ 'rgb(128,0,255)' ].html + assert_equal '#85e085', HSLTriple[ 'hsl(120.0,59.4%,70.0%)' ].html + assert_raises ArgumentError do + HSLTriple[ nil ] + end + end + + def test_conversion_to_hsl + hsl = @pastel_green_rgb.to_hsl_triple + assert_in_delta @pastel_green_hsl.hue, hsl.hue, 1e-1 + assert_in_delta @pastel_green_hsl.saturation, hsl.saturation, 1e-1 + assert_in_delta @pastel_green_hsl.lightness, hsl.lightness, 1e-1 + assert_match /hsl\(0\.0,0\.0%,53.3333.*?%\)/, @gray_rgb.to_hsl_triple.css + assert_match /hsl\(120\.0.*?,58\.82.*?%,20.0%\)/, RGBTriple[ '#155115' ].to_hsl_triple.css + end + + def test_conversion_to_rgb + rgb = @pastel_green_hsl.to_rgb_triple + assert_in_delta @pastel_green_rgb.red, rgb.red, 1e-1 + assert_in_delta @pastel_green_rgb.green, rgb.green, 1e-1 + assert_in_delta @pastel_green_rgb.blue, rgb.blue, 1e-1 + assert_equal '#155115', HSLTriple[ '#155115' ].to_rgb_triple.html + end + + def test_lighten + assert_in_delta 80, @pastel_green_hsl.lighten(10).lightness, 1e-3 + end + + def test_darken + assert_in_delta 60, @pastel_green_hsl.darken(10).lightness, 1e-3 + end + + def test_saturate + assert_in_delta 69.4, @pastel_green_hsl.saturate(10).saturation, 1e-3 + end + + def test_desaturate + assert_in_delta 49.4, @pastel_green_hsl.desaturate(10).saturation, 1e-3 + end + + def test_adjust_hue + assert_in_delta 130, @pastel_green_hsl.adjust_hue(10).hue, 1e-3 + end + + def test_grayscale + assert_equal '#b3b3b3', @pastel_green_hsl.grayscale.html + end + + def test_complement + assert_in_delta 300, @pastel_green_hsl.complement.hue, 1e-3 + assert_in_delta 300 - 120, @soft_red_rgb.complement.hue, 1e-3 + assert_in_delta 300 - 240, @soft_blue_rgb.complement.hue, 1e-3 + end + + def test_css + assert_equal 'hsl(120.0,59.4%,70.0%)', @pastel_green_hsl.css + assert_equal '#85e085', HSLTriple.from_css('hsl(120.0,59.4%,70.0%)').html + end + + def test_equality + assert_equal @pastel_green_hsl, @pastel_green_rgb + assert_equal @pastel_green_rgb, @pastel_green_hsl + end + + def test_method_missing + assert_raise(NoMethodError) { @pastel_green_hsl.foo } + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tests/rgb_triple_test.rb new/tests/rgb_triple_test.rb --- old/tests/rgb_triple_test.rb 2016-09-27 12:16:09.000000000 +0200 +++ new/tests/rgb_triple_test.rb 2017-03-28 10:40:15.000000000 +0200 @@ -8,6 +8,9 @@ assert_equal '#8000ff', RGBTriple[ rgb ].html assert_equal '#8000ff', RGBTriple[ [ 128, 0, 255 ] ].html assert_equal '#8000ff', RGBTriple[ :red => 128, :green => 0, :blue => 255 ].html + assert_equal '#11ddff', RGBTriple[ '#1df' ].html + assert_equal '#8000ff', RGBTriple[ 'rgb(128,0,255)' ].html + assert_equal '#85e085', RGBTriple[ 'hsl(120.0,59.4%,70.0%)' ].html assert_raises ArgumentError do RGBTriple[ nil ] end @@ -18,6 +21,13 @@ assert_equal [ 128, 0, 255 ], rgb.to_a end + def test_percentages + rgb = RGBTriple.new(128, 0, 255) + assert_in_delta 50.19, rgb.red_p, 1e-2 + assert_in_delta 0.0, rgb.green_p, 1e-2 + assert_in_delta 100.0, rgb.blue_p, 1e-2 + end + def test_rgb_distance rgb1 = RGBTriple.new(128, 0, 255) rgb2 = RGBTriple.new(128, 200, 64) @@ -68,4 +78,24 @@ assert_equal 204, g2[4].blue assert_equal rgb2, g2[5] end + + def test_invert + assert_equal RGBTriple.new(127, 255, 0), RGBTriple.new(128, 0, 255).invert + end + + def test_css + rgb = RGBTriple.new(128, 0, 255) + assert_equal 'rgb(128,0,255)', rgb.css + assert_equal '#8000ff', RGBTriple.from_css('rgb(128,0,255)').html + assert_match /rgb\(50\.19.*?%,0\.0%,100.0%\)/, rgb.css(percentage: true) + assert_equal '#8000ff', RGBTriple.from_css('rgb(50.19607843137255%,0.0%,100.0%)').html + end + + def test_color + assert_equal "\e[38;5;93mfoo\e[0m", RGBTriple.new(128, 0, 255).color('foo') + end + + def test_method_missing + assert_raise(NoMethodError) { RGBTriple.new(0, 0, 0).foo } + end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tests/test_helper.rb new/tests/test_helper.rb --- old/tests/test_helper.rb 2016-09-27 12:16:09.000000000 +0200 +++ new/tests/test_helper.rb 2017-03-28 10:40:15.000000000 +0200 @@ -4,10 +4,5 @@ add_filter "#{File.basename(File.dirname(__FILE__))}/" end end -if RUBY_VERSION >= '1.9' && ENV['CODECLIMATE_REPO_TOKEN'] - require "codeclimate-test-reporter" - CodeClimate::TestReporter.start -end -require 'minitest/unit' require 'test/unit' require 'term/ansicolor'