irbtools 0.0.4 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,30 @@
1
+
2
+ <?xml version="1.0" encoding="iso-8859-1"?>
3
+ <!DOCTYPE html
4
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
5
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
6
+
7
+ <!--
8
+
9
+ Classes
10
+
11
+ -->
12
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
13
+ <head>
14
+ <title>Classes</title>
15
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
16
+ <link rel="stylesheet" href="rdoc-style.css" type="text/css" />
17
+ <base target="docwin" />
18
+ </head>
19
+ <body>
20
+ <div id="index">
21
+ <h1 class="section-bar">Classes</h1>
22
+ <div id="index-entries">
23
+ <a href="classes/IRB.html">IRB</a><br />
24
+ <a href="classes/IRB/CaptureIO.html">IRB::CaptureIO</a><br />
25
+ <a href="classes/Irbtools.html">Irbtools</a><br />
26
+ <a href="classes/Kernel.html">Kernel</a><br />
27
+ </div>
28
+ </div>
29
+ </body>
30
+ </html>
@@ -0,0 +1,29 @@
1
+
2
+ <?xml version="1.0" encoding="iso-8859-1"?>
3
+ <!DOCTYPE html
4
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
5
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
6
+
7
+ <!--
8
+
9
+ Files
10
+
11
+ -->
12
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
13
+ <head>
14
+ <title>Files</title>
15
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
16
+ <link rel="stylesheet" href="rdoc-style.css" type="text/css" />
17
+ <base target="docwin" />
18
+ </head>
19
+ <body>
20
+ <div id="index">
21
+ <h1 class="section-bar">Files</h1>
22
+ <div id="index-entries">
23
+ <a href="files/README_rdoc.html">README.rdoc</a><br />
24
+ <a href="files/lib/irbtools_rb.html">lib/irbtools.rb</a><br />
25
+ <a href="files/lib/irbtools/configure_rb.html">lib/irbtools/configure.rb</a><br />
26
+ </div>
27
+ </div>
28
+ </body>
29
+ </html>
@@ -0,0 +1,48 @@
1
+
2
+ <?xml version="1.0" encoding="iso-8859-1"?>
3
+ <!DOCTYPE html
4
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
5
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
6
+
7
+ <!--
8
+
9
+ Methods
10
+
11
+ -->
12
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
13
+ <head>
14
+ <title>Methods</title>
15
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
16
+ <link rel="stylesheet" href="rdoc-style.css" type="text/css" />
17
+ <base target="docwin" />
18
+ </head>
19
+ <body>
20
+ <div id="index">
21
+ <h1 class="section-bar">Methods</h1>
22
+ <div id="index-entries">
23
+ <a href="classes/IRB/CaptureIO.html#M000019">capture (IRB::CaptureIO)</a><br />
24
+ <a href="files/lib/irbtools_rb.html#M000012">cat (lib/irbtools.rb)</a><br />
25
+ <a href="files/lib/irbtools_rb.html#M000011">cd (lib/irbtools.rb)</a><br />
26
+ <a href="files/lib/irbtools_rb.html#M000007">colorize (lib/irbtools.rb)</a><br />
27
+ <a href="files/lib/irbtools_rb.html#M000001">copy (lib/irbtools.rb)</a><br />
28
+ <a href="files/lib/irbtools_rb.html#M000003">copy_input (lib/irbtools.rb)</a><br />
29
+ <a href="files/lib/irbtools_rb.html#M000005">copy_output (lib/irbtools.rb)</a><br />
30
+ <a href="files/lib/irbtools_rb.html#M000004">copy_session_input (lib/irbtools.rb)</a><br />
31
+ <a href="files/lib/irbtools_rb.html#M000006">copy_session_output (lib/irbtools.rb)</a><br />
32
+ <a href="files/lib/irbtools_rb.html#M000010">dir (lib/irbtools.rb)</a><br />
33
+ <a href="classes/Kernel.html#M000022">exec (Kernel)</a><br />
34
+ <a href="classes/Irbtools.html#M000021">init (Irbtools)</a><br />
35
+ <a href="classes/Irbtools.html#M000020">libs (Irbtools)</a><br />
36
+ <a href="files/lib/irbtools_rb.html#M000009">ls (lib/irbtools.rb)</a><br />
37
+ <a href="files/lib/irbtools_rb.html#M000002">paste (lib/irbtools.rb)</a><br />
38
+ <a href="files/lib/irbtools_rb.html#M000008">ray (lib/irbtools.rb)</a><br />
39
+ <a href="files/lib/irbtools_rb.html#M000015">reset! (lib/irbtools.rb)</a><br />
40
+ <a href="files/lib/irbtools_rb.html#M000013">rq (lib/irbtools.rb)</a><br />
41
+ <a href="files/lib/irbtools_rb.html#M000016">ruby_version (lib/irbtools.rb)</a><br />
42
+ <a href="files/lib/irbtools_rb.html#M000014">session_history (lib/irbtools.rb)</a><br />
43
+ <a href="classes/IRB/CaptureIO.html#M000018">streams (IRB::CaptureIO)</a><br />
44
+ <a href="files/lib/irbtools_rb.html#M000017">use (lib/irbtools.rb)</a><br />
45
+ </div>
46
+ </div>
47
+ </body>
48
+ </html>
data/doc/index.html ADDED
@@ -0,0 +1,26 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
5
+
6
+ <!--
7
+
8
+ irbtools 0.0.4
9
+
10
+
11
+ -->
12
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
13
+ <head>
14
+ <title>irbtools 0.0.4
15
+ </title>
16
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
17
+ </head>
18
+ <frameset rows="20%, 80%">
19
+ <frameset cols="25%,35%,45%">
20
+ <frame src="fr_file_index.html" title="Files" name="Files" />
21
+ <frame src="fr_class_index.html" name="Classes" />
22
+ <frame src="fr_method_index.html" name="Methods" />
23
+ </frameset>
24
+ <frame src="files/README_rdoc.html" name="docwin" />
25
+ </frameset>
26
+ </html>
@@ -0,0 +1,208 @@
1
+
2
+ body {
3
+ font-family: Verdana,Arial,Helvetica,sans-serif;
4
+ font-size: 90%;
5
+ margin: 0;
6
+ margin-left: 40px;
7
+ padding: 0;
8
+ background: white;
9
+ }
10
+
11
+ h1,h2,h3,h4 { margin: 0; color: #efefef; background: transparent; }
12
+ h1 { font-size: 150%; }
13
+ h2,h3,h4 { margin-top: 1em; }
14
+
15
+ a { background: #eef; color: #039; text-decoration: none; }
16
+ a:hover { background: #039; color: #eef; }
17
+
18
+ /* Override the base stylesheet's Anchor inside a table cell */
19
+ td > a {
20
+ background: transparent;
21
+ color: #039;
22
+ text-decoration: none;
23
+ }
24
+
25
+ /* and inside a section title */
26
+ .section-title > a {
27
+ background: transparent;
28
+ color: #eee;
29
+ text-decoration: none;
30
+ }
31
+
32
+ /* === Structural elements =================================== */
33
+
34
+ div#index {
35
+ margin: 0;
36
+ margin-left: -40px;
37
+ padding: 0;
38
+ font-size: 90%;
39
+ }
40
+
41
+
42
+ div#index a {
43
+ margin-left: 0.7em;
44
+ }
45
+
46
+ div#index .section-bar {
47
+ margin-left: 0px;
48
+ padding-left: 0.7em;
49
+ background: #ccc;
50
+ font-size: small;
51
+ }
52
+
53
+
54
+ div#classHeader, div#fileHeader {
55
+ width: auto;
56
+ color: white;
57
+ padding: 0.5em 1.5em 0.5em 1.5em;
58
+ margin: 0;
59
+ margin-left: -40px;
60
+ border-bottom: 3px solid #006;
61
+ }
62
+
63
+ div#classHeader a, div#fileHeader a {
64
+ background: inherit;
65
+ color: white;
66
+ }
67
+
68
+ div#classHeader td, div#fileHeader td {
69
+ background: inherit;
70
+ color: white;
71
+ }
72
+
73
+
74
+ div#fileHeader {
75
+ background: #057;
76
+ }
77
+
78
+ div#classHeader {
79
+ background: #048;
80
+ }
81
+
82
+
83
+ .class-name-in-header {
84
+ font-size: 180%;
85
+ font-weight: bold;
86
+ }
87
+
88
+
89
+ div#bodyContent {
90
+ padding: 0 1.5em 0 1.5em;
91
+ }
92
+
93
+ div#description {
94
+ padding: 0.5em 1.5em;
95
+ background: #efefef;
96
+ border: 1px dotted #999;
97
+ }
98
+
99
+ div#description h1,h2,h3,h4,h5,h6 {
100
+ color: #125;;
101
+ background: transparent;
102
+ }
103
+
104
+ div#validator-badges {
105
+ text-align: center;
106
+ }
107
+ div#validator-badges img { border: 0; }
108
+
109
+ div#copyright {
110
+ color: #333;
111
+ background: #efefef;
112
+ font: 0.75em sans-serif;
113
+ margin-top: 5em;
114
+ margin-bottom: 0;
115
+ padding: 0.5em 2em;
116
+ }
117
+
118
+
119
+ /* === Classes =================================== */
120
+
121
+ table.header-table {
122
+ color: white;
123
+ font-size: small;
124
+ }
125
+
126
+ .type-note {
127
+ font-size: small;
128
+ color: #DEDEDE;
129
+ }
130
+
131
+ .xxsection-bar {
132
+ background: #eee;
133
+ color: #333;
134
+ padding: 3px;
135
+ }
136
+
137
+ .section-bar {
138
+ color: #333;
139
+ border-bottom: 1px solid #999;
140
+ margin-left: -20px;
141
+ }
142
+
143
+
144
+ .section-title {
145
+ background: #79a;
146
+ color: #eee;
147
+ padding: 3px;
148
+ margin-top: 2em;
149
+ margin-left: -30px;
150
+ border: 1px solid #999;
151
+ }
152
+
153
+ .top-aligned-row { vertical-align: top }
154
+ .bottom-aligned-row { vertical-align: bottom }
155
+
156
+ /* --- Context section classes ----------------------- */
157
+
158
+ .context-row { }
159
+ .context-item-name { font-family: monospace; font-weight: bold; color: black; }
160
+ .context-item-value { font-size: small; color: #448; }
161
+ .context-item-desc { color: #333; padding-left: 2em; }
162
+
163
+ /* --- Method classes -------------------------- */
164
+ .method-detail {
165
+ background: #efefef;
166
+ padding: 0;
167
+ margin-top: 0.5em;
168
+ margin-bottom: 1em;
169
+ border: 1px dotted #ccc;
170
+ }
171
+ .method-heading {
172
+ color: black;
173
+ background: #ccc;
174
+ border-bottom: 1px solid #666;
175
+ padding: 0.2em 0.5em 0 0.5em;
176
+ }
177
+ .method-signature { color: black; background: inherit; }
178
+ .method-name { font-weight: bold; }
179
+ .method-args { font-style: italic; }
180
+ .method-description { padding: 0 0.5em 0 0.5em; }
181
+
182
+ /* --- Source code sections -------------------- */
183
+
184
+ a.source-toggle { font-size: 90%; }
185
+ div.method-source-code {
186
+ background: #262626;
187
+ color: #ffdead;
188
+ margin: 1em;
189
+ padding: 0.5em;
190
+ border: 1px dashed #999;
191
+ overflow: hidden;
192
+ }
193
+
194
+ div.method-source-code pre { color: #ffdead; overflow: hidden; }
195
+
196
+ /* --- Ruby keyword styles --------------------- */
197
+
198
+ .standalone-code { background: #221111; color: #ffdead; overflow: hidden; }
199
+
200
+ .ruby-constant { color: #7fffd4; background: transparent; }
201
+ .ruby-keyword { color: #00ffff; background: transparent; }
202
+ .ruby-ivar { color: #eedd82; background: transparent; }
203
+ .ruby-operator { color: #00ffee; background: transparent; }
204
+ .ruby-identifier { color: #ffdead; background: transparent; }
205
+ .ruby-node { color: #ffa07a; background: transparent; }
206
+ .ruby-comment { color: #b22222; font-weight: bold; background: transparent; }
207
+ .ruby-regexp { color: #ffa07a; background: transparent; }
208
+ .ruby-value { color: #7fffd4; background: transparent; }
data/irbtools.gemspec ADDED
@@ -0,0 +1,87 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{irbtools}
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 = ["Jan Lelis"]
12
+ s.date = %q{2010-10-06}
13
+ s.description = %q{irbtools is a meta gem which installs some great irb gems and configures your irb. Simply put a require 'irbtools' in the .irbrc file in your home directory.}
14
+ s.email = %q{mail@janlelis.de}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "doc/classes/IRB.html",
27
+ "doc/classes/IRB/CaptureIO.html",
28
+ "doc/classes/Irbtools.html",
29
+ "doc/classes/Kernel.html",
30
+ "doc/created.rid",
31
+ "doc/files/README_rdoc.html",
32
+ "doc/files/lib/irbtools/configure_rb.html",
33
+ "doc/files/lib/irbtools_rb.html",
34
+ "doc/fr_class_index.html",
35
+ "doc/fr_file_index.html",
36
+ "doc/fr_method_index.html",
37
+ "doc/index.html",
38
+ "doc/rdoc-style.css",
39
+ "irbtools.gemspec",
40
+ "lib/irbtools.rb",
41
+ "lib/irbtools/configure.rb"
42
+ ]
43
+ s.homepage = %q{http://github.com/janlelis/irbtools}
44
+ s.rdoc_options = ["--charset=UTF-8"]
45
+ s.require_paths = ["lib"]
46
+ s.requirements = ["You need to add http://merbi.st to your gem sources (irb_rocket)"]
47
+ s.rubygems_version = %q{1.3.7}
48
+ s.summary = %q{irbtools is a meta gem which installs some great irb gems and configures your irb.}
49
+
50
+ if s.respond_to? :specification_version then
51
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
52
+ s.specification_version = 3
53
+
54
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
55
+ s.add_runtime_dependency(%q<wirble>, [">= 0"])
56
+ s.add_runtime_dependency(%q<hirb>, [">= 0"])
57
+ s.add_runtime_dependency(%q<zucker>, [">= 7"])
58
+ s.add_runtime_dependency(%q<awesome_print>, [">= 0"])
59
+ s.add_runtime_dependency(%q<g>, [">= 0"])
60
+ s.add_runtime_dependency(%q<clipboard>, [">= 0"])
61
+ s.add_runtime_dependency(%q<guessmethod>, [">= 0"])
62
+ s.add_runtime_dependency(%q<interactive_editor>, [">= 0"])
63
+ s.add_runtime_dependency(%q<coderay>, [">= 0"])
64
+ else
65
+ s.add_dependency(%q<wirble>, [">= 0"])
66
+ s.add_dependency(%q<hirb>, [">= 0"])
67
+ s.add_dependency(%q<zucker>, [">= 7"])
68
+ s.add_dependency(%q<awesome_print>, [">= 0"])
69
+ s.add_dependency(%q<g>, [">= 0"])
70
+ s.add_dependency(%q<clipboard>, [">= 0"])
71
+ s.add_dependency(%q<guessmethod>, [">= 0"])
72
+ s.add_dependency(%q<interactive_editor>, [">= 0"])
73
+ s.add_dependency(%q<coderay>, [">= 0"])
74
+ end
75
+ else
76
+ s.add_dependency(%q<wirble>, [">= 0"])
77
+ s.add_dependency(%q<hirb>, [">= 0"])
78
+ s.add_dependency(%q<zucker>, [">= 7"])
79
+ s.add_dependency(%q<awesome_print>, [">= 0"])
80
+ s.add_dependency(%q<g>, [">= 0"])
81
+ s.add_dependency(%q<clipboard>, [">= 0"])
82
+ s.add_dependency(%q<guessmethod>, [">= 0"])
83
+ s.add_dependency(%q<interactive_editor>, [">= 0"])
84
+ s.add_dependency(%q<coderay>, [">= 0"])
85
+ end
86
+ end
87
+
data/lib/irbtools.rb CHANGED
@@ -2,54 +2,211 @@
2
2
 
3
3
  # # # # #
4
4
  # require 'irbtools' in your .irbrc
5
- # then call Irbtools.load or require 'irbtools/init' to load libraries
6
5
  # see the README file for more information
7
6
 
8
- require 'set'
9
- require 'zucker/alias_for'
10
- require 'zucker/env' # Info, OS, RubyVersion, RubyEngine
11
-
12
- # suggested libraries
13
- module Irbtools
14
- @libs = Set['rubygems',
15
- 'wirble', # colors
16
- 'hirb', # active record tables
17
- 'fileutils', # cd, pwd, ln_s, mv, rm, mkdir, touch ... ;)
18
- 'zucker/debug', # nice debug printing (q, o, c, .m, .d)
19
- 'ap', # nice debug printing (ap)
20
- 'yaml', # nice debug printing (y)
21
- 'g', # nice debug printing (g) - MacOS only :/
22
- 'clipboard', # easy clipboard access (copy & paste)
23
- 'guessmethod', # automatically correct typos (method_missing hook)
24
- # 'drx', # nice tk object inspector (.see) [not included because it fails to install out of the box on lots of systems]
25
- 'interactive_editor', # lets you open vim (or your favourite editor), hack something, save it, and it's loaded in the current irb session
26
- 'coderay', # some nice colorful display ;)
27
- 'irb_rocket', # put result as comment instead of a new line!
28
- # 'zucker/all' # see rubyzucker.info
29
- ]
30
-
31
- if OS.windows?
32
- @libs -= %w[irb_rocket coderay]
7
+ require File.expand_path('irbtools/configure', File.dirname(__FILE__) )
8
+
9
+ # # # # #
10
+ # load libraries
11
+ Irbtools.libs.each{ |lib|
12
+ begin
13
+ require lib # &&
14
+ case lib
15
+
16
+ when 'wirble'
17
+ Wirble.init
18
+ Wirble.colorize unless OS.windows?
19
+
20
+ when 'hirb'
21
+ Hirb::View.enable
22
+
23
+ when 'fileutils'
24
+ include FileUtils::Verbose
25
+
26
+ when 'clipboard'
27
+ # copies the clipboard
28
+ def copy(str)
29
+ Clipboard.copy(str)
30
+ end
31
+
32
+ # pastes the clipboard
33
+ def paste
34
+ Clipboard.paste
35
+ end
36
+
37
+ # copies everything you have entered in this irb session
38
+ def copy_input
39
+ copy session_history
40
+ "The session input history has been copied to the clipboard."
41
+ end
42
+ alias copy_session_input copy_input
43
+
44
+ # copies the output of all irb commands in this irb session
45
+ def copy_output
46
+ copy context.instance_variable_get(:@eval_history_values).inspect.gsub(/^\d+ (.*)/, '\1')
47
+ "The session output history has been copied to the clipboard."
48
+ end
49
+ alias copy_session_output copy_output
50
+
51
+
52
+ when 'coderay'
53
+ # syntax highlight a string
54
+ def colorize(string)
55
+ puts CodeRay.scan( string, :ruby ).term
56
+ end
57
+
58
+ # syntax highlight a file
59
+ def ray(path)
60
+ puts CodeRay.scan( File.read(path), :ruby ).term
61
+ end
62
+
63
+ end
64
+
65
+ rescue LoadError => err
66
+ if err.to_s =~ /irb_rocket/ && RubyEngine.mri?
67
+ warn "Couldn't load the irb_rocket gem, which is not in the gem dependencies, because it is hosted on a different server.
68
+ You can install it with: gem install irb_rocket --source http://merbi.st"
69
+ else
70
+ warn "Couldn't load an irb library: #{err}"
71
+ end
33
72
  end
73
+ }
74
+
75
+ # # # # #
76
+ # general shortcuts & helper methods
77
+
78
+ # shows the contents of your current directory (more such commands available by FileUtils)
79
+ def ls(path='.')
80
+ Dir[ File.join path, '*' ].map{|res| res =~ /^#{path}\/?/; $' }
81
+ end
82
+ alias dir ls
83
+
84
+ # patch cd so that it also shows the current directory
85
+ def cd(path = '/', *args)
86
+ FileUtils::Verbose.cd path, *args
87
+ ls
88
+ end
34
89
 
35
- unless OS.mac?
36
- @libs -= %w[g]
90
+ # read file contents (also see ray for ruby source files ;) )
91
+ def cat(path)
92
+ File.read path
93
+ end
94
+
95
+ # allows concise syntax like rq:mathn
96
+ def rq(lib)
97
+ require lib.to_s
98
+ end
99
+
100
+ # returns the last lines, needed for some copy_ methods
101
+ def session_history(number_of_lines = context.instance_variable_get(:@line_no) )
102
+ Readline::HISTORY.entries[-number_of_lines...-1]*"\n"
103
+ end
104
+
105
+ # restart irb
106
+ def reset! # restart irb
107
+ exec$0
108
+ end
109
+
110
+ def ruby_version(which = nil)
111
+ # test if installed
112
+ unless `rvm -v` =~ /Seguin/
113
+ raise 'Ruby Version Manager must be installed to use this command'
114
+ end
115
+
116
+ # show rubies if called without options
117
+ if !which
118
+ puts 'Availabe Rubies: ' +
119
+ `rvm list`.scan( /^(?: |=>) (.*) \[/ )*", "
120
+ return
121
+ end
122
+
123
+ # get irb suffix
124
+ rv = `rvm use #{which}` # e.g. => "\ninfo: Using ruby 1.9.2 p0\n"
125
+ # it does not change the ruby for the current user
126
+ rv =~ /^.*Using(.*)\n/
127
+
128
+ # if ruby is found, start it
129
+ if $1
130
+ ruby_name = File.split( $1 )[-1].tr(' ', '-')
131
+ irbname = $0 + '-' + ruby_name + '@global'
132
+ exec irbname
133
+ else
134
+ puts "Sorry, that Ruby version could not be found."
37
135
  end
136
+ end
137
+ alias use ruby_version
138
+
139
+ # # # # #
140
+ # irb options
141
+ IRB.conf[:AUTO_INDENT] = true # simple auto indent
142
+ IRB.conf[:EVAL_HISTORY] = 42424242424242424242 # creates the special __ variable
143
+ IRB.conf[:SAVE_HISTORY] = 2000 # how many lines will go to ~/.irb_history
144
+
145
+ # prompt
146
+ IRB.conf[:PROMPT].merge!({:IRBTOOLS => {
147
+ :PROMPT_I => ">> ", # normal
148
+ :PROMPT_N => "| ", # indenting
149
+ :PROMPT_C => "(>>) ", # continuing a statement
150
+ :PROMPT_S => "%l> ", # continuing a string
151
+ :RETURN => "=> %s \n",
152
+ :AUTO_INDENT => true,
153
+ }})
154
+
155
+ IRB.conf[:PROMPT_MODE] = :IRBTOOLS
156
+
157
+ # # # # #
158
+ # misc
159
+ Zucker.more_aliases! # RubyVersion --> RV, RubyEngine --> RE
160
+
161
+ # # # # #
162
+ # workarounds
163
+
164
+ # irb_rocket stdout problems
165
+ if IRB.const_defined? :CaptureIO
166
+ module IRB
167
+ class CaptureIO
168
+ def self.streams
169
+ {
170
+ :stdout => @@current_capture.instance_variable_get( :@out ),
171
+ :stderr => @@current_capture.instance_variable_get( :@err ),
172
+ }
173
+ end
38
174
 
39
- if RubyVersion.is? 1.9
40
- @libs -= %w[guessmethod]
175
+ alias original_capture capture
176
+ def capture(&block)
177
+ @@current_capture = self
178
+ original_capture &block
179
+ end
180
+ end
41
181
  end
42
182
 
43
- class << self
44
- def libs
45
- @libs
183
+ # patch method using stdout
184
+ module Kernel
185
+ alias exec_unpatched exec
186
+ def exec(*args)
187
+ STDOUT.reopen(IRB::CaptureIO.streams[:stdout])
188
+ STDERR.reopen(IRB::CaptureIO.streams[:stderr])
189
+ exec_unpatched *args
46
190
  end
47
- aliases_for :libs, :gems, :libraries
191
+ end
48
192
 
49
- def load
50
- require File.expand_path( 'irbtools/init', File.dirname(__FILE__) )
193
+ if Object.const_defined? :InteractiveEditor
194
+ InteractiveEditor::Editors.class_eval do
195
+ editors = %w[vi vim emacs nano mate ed]
196
+ editors.each{ |editor|
197
+ alias_for editor, editor_unpatched = ( editor + '_unpatched' ).to_sym
198
+ define_method editor do
199
+ STDOUT.reopen(IRB::CaptureIO.streams[:stdout])
200
+ STDERR.reopen(IRB::CaptureIO.streams[:stderr])
201
+ send editor_unpatched
202
+ end
203
+ }
51
204
  end
52
205
  end
53
206
  end
54
207
 
208
+ # # # # #
209
+ # done :)
210
+ puts "Welcome to IRB. You are using #{ RUBY_DESCRIPTION }. Have fun ;)"
211
+
55
212
  # J-_-L