From 1125f07035ffb955be1ca1f7367ca46f7089781d Mon Sep 17 00:00:00 2001 From: moe Date: Thu, 11 Aug 2011 13:21:08 +0200 Subject: [PATCH] Lolcat ,Third book of nyan' * No more cursor eating (patch by Yu-Jie Lin) * Rainbow frequency now customizable. * Much awesomer defaults. * Now silently swallows EPIPE (like 'cat' does). --- lib/lolcat/cat.rb | 8 +++++--- lib/lolcat/lol.rb | 2 +- lib/lolcat/version.rb | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/lolcat/cat.rb b/lib/lolcat/cat.rb index b0ecc5a..4fbf464 100644 --- a/lib/lolcat/cat.rb +++ b/lib/lolcat/cat.rb @@ -49,6 +49,7 @@ def self.halp!(text, opts={}) def self.cat! p = Trollop::Parser.new do + version "lolcat #{Lolcat::VERSION} (c)2011 moe@busyloop.net" banner <
'p', :default => 8.0 + opt :spread, "Rainbow spread", :short => 'p', :default => 3.0 + opt :freq, "Rainbow frequency", :short => 'F', :default => 0.1 opt :seed, "Rainbow seed, 0 = random", :short => 'S', :default => 0 opt :animate, "Enable psychedelics", :short => 'a', :default => false opt :duration, "Animation duration", :short => 'd', :default => 12 @@ -76,7 +78,6 @@ def self.cat! Report lolcat bugs to lolcat home page: Report lolcat translation bugs to -For complete documentation, read the source! FOOTER end @@ -98,7 +99,6 @@ def self.cat! p.die :duration, "must be > 0" if opts[:duration] < 0.1 p.die :speed, "must be > 0.1" if opts[:duration] < 0.1 - opts = { :freq => 0.3 }.merge(opts) opts[:os] = opts[:seed] opts[:os] = rand(256) if opts[:os] == 0 @@ -125,6 +125,8 @@ def self.cat! rescue Errno::EISDIR puts "lolcat: #{file}: Is a directory" exit 1 + rescue Errno::EPIPE + exit 1 end end rescue Interrupt diff --git a/lib/lolcat/lol.rb b/lib/lolcat/lol.rb index 18673a2..161dbf8 100644 --- a/lib/lolcat/lol.rb +++ b/lib/lolcat/lol.rb @@ -60,7 +60,7 @@ def self.println_ani(str, opts={}) return if str.empty? (1..opts[:duration]).each do |i| print "\e[#{str.length}D" - opts[:os] += opts[:spread]/Math::PI + opts[:os] += opts[:spread] println_plain(str, opts) sleep 1.0/opts[:speed] end diff --git a/lib/lolcat/version.rb b/lib/lolcat/version.rb index 3244b43..46cf58f 100644 --- a/lib/lolcat/version.rb +++ b/lib/lolcat/version.rb @@ -1,3 +1,3 @@ module Lolcat - VERSION = "42.0.43" + VERSION = "42.0.84" end