Class: LogPoop

Inherits:
Object
  • Object
show all
Defined in:
lib/logpoop.rb

Constant Summary collapse

POOP_TYPES =
[
  "make - simulate compiling something for a long, long, looooong time ",
  "poop - take a dump in your terminal",
  "print - print the given text over and over in every terminal",
  "tail - simulate 'tail -f' in all your open terminals",
  "test - simulate a console test run (needs two terminals open)",
]

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLogPoop

Returns a new instance of LogPoop.



59
60
61
62
# File 'lib/logpoop.rb', line 59

def initialize
  options = self.class.parse_options
  Runner::Context.run(options)    
end

Class Method Details



15
16
17
18
19
20
# File 'lib/logpoop.rb', line 15

def self.banner
  <<-STR
Description:
Look busy! Tail some stuff in your open terminals, or even simulate running some tests. 
STR
end

.instanceObject



55
56
57
# File 'lib/logpoop.rb', line 55

def self.instance
  @@instance
end

.parse_optionsObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/logpoop.rb', line 29

def self.parse_options
  options = {
    :type => :tail,
    :log_dir => "/var/log"
  }

  o = OptionParser.new do |opt|
    opt.banner = self.banner
    opt.on("-v", "--version", "Show version") do
      puts File.read(File.join(File.dirname(__FILE__), '..', 'VERSION'))
      exit
    end
    opt.on("-d", "--log_dir DIRECTORY", "Log directory") do |d|
      options[:log_dir] = d
    end
    opt.on("-t", "--type TYPE", "Poop type. Available types: \t\n#{POOP_TYPES.join("\t\n")}") do |t|
      options[:type] = t
    end
    opt.on("-p", "--print TEXT", "Text to print (only valid with poop type 'print')") do |t|
      options[:text] = t
    end
  end
  o.parse!
  options
end