rainbros 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,86 +1,9 @@
1
- require "rainbros/version"
2
1
  require 'lolcat/lol'
3
2
  require 'stringio'
4
3
  require 'irb'
5
-
6
- module Rainbros
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
27
- while true
28
- exit! unless system('dicks | lolcat')
29
- end
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
71
- end
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
-
85
- end
86
- end
4
+ require "rainbros/version"
5
+ require 'rainbros/irb_extensions'
6
+ #require 'rainbros/core_extensions'
7
+ #require 'rainbros/paint_extentions'
8
+ require 'rainbros/lol_cat_extensions'
9
+ require 'rainbros/bro_it_out'
@@ -0,0 +1,39 @@
1
+ module Rainbros
2
+ class BroItOut
3
+ def go
4
+ bros = ARGV.pop
5
+
6
+ case bros
7
+ when "forever" then bros_forever
8
+ when "irb" then irb_bro
9
+ else
10
+ bros ||= 12
11
+
12
+ if (n = bros.to_i) > 0
13
+ bros n
14
+ else
15
+ no_bros
16
+ end
17
+ end
18
+ end
19
+
20
+ private
21
+ def bros_forever
22
+ while true
23
+ exit! unless system('dicks | lolcat')
24
+ end
25
+ end
26
+
27
+ def bros n
28
+ system("dicks #{n} | lolcat")
29
+ end
30
+
31
+ def no_bros
32
+ system("echo 'y u no want rainbros?' | lolcat")
33
+ end
34
+
35
+ def irb_bro
36
+ IRB.start
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,13 @@
1
+ # unused for now
2
+ module Rainbros
3
+ module ::Kernel
4
+ def capture_stdout
5
+ out = StringIO.new
6
+ $stdout = out
7
+ yield
8
+ return out
9
+ ensure
10
+ $stdout = STDOUT
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,33 @@
1
+ module Rainbros
2
+ module ::IRB
3
+ class << self
4
+ alias :old_setup :setup
5
+
6
+ def setup(ap_path)
7
+ STDOUT.sync = true
8
+ old_setup(ap_path)
9
+ prompt = "8===D~~ "
10
+ opts = {
11
+ :spread => 3.0,
12
+ :freq => 0.8,
13
+ :os => rand(256),
14
+ :speed => 1.0
15
+ }
16
+ output = ::Lol.cat([prompt], opts)
17
+ default = @CONF[:PROMPT][:DEFAULT]
18
+ @CONF[:PROMPT][:RAINBROS] = {
19
+ :PROMPT_I => "#{default[:PROMPT_I][0..-3]}#{output}",
20
+ :PROMPT_N => "#{default[:PROMPT_N][0..-3]}#{output}",
21
+ :PROMPT_S => "#{default[:PROMPT_S][0..-2]}#{output}",
22
+ :PROMPT_C => "#{default[:PROMPT_C][0..-2]}#{output}",
23
+ :RETURN => "#{output}#{default[:RETURN][3..-1]}"
24
+ }
25
+ @CONF[:PROMPT_MODE] = :RAINBROS
26
+ @CONF[:AUTO_INDENT] = true
27
+ # disable readline because it causes a wrapping bug.
28
+ # http://www.ruby-forum.com/topic/213807
29
+ @CONF[:USE_READLINE] = false
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,28 @@
1
+ module Lol
2
+ def self.cat(fd, opts={})
3
+ text = []
4
+ fd.each do |line|
5
+ opts[:os] += 1
6
+ text << println(line, opts)
7
+ end
8
+ text.join("\n")
9
+ end
10
+
11
+ def self.println(str, defaults={}, opts={})
12
+ opts.merge!(defaults)
13
+ str.chomp!
14
+ str.gsub! STRIP_ANSI, '' if !str.nil? and ($stdout.tty? or opts[:force])
15
+ println_plain(str, opts)
16
+ end
17
+
18
+ private
19
+
20
+ def self.println_plain(str, defaults={}, opts={})
21
+ opts.merge!(defaults)
22
+ chars = []
23
+ str.chomp.chars.each_with_index do |c,i|
24
+ chars << Paint[c, rainbow(opts[:freq], opts[:os]+i/opts[:spread])]
25
+ end
26
+ chars.join('')
27
+ end
28
+ end
@@ -0,0 +1,9 @@
1
+ # unused for now
2
+ module Paint
3
+ class << self
4
+ # Adds ansi sequence
5
+ def wrap(*ansi_codes)
6
+ "\033[" + ansi_codes*";" + "m"
7
+ end
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module Rainbros
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
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.6
4
+ version: 0.0.7
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-12 00:00:00.000000000 Z
12
+ date: 2012-02-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: dicks
16
- requirement: &70298378243900 !ruby/object:Gem::Requirement
16
+ requirement: &70223596200360 !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: *70298378243900
24
+ version_requirements: *70223596200360
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: lolcat
27
- requirement: &70298378243300 !ruby/object:Gem::Requirement
27
+ requirement: &70223596198860 !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: *70298378243300
35
+ version_requirements: *70223596198860
36
36
  description: Most super awesome gem that makes you think of your awesome multicultural
37
37
  bros.
38
38
  email:
@@ -47,6 +47,11 @@ files:
47
47
  - Rakefile
48
48
  - bin/rainbros
49
49
  - lib/rainbros.rb
50
+ - lib/rainbros/bro_it_out.rb
51
+ - lib/rainbros/core_extensions.rb
52
+ - lib/rainbros/irb_extensions.rb
53
+ - lib/rainbros/lol_cat_extensions.rb
54
+ - lib/rainbros/paint_extentions.rb
50
55
  - lib/rainbros/version.rb
51
56
  - rainbros.gemspec
52
57
  homepage: ''
@@ -69,9 +74,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
74
  version: '0'
70
75
  requirements: []
71
76
  rubyforge_project: rainbros
72
- rubygems_version: 1.8.10
77
+ rubygems_version: 1.8.16
73
78
  signing_key:
74
79
  specification_version: 3
75
80
  summary: This gem prints rainbros to your console
76
81
  test_files: []
77
- has_rdoc: