Skip to content
Browse files

lol

  • Loading branch information...
0 parents commit 240e9ed13857347145918d72a1ef33b622699661 @m-o-e m-o-e committed
Showing with 195 additions and 0 deletions.
  1. +4 −0 .gitignore
  2. +2 −0 Gemfile
  3. +1 −0 Rakefile
  4. +24 −0 bin/lolcat
  5. +21 −0 lib/lolcat.rb
  6. +64 −0 lib/lolcat/cat.rb
  7. +55 −0 lib/lolcat/lol.rb
  8. +3 −0 lib/lolcat/version.rb
  9. +21 −0 lolcat.gemspec
4 .gitignore
@@ -0,0 +1,4 @@
+*.gem
+.bundle
+Gemfile.lock
+pkg/*
2 Gemfile
@@ -0,0 +1,2 @@
+source "http://rubygems.org"
+gemspec
1 Rakefile
@@ -0,0 +1 @@
+require 'bundler/gem_tasks'
24 bin/lolcat
@@ -0,0 +1,24 @@
+#!/usr/bin/env ruby
+
+#
+# lolcat (c)2011 moe@busyloop.net
+#
+
+# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+# Version 2, December 2004
+#
+# Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
+#
+# Everyone is permitted to copy and distribute verbatim or modified
+# copies of this license document, and changing it is allowed as long
+# as the name is changed.
+#
+# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+# TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+#
+# 0. You just DO WHAT THE FUCK YOU WANT TO.
+
+require "lolcat/version"
+require "lolcat/cat"
+
+Lol.cat!
21 lib/lolcat.rb
@@ -0,0 +1,21 @@
+#
+# lolcat (c)2011 moe@busyloop.net
+#
+
+# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+# Version 2, December 2004
+#
+# Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
+#
+# Everyone is permitted to copy and distribute verbatim or modified
+# copies of this license document, and changing it is allowed as long
+# as the name is changed.
+#
+# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+# TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+#
+# 0. You just DO WHAT THE FUCK YOU WANT TO.
+
+require "lolcat/version"
+require "lolcat/lol"
+require "lolcat/cat"
64 lib/lolcat/cat.rb
@@ -0,0 +1,64 @@
+#
+# lolcat (c)2011 moe@busyloop.net
+#
+
+# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+# Version 2, December 2004
+#
+# Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
+#
+# Everyone is permitted to copy and distribute verbatim or modified
+# copies of this license document, and changing it is allowed as long
+# as the name is changed.
+#
+# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+# TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+#
+# 0. You just DO WHAT THE FUCK YOU WANT TO.
+
+require "lolcat/version"
+require "lolcat/lol"
+
+require 'optparse'
+
+module Lol
+ def self.cat!
+ if ['-h','--help','--halp','--version'].include? ARGV[0]
+ begin
+ puts
+ Lol.whut "Usage: lolcat [[file] [[file] [[file] [[file] [file]]]] [...]]", 20
+ puts
+ Lol.whut "Concatenate FILE(s), or standard input, to standard output.", 19
+ Lol.whut "With no FILE, or when FILE is -, read standard input.", 18
+ puts
+ Lol.whut " -h, --help, --halp, --version display this help and exit", 17
+
+ puts
+ Lol.whut "Examples:"
+ Lol.whut " lolcat f - g Output f's contents, then standard input, then g's contents.", 16
+ Lol.whut " lolcat Copy standard input to standard output.", 15
+ Lol.whut " fortune | lolcat Display a rainbow cookie.", 14
+
+ puts
+ Lol.whut "Report lolcat bugs to <http://www.github.org/busyloop/lolcat/>", 13
+ Lol.whut "lolcat home page: <http://www.github.org/busyloop/lolcat/>", 12
+ Lol.whut "Report lolcat translation bugs to <http://speaklolcat.com/>", 11
+ Lol.whut "For complete documentation, read the source!", 10
+ puts
+ rescue Interrupt
+ end
+ exit 1
+ end
+
+ begin
+ fds = ARGV.empty? ? [ARGF] : ARGV[0..-1]
+ fds.each do |file|
+ file = ARGF if file == '-'
+ file = File.open file unless file == ARGF
+ Lol.cat file,8
+ end
+ rescue Interrupt
+ end
+ end
+end
+
55 lib/lolcat/lol.rb
@@ -0,0 +1,55 @@
+#
+# lolcat (c)2011 moe@busyloop.net
+#
+
+# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+# Version 2, December 2004
+#
+# Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
+#
+# Everyone is permitted to copy and distribute verbatim or modified
+# copies of this license document, and changing it is allowed as long
+# as the name is changed.
+#
+# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
+# TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+#
+# 0. You just DO WHAT THE FUCK YOU WANT TO.
+
+require "lolcat/version"
+
+require 'paint'
+
+module Lol
+ def self.rainbow(freq, i)
+ red = Math.sin(freq*i + 0) * 127 + 128
+ green = Math.sin(freq*i + 2*Math::PI/3) * 127 + 128
+ blue = Math.sin(freq*i + 4*Math::PI/3) * 127 + 128
+ "#%02X%02X%02X" % [ red, green, blue ]
+ end
+
+ def self.whut(text, duration=12, delay=0.05, spread=8)
+ (1..duration).each do |i|
+ print "\e[#{text.length}D"
+ text.chars.each_with_index do |c,j|
+ print Paint[c, rainbow(0.3, i+j/spread)]
+ end
+ sleep delay
+ end
+ puts
+ end
+
+ def self.lput(str, offset, spread)
+ print Paint[str, rainbow(0.3, offset/spread)]
+ end
+
+ def self.cat(fd, spread)
+ i=0
+ fd.each do |line|
+ line.chars.each_with_index do |c,j|
+ lput c, i+j, spread
+ end
+ i+=1
+ end
+ end
+end
3 lib/lolcat/version.rb
@@ -0,0 +1,3 @@
+module Lolcat
+ VERSION = "42.0.16"
+end
21 lolcat.gemspec
@@ -0,0 +1,21 @@
+# -*- encoding: utf-8 -*-
+$:.push File.expand_path("../lib", __FILE__)
+require "lolcat/version"
+
+Gem::Specification.new do |s|
+ s.name = "lolcat"
+ s.version = Lolcat::VERSION
+ s.authors = ["Moe"]
+ s.email = ["moe@busyloop.net"]
+ s.homepage = "https://github.com/busyloop/lolcat"
+ s.summary = %q{Rainbows and unicorns!}
+ s.description = %q{Okay, no unicorns. But rainbows!!}
+
+ #s.rubyforge_project = "lolcat"
+ s.add_dependency "paint", "~> 0.8.3"
+
+ s.files = `git ls-files`.split("\n")
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
+ s.require_paths = ["lib"]
+end

0 comments on commit 240e9ed

Please sign in to comment.
Something went wrong with that request. Please try again.