logpoop 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +15 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +25 -0
- data/Rakefile +46 -0
- data/VERSION +1 -0
- data/bin/logpoop +9 -0
- data/lib/logpoop.rb +82 -0
- data/logpoop.gemspec +57 -0
- data/test/helper.rb +18 -0
- data/test/test_logpoop.rb +7 -0
- metadata +95 -0
data/.document
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "jeweler", "~> 1.5.2"
|
10
|
+
end
|
data/Gemfile.lock
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Billy Reisinger
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
= logpoop
|
2
|
+
|
3
|
+
This gem installs a script called +logpoop+ that fills up your active
|
4
|
+
terminal sessions with crap (so that you look *really* busy). The 'crap' is from log files found on
|
5
|
+
your system (either from +/var/log+ or from where you choose). It scrolls by at random speeds and keeps going
|
6
|
+
until you ^C it.
|
7
|
+
|
8
|
+
This script uses +/dev/ttys00*+, and so it's likely only gonna work on a Mac. It could be easily modified
|
9
|
+
to work on Linux, of course, so pull requests are awesome.
|
10
|
+
|
11
|
+
== Contributing to logpoop
|
12
|
+
|
13
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
14
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
15
|
+
* Fork the project
|
16
|
+
* Start a feature/bugfix branch
|
17
|
+
* Commit and push until you are happy with your contribution
|
18
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
19
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
20
|
+
|
21
|
+
== Copyright
|
22
|
+
|
23
|
+
Copyright (c) 2011 Billy Reisinger. See LICENSE.txt for
|
24
|
+
further details.
|
25
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'rake'
|
11
|
+
|
12
|
+
require 'jeweler'
|
13
|
+
Jeweler::Tasks.new do |gem|
|
14
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
15
|
+
gem.name = "logpoop"
|
16
|
+
gem.homepage = "http://github.com/unclebilly/logpoop"
|
17
|
+
gem.license = "MIT"
|
18
|
+
gem.summary = %Q{Quick, look busy! Print some poop in your terminals!}
|
19
|
+
gem.description = %Q{This gem installs a script called 'logpoop' that, when run, fills up your active terminal sessions with crap (so that you look really busy). }
|
20
|
+
gem.email = "billy.reisinger@gmail.com"
|
21
|
+
gem.authors = ["Billy Reisinger"]
|
22
|
+
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
23
|
+
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
24
|
+
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
|
25
|
+
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
26
|
+
end
|
27
|
+
Jeweler::RubygemsDotOrgTasks.new
|
28
|
+
|
29
|
+
require 'rake/testtask'
|
30
|
+
Rake::TestTask.new(:test) do |test|
|
31
|
+
test.libs << 'lib' << 'test'
|
32
|
+
test.pattern = 'test/**/test_*.rb'
|
33
|
+
test.verbose = true
|
34
|
+
end
|
35
|
+
|
36
|
+
task :default => :test
|
37
|
+
|
38
|
+
require 'rake/rdoctask'
|
39
|
+
Rake::RDocTask.new do |rdoc|
|
40
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
41
|
+
|
42
|
+
rdoc.rdoc_dir = 'rdoc'
|
43
|
+
rdoc.title = "logpoop #{version}"
|
44
|
+
rdoc.rdoc_files.include('README*')
|
45
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
46
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/bin/logpoop
ADDED
data/lib/logpoop.rb
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
class LogPoop
|
2
|
+
attr_accessor :go
|
3
|
+
|
4
|
+
def self.usage
|
5
|
+
<<-STR
|
6
|
+
Description:
|
7
|
+
Print random lines from log files pulled from somewhere, at randomly varying speeds, to some or all
|
8
|
+
open terminals.
|
9
|
+
|
10
|
+
Usage: #{$0} [log_dir] [tty_num]
|
11
|
+
log_dir directory to pull log files from, defaults to /var/log
|
12
|
+
tty_num tty number to use (e.g. 1). If blank, all open terminals will get pooped on.
|
13
|
+
STR
|
14
|
+
end
|
15
|
+
def self.instance
|
16
|
+
@@instance
|
17
|
+
end
|
18
|
+
|
19
|
+
# takes an IO instance
|
20
|
+
def clear_screen(tty)
|
21
|
+
tty.write "\e[2J\e[f"
|
22
|
+
end
|
23
|
+
|
24
|
+
def loop_some_log_crap(mytty, log)
|
25
|
+
iter = 0
|
26
|
+
speed = rand(20)
|
27
|
+
while @go do
|
28
|
+
iter += 1
|
29
|
+
num_lines = rand(4) + 1
|
30
|
+
rand_pos = rand(log.length - 1)
|
31
|
+
range = (rand_pos..(rand_pos + num_lines))
|
32
|
+
line = log[range].map{|li| li.gsub(/'/, "\"")}.join("\n")
|
33
|
+
mytty.write(line)
|
34
|
+
sleep(speed / 50.0)
|
35
|
+
speed = rand(20) if iter % 7 == 0
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def initialize(log_dir, num)
|
40
|
+
@@instance = self
|
41
|
+
@ttys = get_tty_list(num).map{|f| IO.sysopen(f, 'w')}.map{|n| IO.new(n, 'w')}
|
42
|
+
logs = get_logs(@ttys.length, log_dir || "/var/log")
|
43
|
+
f = logs.map{|log| File.read(log).split(/\n/)}
|
44
|
+
@go = true
|
45
|
+
threads = []
|
46
|
+
@ttys.each_with_index do |tty, index|
|
47
|
+
threads << Thread.new(tty, f[index]) do |mytty, mylog|
|
48
|
+
loop_some_log_crap(mytty, mylog)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
threads.each {|t| t.join}
|
52
|
+
end
|
53
|
+
|
54
|
+
def get_tty_list(num=nil)
|
55
|
+
if(num.nil?)
|
56
|
+
Dir.glob("/dev/ttys00*")
|
57
|
+
else
|
58
|
+
if(File.exists?("/dev/ttys00#{num}"))
|
59
|
+
["/dev/ttys00#{num}"]
|
60
|
+
else
|
61
|
+
raise "/dev/ttys00#{num} does not exist"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def get_logs(how_many, dir)
|
67
|
+
`ls -S #{dir}/*.log`.split(/\n/)[1..how_many]
|
68
|
+
end
|
69
|
+
|
70
|
+
def stop
|
71
|
+
@go = false
|
72
|
+
@ttys.each {|t| clear_screen(t)}
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
Signal.trap("INT") do
|
77
|
+
LogPoop.instance.stop
|
78
|
+
end
|
79
|
+
|
80
|
+
Signal.trap("TERM") do
|
81
|
+
LogPoop.instance.stop
|
82
|
+
end
|
data/logpoop.gemspec
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{logpoop}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Billy Reisinger"]
|
12
|
+
s.date = %q{2011-02-02}
|
13
|
+
s.default_executable = %q{logpoop}
|
14
|
+
s.description = %q{This gem installs a script called 'logpoop' that, when run, fills up your active terminal sessions with crap (so that you look really busy). }
|
15
|
+
s.email = %q{billy.reisinger@gmail.com}
|
16
|
+
s.executables = ["logpoop"]
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE.txt",
|
19
|
+
"README.rdoc"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
".document",
|
23
|
+
"Gemfile",
|
24
|
+
"Gemfile.lock",
|
25
|
+
"LICENSE.txt",
|
26
|
+
"README.rdoc",
|
27
|
+
"Rakefile",
|
28
|
+
"VERSION",
|
29
|
+
"bin/logpoop",
|
30
|
+
"lib/logpoop.rb",
|
31
|
+
"logpoop.gemspec",
|
32
|
+
"test/helper.rb",
|
33
|
+
"test/test_logpoop.rb"
|
34
|
+
]
|
35
|
+
s.homepage = %q{http://github.com/unclebilly/logpoop}
|
36
|
+
s.licenses = ["MIT"]
|
37
|
+
s.require_paths = ["lib"]
|
38
|
+
s.rubygems_version = %q{1.5.0}
|
39
|
+
s.summary = %q{Quick, look busy! Print some poop in your terminals!}
|
40
|
+
s.test_files = [
|
41
|
+
"test/helper.rb",
|
42
|
+
"test/test_logpoop.rb"
|
43
|
+
]
|
44
|
+
|
45
|
+
if s.respond_to? :specification_version then
|
46
|
+
s.specification_version = 3
|
47
|
+
|
48
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
49
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
|
50
|
+
else
|
51
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
52
|
+
end
|
53
|
+
else
|
54
|
+
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
data/test/helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
require 'shoulda'
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
|
+
require 'logpoop'
|
16
|
+
|
17
|
+
class Test::Unit::TestCase
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: logpoop
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Billy Reisinger
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-02-02 00:00:00 -06:00
|
19
|
+
default_executable: logpoop
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: jeweler
|
23
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 7
|
29
|
+
segments:
|
30
|
+
- 1
|
31
|
+
- 5
|
32
|
+
- 2
|
33
|
+
version: 1.5.2
|
34
|
+
prerelease: false
|
35
|
+
type: :development
|
36
|
+
requirement: *id001
|
37
|
+
description: "This gem installs a script called 'logpoop' that, when run, fills up your active terminal sessions with crap (so that you look really busy). "
|
38
|
+
email: billy.reisinger@gmail.com
|
39
|
+
executables:
|
40
|
+
- logpoop
|
41
|
+
extensions: []
|
42
|
+
|
43
|
+
extra_rdoc_files:
|
44
|
+
- LICENSE.txt
|
45
|
+
- README.rdoc
|
46
|
+
files:
|
47
|
+
- .document
|
48
|
+
- Gemfile
|
49
|
+
- Gemfile.lock
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.rdoc
|
52
|
+
- Rakefile
|
53
|
+
- VERSION
|
54
|
+
- bin/logpoop
|
55
|
+
- lib/logpoop.rb
|
56
|
+
- logpoop.gemspec
|
57
|
+
- test/helper.rb
|
58
|
+
- test/test_logpoop.rb
|
59
|
+
has_rdoc: true
|
60
|
+
homepage: http://github.com/unclebilly/logpoop
|
61
|
+
licenses:
|
62
|
+
- MIT
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options: []
|
65
|
+
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
hash: 3
|
74
|
+
segments:
|
75
|
+
- 0
|
76
|
+
version: "0"
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
none: false
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
hash: 3
|
83
|
+
segments:
|
84
|
+
- 0
|
85
|
+
version: "0"
|
86
|
+
requirements: []
|
87
|
+
|
88
|
+
rubyforge_project:
|
89
|
+
rubygems_version: 1.5.0
|
90
|
+
signing_key:
|
91
|
+
specification_version: 3
|
92
|
+
summary: Quick, look busy! Print some poop in your terminals!
|
93
|
+
test_files:
|
94
|
+
- test/helper.rb
|
95
|
+
- test/test_logpoop.rb
|