lolcat 99.9.9 → 99.9.10

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: 5b2f2da553496da9167b641f9490b602b7c7ab20939855328e5b11ba576981ac
4
- data.tar.gz: fb4269af6402efb41734d960e7dc5645d3407e2140a1adcaf9d2346a853d3064
3
+ metadata.gz: a313766343e4d204f03d600659987b0c910dc8afd3fbc420987a01ed3f829fc6
4
+ data.tar.gz: b01cf6ef9c92806257e88ee14416e428330531a128cd7c7ec8c6e47970c5e5b9
5
5
  SHA512:
6
- metadata.gz: 836bb75c723ea7c49f4ea1201ab2a301bedc9c61db9a4995d8e7191f15ae4792dc856144bb592dab0dcc167234a968afb997f6b1b3323384eb07f679f5c7189b
7
- data.tar.gz: 5678cebdb25b01d6115d20fbf8cfdb67a4904d1dc715671d40359ddce1ad080d9cd99f45ca062fe92eab3ed6913621ed6c67506eb625ecff31787ade038c9d74
6
+ metadata.gz: 51c84d710091c29b29611c089090515cc5c26c69e33517ca894eb9f28363f794edeb324a5aa5687addca1ea9d1f94dd553b08b55cef9d9270cf269cd46abf041
7
+ data.tar.gz: 383ba55cf86ab59a187a2085df85e29d7b70cbb4c6e302680bb4e9fb17b975f214c5de6bc78882871fabc4f7df4047f5965e112539d6f7833b49055ebee656e2
@@ -27,6 +27,10 @@ require "lolcat/version"
27
27
  require 'paint'
28
28
 
29
29
  module Lol
30
+ ANSI_ESCAPE = /((?:\e(?:[ -\/]+.|[\]PX^_][^\a\e]*|\[[0-?]*.|.))*)(.?)/m
31
+ INCOMPLETE_ESCAPE = /\e(?:[ -\/]*|[\]PX^_][^\a\e]*|\[[0-?]*)$/
32
+ INCOMPLETE_UTF8 = /[\xc0-\xdf]$|[\xe0-\xef].?$|[\xf0-\xf7].?.?$/n
33
+
30
34
  @paint_detected_mode = Paint.detect_mode
31
35
 
32
36
  def self.rainbow(freq, i)
@@ -39,8 +43,11 @@ module Lol
39
43
  def self.cat(fd, opts={})
40
44
  print "\e[?25l" if opts[:animate]
41
45
  while true do
46
+ buf = ''
42
47
  begin
43
- buf = fd.sysread(65536)
48
+ begin
49
+ buf += fd.sysread(4096)
50
+ end while buf.match(INCOMPLETE_ESCAPE) or (fd.external_encoding == 'UTF-8' and buf.match(INCOMPLETE_UTF8))
44
51
  rescue EOFError
45
52
  break
46
53
  end
@@ -52,8 +59,8 @@ module Lol
52
59
  end
53
60
  ensure
54
61
  if STDOUT.tty? then
55
- print "\e[m\e[?25h\e[?1;5;47;2004l"
56
- system("stty cooked -nl <&1");
62
+ print "\e[m\e[?25h\e[?1;5;2004l"
63
+ system("stty sane -istrip <&1");
57
64
  end
58
65
  end
59
66
 
@@ -70,9 +77,13 @@ module Lol
70
77
  def self.println_plain(str, defaults={}, opts={})
71
78
  opts.merge!(defaults)
72
79
  set_mode(opts[:truecolor])
73
- str.scan(/((?:\e(?:[ -\/]+.|[\]PX^_][^\a\e]*|\[[0-?]*.|.))*)(.?)/m).each_with_index do |c,i|
74
- code = rainbow(opts[:freq], opts[:os]+i/opts[:spread])
75
- print c[0], Paint[c[1], *[ (:black if opts[:invert]), code ].compact ]
80
+ str.scan(ANSI_ESCAPE).each_with_index do |c,i|
81
+ color = rainbow(opts[:freq], opts[:os]+i/opts[:spread])
82
+ if opts[:invert] then
83
+ print c[0], Paint.color(nil, color), c[1], "\e[49m"
84
+ else
85
+ print c[0], Paint.color(color), c[1], "\e[39m"
86
+ end
76
87
  end
77
88
  end
78
89
 
@@ -1,3 +1,3 @@
1
1
  module Lolcat
2
- VERSION = "99.9.9"
2
+ VERSION = "99.9.10"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lolcat
3
3
  version: !ruby/object:Gem::Version
4
- version: 99.9.9
4
+ version: 99.9.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Moe