irbtools 1.7.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/{CHANGELOG → CHANGELOG.txt} +14 -0
- data/CONFIGURE.md +55 -0
- data/{MIT-LICENSE → MIT-LICENSE.txt} +1 -1
- data/README.md +195 -0
- data/Rakefile +16 -14
- data/irbtools.gemspec +44 -35
- data/lib/irbtools.rb +58 -110
- data/lib/irbtools/binding.rb +19 -0
- data/lib/irbtools/configure.rb +3 -136
- data/lib/irbtools/hirb.rb +46 -0
- data/lib/irbtools/implementation.rb +156 -0
- data/lib/irbtools/libraries.rb +36 -147
- data/lib/irbtools/minimal.rb +1 -3
- data/lib/irbtools/non_fancy.rb +7 -0
- data/lib/irbtools/version.rb +3 -0
- metadata +118 -86
- data/README.rdoc +0 -203
data/README.rdoc
DELETED
@@ -1,203 +0,0 @@
|
|
1
|
-
= irbtools
|
2
|
-
|
3
|
-
Improvements for Ruby's IRB console, for example, colored output, and a lot of debugging and introspection methods. Unlike with PRY, you are still in your normal IRB. It is designed to work out-of-the-box so there is no reason to not use it!
|
4
|
-
|
5
|
-
|
6
|
-
== Setup
|
7
|
-
|
8
|
-
$ gem install irbtools
|
9
|
-
|
10
|
-
|
11
|
-
=== Extra Requirements
|
12
|
-
|
13
|
-
Linux: Clipboard support requires *xclip* or *xsel*: <tt>sudo apt-get install xclip</tt>
|
14
|
-
|
15
|
-
Windows: ANSI colors can be enabled via ansicon[https://github.com/adoxa/ansicon]
|
16
|
-
|
17
|
-
Mac OS: The g gem makes use of *growl*
|
18
|
-
|
19
|
-
|
20
|
-
== Usage
|
21
|
-
|
22
|
-
IRB executes code in <tt>~/.irbrc</tt> on start-up. If the file does not exist, yet, just create a new one. Add the following:
|
23
|
-
|
24
|
-
require 'irbtools'
|
25
|
-
|
26
|
-
See further below, if you want to customize which libraries should be loaded on IRB start-up.
|
27
|
-
|
28
|
-
|
29
|
-
=== With Bundler
|
30
|
-
|
31
|
-
To integrate *irbtools* into a Rails console (or any project that uses bundler), add <tt>irbtools</tt> to your Gemfile:
|
32
|
-
|
33
|
-
gem 'irbtools', require: 'binding.repl'
|
34
|
-
|
35
|
-
Thanks to help from the {binding.repl gem}[https://github.com/rpag/binding.repl], you can start IRB (with *irbtools*) directly from your code:
|
36
|
-
|
37
|
-
binding.repl!
|
38
|
-
|
39
|
-
|
40
|
-
=== Debundle
|
41
|
-
|
42
|
-
Another way to activate *irbtools* in bundler projects is to add a {debundle hack}[https://github.com/janlelis/debundle.rb] at the beginning of your <tt>~/.irbrc</tt> file.
|
43
|
-
|
44
|
-
|
45
|
-
=== This is irbtools Light
|
46
|
-
|
47
|
-
When installing *irbtools*, some gems will not be installed to ensure Windows OS support, for example, the bond gem for better auto-completion or the looksee gem for method/class introspection. These are packaged as {irbtools-more}[https://github.com/janlelis/irbtools-more]. To use <tt>irbtools-more</tt>, you will need to change your <tt>.irbrc</tt> to:
|
48
|
-
|
49
|
-
require 'irbtools/more'
|
50
|
-
|
51
|
-
and/or edit your Gemfile to
|
52
|
-
|
53
|
-
gem 'irbtools-more', require: 'binding.repl'
|
54
|
-
|
55
|
-
|
56
|
-
=== Included Gems and Libraries
|
57
|
-
==== IRB Improvements
|
58
|
-
|
59
|
-
* Colorization: wirb[https://github.com/janlelis/wirb/]
|
60
|
-
* IRB tweaks: fancy_irb[https://github.com/janlelis/fancy_irb]
|
61
|
-
* Custom views for specific objects: hirb[http://tagaholic.me/2009/03/13/hirb-irb-on-the-good-stuff.html]
|
62
|
-
* <b>(irbtools-more)</b> Better IRB tab-completion: bond[http://tagaholic.me/bond/]
|
63
|
-
|
64
|
-
|
65
|
-
==== Helpful Methods
|
66
|
-
|
67
|
-
* Useful IRB commands: every_day_irb[https://github.com/janlelis/irbtools/tree/master/lib/every_day_irb.rb]
|
68
|
-
* Clipboard Access: clipboard[http://github.com/janlelis/clipboard]
|
69
|
-
* Loads an editor into your IRB session: interactive_editor[https://github.com/jberkel/interactive_editor]
|
70
|
-
* Print debugging helpers: debugging[https:/github.com/janlelis/debugging]
|
71
|
-
* File-related system commands: *fileutils* (stdlib)
|
72
|
-
|
73
|
-
|
74
|
-
==== Platform Information
|
75
|
-
|
76
|
-
* Query current Ruby version: ruby_version[https://github.com/janlelis/ruby_version]
|
77
|
-
* Query current Ruby engine: ruby_engine[https://github.com/janlelis/ruby_engine]
|
78
|
-
* Query current operating system: os[https://github.com/rdp/os]
|
79
|
-
* Global information by the interpreter behind one <tt>Info</tt> constant: ruby_info[https://github.com/janlelis/ruby_info]
|
80
|
-
|
81
|
-
|
82
|
-
==== Introspection
|
83
|
-
|
84
|
-
* Improved lookup path inspection: method_locator[https://github.com/ryanlecompte/method_locator]
|
85
|
-
* Displays a method's source: method_source[https://github.com/banister/method_source]
|
86
|
-
* Adds a +ri+ doc method to Object: [ori[https://github.com/dadooda/ori]
|
87
|
-
* Finds the methods that turned a value into another value: methodfinder[https://github.com/citizen428/methodfinder]
|
88
|
-
* Syntax highlighting: coderay[https://github.com/rubychan/coderay]
|
89
|
-
* <b>irbtools-more</b> Awesome lookup path inspection: looksee[https://github.com/oggy/looksee]
|
90
|
-
* <b>irbtools-more</b> Useful "did you mean?" suggestions in stack-traces: did_you_mean[https://github.com/yuki42/did_you_mean]
|
91
|
-
|
92
|
-
|
93
|
-
==== Code Organization
|
94
|
-
|
95
|
-
* Command/task framework similar to rake and thor: boson[http://tagaholic.me/boson/]
|
96
|
-
* Shortcuts for your favorite methods, saved in personal yaml file: alias[http://tagaholic.me/2009/07/07/alias-quickness-in-the-ruby-console.html]
|
97
|
-
|
98
|
-
|
99
|
-
=== Irbtools Methods
|
100
|
-
==== From every_day_irb
|
101
|
-
|
102
|
-
[ls] Returns an array with the directory's content
|
103
|
-
[cat] Shortcut for <tt>File.read</tt>
|
104
|
-
[rq] Shortcut for <tt>require library.to_s</tt> (allows concise syntax like <tt>rq:mathn</tt>)
|
105
|
-
[ld] Shortcut for <tt>load library.to_s + '.rb'</tt>
|
106
|
-
[rrq/rerequire] Little hack for rerequiring a library (it's really hack and not reliable, but works in most cases)
|
107
|
-
[reset!] Restarts IRB
|
108
|
-
[clear] Clears the terminal (<tt>system "clear"</tt>)
|
109
|
-
[session_history] Returns all issued commands as a string
|
110
|
-
|
111
|
-
|
112
|
-
==== From irbtools in conjunction with the libraries
|
113
|
-
|
114
|
-
[cd] Improves the cd that is already provided by *fileutils* (try <tt>cd '-'</tt>)
|
115
|
-
[version] Displays RubyVersion
|
116
|
-
[engine] Displays RubyEngine
|
117
|
-
[os] OS information
|
118
|
-
[info] Aggregates information about your Ruby environment
|
119
|
-
[copy] Shortcut for <tt>Clipboard.copy</tt>
|
120
|
-
[paste] Shortcut for <tt>Clipboard.paste</tt>
|
121
|
-
[copy_input] Copies the session_history to the clipboard
|
122
|
-
[copy_output] Copies this session's results to the clipboard
|
123
|
-
[mf] Shortcut for using the *methodfinder*
|
124
|
-
[page] Shortcut for using the pager from *hirb*
|
125
|
-
[colorize] Syntax highlights a ruby string using *coderay*
|
126
|
-
[ray] Syntax highlights a ruby file using *coderay*
|
127
|
-
|
128
|
-
|
129
|
-
==== From the libraries (puplic Object methods, renamed/patched)
|
130
|
-
|
131
|
-
[ri] Patching the +ri+ provided by *ori* to also allow default ri syntax on toplevel
|
132
|
-
[src] Shortcut for displaying the method source using *method_source* and *coderay*
|
133
|
-
[mlp] Shortcut for the *method_locator*
|
134
|
-
[l/lp] Alternative method name to trigger the *looksee* gem (<b>irbtools-more</b>)
|
135
|
-
|
136
|
-
|
137
|
-
== Advanced tweaking
|
138
|
-
=== Customize libraries to load
|
139
|
-
|
140
|
-
It is possible to modify, which libraries to load:
|
141
|
-
|
142
|
-
# Don't require 'irbtools', but:
|
143
|
-
require 'irbtools/configure'
|
144
|
-
# Here you can modify the libraries using the methods below
|
145
|
-
Irbtools.start
|
146
|
-
|
147
|
-
If you do not want to load the default set of *irbtools* gems, you will have to use <tt>require 'irbtools/minimal'</tt> instead of <tt>configure</tt>.
|
148
|
-
|
149
|
-
You can use the following methods:
|
150
|
-
|
151
|
-
* <tt>Irbtools.add_library(lib, options_hash, &block)</tt>
|
152
|
-
* <tt>Irbtools.remove_library(lib)</tt>
|
153
|
-
|
154
|
-
The <tt>options_hash</tt> defines the way in which *irbtools* loads the library. The following options are possible
|
155
|
-
[(no options)/<tt>:start</tt>] The library is required on startup before doing anything else (before displaying the prompt)
|
156
|
-
[<tt>:thread => identifier</tt>] After loading everything else, the library is required in a thread (while continuing loading). You can choose any identifier, but if you take the same one for multiple libraries, they will be loaded in the same thread (in the order that you define)
|
157
|
-
[<tt>:late => true</tt>] The library is required just before showing the prompt (note: loading threads might still be in process)
|
158
|
-
[<tt>:late_thread => identifier</tt>] Same as <tt>:thread</tt>, but after loading late libraries.
|
159
|
-
[<tt>:sub_session => true</tt>] The library is loaded every time a sub-session starts (using <tt>IRB.conf[:IRB_RC]</tt>). In ripl[https://github.com/cldwalker/ripl], <tt>ripl-after_rc</tt> is used.
|
160
|
-
[<tt>:autoload => :Constant</tt>] Use Ruby's <tt>autoload</tt> feature. It loads the library as soon as the constant is encountered.
|
161
|
-
|
162
|
-
You can pass a block as third argument, which gets executed after the library has completed loading (except for <tt>:autoload</tt>, in which case the code will be executed directly on startup). You can modify the callbacks by using <tt>Irbtools.add_library_callback</tt> and <tt>Irbtools.replace_library_callback</tt>.
|
163
|
-
|
164
|
-
When adding a new library, you should firstly consider some way to load it via <tt>:autoload</tt>.
|
165
|
-
If this is not possible, try loading via <tt>:thread</tt>. If that is not possible either, you will need to fallback to the default loading mechanism.
|
166
|
-
|
167
|
-
|
168
|
-
== Troubleshooting: Unicode causes wrong display widths?
|
169
|
-
|
170
|
-
If you use double-width unicode characterss, you will need to paste the following snippet to your <tt>.irbrc</tt> file.
|
171
|
-
|
172
|
-
Irbtools.replace_library_callback :fancy_irb do
|
173
|
-
FancyIrb.start east_asian_width: true
|
174
|
-
end
|
175
|
-
|
176
|
-
This setting is deactivated by default, because of performance issues.
|
177
|
-
|
178
|
-
|
179
|
-
== Hint: Faster start-up
|
180
|
-
|
181
|
-
You can get an about a second faster start-up time by changing the loading methods for wirb and fancy_irb to <tt>:thread</tt> (drawback: the hash rocket will not be used for the first result):
|
182
|
-
|
183
|
-
require 'irbtools/configure'
|
184
|
-
Irbtools.remove_library :paint
|
185
|
-
Irbtools.remove_library :fancy_irb
|
186
|
-
Irbtools.add_library :paint, :late => true do Wirb.load_schema :classic_paint if defined? Wirb end
|
187
|
-
Irbtools.add_library :fancy_irb, :thread => -1 do FancyIrb.start end
|
188
|
-
Irbtools.start
|
189
|
-
|
190
|
-
|
191
|
-
== Welcome Message
|
192
|
-
|
193
|
-
The welcome message can be customized with <tt>Irbtools.welcome_message=</tt>
|
194
|
-
|
195
|
-
|
196
|
-
== Web Console
|
197
|
-
|
198
|
-
*irbtools* works well together with the amazing {web-console!}[https://github.com/rails/web-console]
|
199
|
-
|
200
|
-
|
201
|
-
== J-_-L
|
202
|
-
|
203
|
-
Copyright (c) 2010-2015 Jan Lelis <http://janlelis.com> released under the MIT license.
|