rainbros 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore CHANGED
@@ -2,3 +2,4 @@
2
2
  .bundle
3
3
  Gemfile.lock
4
4
  pkg/*
5
+ .idea/**
@@ -3,4 +3,4 @@
3
3
  $:.unshift File.expand_path('../../lib', __FILE__)
4
4
  require 'rainbros'
5
5
 
6
- Rainbros.bro_it_out!
6
+ Rainbros::BroItOut.new.go
@@ -1,21 +1,86 @@
1
1
  require "rainbros/version"
2
+ require 'lolcat/lol'
3
+ require 'stringio'
4
+ require 'irb'
2
5
 
3
6
  module Rainbros
4
- module_function
5
- def bro_it_out!
6
- cmd = 'dicks | lolcat'
7
- if ARGV[0] && ARGV[0] == "forever"
7
+ class BroItOut
8
+ def go
9
+ bros = ARGV.pop
10
+
11
+ case bros
12
+ when "forever" then bros_forever
13
+ when "irb" then irb_bro
14
+ else
15
+ bros ||= 12
16
+
17
+ if (n = bros.to_i) > 0
18
+ bros n
19
+ else
20
+ no_bros
21
+ end
22
+ end
23
+ end
24
+
25
+ private
26
+ def bros_forever
8
27
  while true
9
- exit! unless system(cmd)
28
+ exit! unless system('dicks | lolcat')
10
29
  end
11
- else
12
- bros = ARGV.first || 4
13
-
14
- if (bros = bros.to_i) > 0
15
- bros.times { exit! unless system(cmd) }
16
- else
17
- system("echo 'y u no want rainbros?' | lolcat")
30
+ end
31
+
32
+ def bros n
33
+ system("dicks #{n} | lolcat")
34
+ end
35
+
36
+ def no_bros
37
+ system("echo 'y u no want rainbros?' | lolcat")
38
+ end
39
+
40
+ def irb_bro
41
+ IRB.start
42
+ end
43
+
44
+
45
+ module ::IRB
46
+ class << self
47
+ alias :old_setup :setup
48
+
49
+ def setup(ap_path)
50
+ old_setup(ap_path)
51
+ prompt = "8===D~~ "
52
+ opts = {
53
+ :spread => 3.0,
54
+ :freq => 0.8,
55
+ :os => rand(256),
56
+ :speed => 1.0
57
+ }
58
+ output = capture_stdout {::Lol.cat([prompt], opts)}
59
+ output = output.string.chomp
60
+ default = @CONF[:PROMPT][:DEFAULT]
61
+ @CONF[:PROMPT][:RAINBROS] = {
62
+ :PROMPT_I => "#{default[:PROMPT_I][0..-3]}#{output}",
63
+ :PROMPT_N => "#{default[:PROMPT_N][0..-3]}#{output}",
64
+ :PROMPT_S => "#{default[:PROMPT_S][0..-2]}#{output}",
65
+ :PROMPT_C => "#{default[:PROMPT_C][0..-2]}#{output}",
66
+ :RETURN => "#{output}#{default[:RETURN][3..-1]}"
67
+ }
68
+ @CONF[:PROMPT_MODE] = :RAINBROS
69
+ @CONF[:AUTO_INDENT] = true
70
+ end
18
71
  end
19
72
  end
73
+
74
+ module ::Kernel
75
+ def capture_stdout
76
+ out = StringIO.new
77
+ $stdout = out
78
+ yield
79
+ return out
80
+ ensure
81
+ $stdout = STDOUT
82
+ end
83
+ end
84
+
20
85
  end
21
86
  end
@@ -1,3 +1,3 @@
1
1
  module Rainbros
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rainbros
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-11 00:00:00.000000000 Z
12
+ date: 2012-02-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: dicks
16
- requirement: &70337698684020 !ruby/object:Gem::Requirement
16
+ requirement: &70298378243900 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70337698684020
24
+ version_requirements: *70298378243900
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: lolcat
27
- requirement: &70337698683600 !ruby/object:Gem::Requirement
27
+ requirement: &70298378243300 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70337698683600
35
+ version_requirements: *70298378243300
36
36
  description: Most super awesome gem that makes you think of your awesome multicultural
37
37
  bros.
38
38
  email: