irbtools 0.7.4 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +6 -0
- data/README.rdoc +23 -3
- data/Rakefile +2 -2
- data/VERSION +1 -1
- data/irbtools.gemspec +3 -3
- data/lib/irbtools.rb +44 -15
- data/lib/irbtools/configure.rb +35 -17
- data/lib/irbtools/general.rb +37 -3
- data/lib/irbtools/libraries.rb +5 -6
- metadata +6 -6
data/CHANGELOG
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
0.8.0
|
2
|
+
* added Object#ri method
|
3
|
+
* feature: extension package loading (e.g. irbtools-more)
|
4
|
+
* feature: loading in IRB.conf[:IRB_RC] (loading when a subirb starts, no more guessmethod rails errors)
|
5
|
+
* added rerequire (rrq) and ld load helper
|
6
|
+
|
1
7
|
0.7.4
|
2
8
|
* added workaround to use irb_rocket and hirb at the same time (basic hack, e.g. paging does not work)
|
3
9
|
* fixed little VERSION bug
|
data/README.rdoc
CHANGED
@@ -23,12 +23,21 @@ If it does not exist, just create a new one.
|
|
23
23
|
It's possible to modify, which libraries get loaded:
|
24
24
|
|
25
25
|
require 'irbtools/configure'
|
26
|
-
# here you can
|
26
|
+
# here you can modify which libraries get loaded (see below)
|
27
27
|
Irbtools.init
|
28
28
|
|
29
|
+
=== How to load more or less libraries
|
30
|
+
|
31
|
+
You have the following ways:
|
32
|
+
* <tt>Irbtools.add_library(lib, in_proc = false, &block)</tt>
|
33
|
+
* <tt>Irbtools.remove_library(lib)</tt>
|
34
|
+
* <tt>Irbtools.add_package(pkg)</tt>
|
35
|
+
* <tt>Irbtools.remove_package(pkg)</tt>
|
36
|
+
* Edit the <tt>Irbtools.libraries</tt>, <tt>Irbtools.libraries_in_proc</tt> or <tt>Irbtools.packages</tt> arrays directly (no way to set callbacks).
|
37
|
+
|
29
38
|
== Features
|
30
39
|
|
31
|
-
See http://rbjl.net/40-irbtools-release-the-power-of-irb or read the commented source file
|
40
|
+
See http://rbjl.net/40-irbtools-release-the-power-of-irb or read the commented source file.
|
32
41
|
|
33
42
|
=== Included gems and libraries
|
34
43
|
|
@@ -46,16 +55,27 @@ See http://rbjl.net/40-irbtools-release-the-power-of-irb or read the commented s
|
|
46
55
|
* boson[http://tagaholic.me/boson/] IRB commands repository (which also works for the shell!)
|
47
56
|
* irb_rocket[http://merbi.st/plugins/22] put result as comment instead of a new line!
|
48
57
|
|
58
|
+
=== Helper methods
|
59
|
+
See the source/rdoc for a description. These methods are defined directly by irbtools.
|
60
|
+
|
61
|
+
*General*: <tt>ls, cat, rq, rrq/rerequire, ls, session_history, reset!, clear, use_ruby/use, dbg, Object#ri</tt>
|
62
|
+
|
63
|
+
*Clipboard*: <tt>copy, paste, copy_input, copy_output</tt>
|
64
|
+
|
65
|
+
*CodeRay*: <tt>colorize, ray</tt>
|
66
|
+
|
49
67
|
== Bugs / TODO
|
50
68
|
|
51
69
|
* Make guessmethod 1.9 compatible
|
52
70
|
* Fix Clipboard Windows issues
|
53
71
|
* Fix irb_rockets general stdout problem. If something stdout related fails, odds are high that it's irb_rockets fault.
|
72
|
+
* Pager for hirb and ri
|
73
|
+
* Use RDoc driver instead of system ri for ri (?)
|
54
74
|
* ...
|
55
75
|
|
56
76
|
== More Features
|
57
77
|
|
58
|
-
*
|
78
|
+
* See the irbtools-more[http://github.com/janlelis/irbtools-more] package.
|
59
79
|
|
60
80
|
== Copyright
|
61
81
|
|
data/Rakefile
CHANGED
@@ -10,7 +10,7 @@ begin
|
|
10
10
|
gem.email = "mail@janlelis.de"
|
11
11
|
gem.homepage = "http://github.com/janlelis/irbtools"
|
12
12
|
gem.authors = ["Jan Lelis"]
|
13
|
-
gem.requirements << '
|
13
|
+
gem.requirements << "It's recommended to use the irb_rocket gem: gem install irb_rocket --source http://merbi.st"
|
14
14
|
gem.add_dependency 'wirble'
|
15
15
|
gem.add_dependency 'hirb'
|
16
16
|
gem.add_dependency 'zucker', '>=8'
|
@@ -30,7 +30,7 @@ end
|
|
30
30
|
|
31
31
|
require 'rake/rdoctask'
|
32
32
|
Rake::RDocTask.new do |rdoc|
|
33
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
33
|
+
version = File.exist?('VERSION') ? File.read('VERSION').chomp : ""
|
34
34
|
|
35
35
|
rdoc.rdoc_dir = 'doc'
|
36
36
|
rdoc.title = "irbtools #{version}"
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.8.0
|
data/irbtools.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{irbtools}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.8.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jan Lelis"]
|
12
|
-
s.date = %q{2010-10-
|
12
|
+
s.date = %q{2010-10-12}
|
13
13
|
s.description = %q{irbtools is a meta gem which installs some useful irb gems and configures your irb. Simply put a require 'irbtools' in the .irbrc file in your home directory.}
|
14
14
|
s.email = %q{mail@janlelis.de}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -36,7 +36,7 @@ Gem::Specification.new do |s|
|
|
36
36
|
s.homepage = %q{http://github.com/janlelis/irbtools}
|
37
37
|
s.rdoc_options = ["--charset=UTF-8"]
|
38
38
|
s.require_paths = ["lib"]
|
39
|
-
s.requirements = ["
|
39
|
+
s.requirements = ["It's recommended to use the irb_rocket gem: gem install irb_rocket --source http://merbi.st"]
|
40
40
|
s.rubygems_version = %q{1.3.7}
|
41
41
|
s.summary = %q{irbtools is a meta gem which installs some useful irb gems and configures your irb.}
|
42
42
|
|
data/lib/irbtools.rb
CHANGED
@@ -3,31 +3,56 @@
|
|
3
3
|
# # # # #
|
4
4
|
# require 'irbtools' in your .irbrc
|
5
5
|
# see the README file for more information
|
6
|
-
|
7
6
|
require File.expand_path('irbtools/configure', File.dirname(__FILE__) ) unless defined? Irbtools
|
8
7
|
|
8
|
+
# # # # #
|
9
|
+
# load extension packages
|
10
|
+
Irbtools.packages.each{ |pkg|
|
11
|
+
begin
|
12
|
+
require "irbtools/#{pkg}"
|
13
|
+
|
14
|
+
rescue LoadError => err
|
15
|
+
warn "Couldn't load an extension package: #{err}"
|
16
|
+
end
|
17
|
+
}
|
18
|
+
|
9
19
|
# # # # #
|
10
20
|
# load libraries
|
11
|
-
remember_verbose_and_debug = $VERBOSE, $DEBUG
|
12
|
-
$VERBOSE = $DEBUG = false
|
13
21
|
|
14
|
-
|
15
|
-
|
16
|
-
|
22
|
+
# load helper proc
|
23
|
+
load_libraries_proc = proc{ |libs|
|
24
|
+
remember_verbose_and_debug = $VERBOSE, $DEBUG
|
25
|
+
$VERBOSE = $DEBUG = false
|
17
26
|
|
18
|
-
|
27
|
+
libs.each{ |lib|
|
28
|
+
begin
|
29
|
+
require lib.to_s
|
19
30
|
|
20
|
-
|
21
|
-
|
22
|
-
|
31
|
+
Irbtools.send :library_loaded, lib
|
32
|
+
|
33
|
+
rescue LoadError => err
|
34
|
+
if err.to_s =~ /irb_rocket/ && RubyEngine.mri?
|
35
|
+
warn "Couldn't load the irb_rocket gem.
|
23
36
|
You can install it with: gem install irb_rocket --source http://merbi.st"
|
24
|
-
|
25
|
-
|
37
|
+
else
|
38
|
+
warn "Couldn't load an irb library: #{err}"
|
39
|
+
end
|
26
40
|
end
|
27
|
-
|
41
|
+
}
|
42
|
+
$VERBOSE, $DEBUG = remember_verbose_and_debug
|
28
43
|
}
|
29
44
|
|
30
|
-
|
45
|
+
# load them :)
|
46
|
+
load_libraries_proc[ Irbtools.libraries ]
|
47
|
+
|
48
|
+
# load these each time a new sub irb starts
|
49
|
+
original_irbrc_proc = IRB.conf[:IRB_RC]
|
50
|
+
IRB.conf[:IRB_RC] = proc{
|
51
|
+
load_libraries_proc[ Irbtools.libraries_in_proc ]
|
52
|
+
original_irbrc_proc[ ] if original_irbrc_proc
|
53
|
+
}
|
54
|
+
|
55
|
+
|
31
56
|
|
32
57
|
# # # # #
|
33
58
|
# general shortcuts & helper methods
|
@@ -53,10 +78,14 @@ IRB.conf[:PROMPT_MODE] = :IRBTOOLS
|
|
53
78
|
|
54
79
|
# # # # #
|
55
80
|
# misc
|
81
|
+
|
82
|
+
# add current directory to the loadpath
|
83
|
+
$: << '.' if RubyVersion.is.at_least? '1.9.2'
|
84
|
+
|
85
|
+
# shoter ruby info constants
|
56
86
|
Object.const_set 'RV', RubyVersion rescue nil
|
57
87
|
Object.const_set 'RE', RubyEngine rescue nil
|
58
88
|
|
59
|
-
# # # # #
|
60
89
|
# load rails.rc
|
61
90
|
begin
|
62
91
|
if ( ENV['RAILS_ENV'] || defined? Rails ) && Irbtools.railsrc
|
data/lib/irbtools/configure.rb
CHANGED
@@ -16,52 +16,70 @@ end
|
|
16
16
|
# define module methods
|
17
17
|
module Irbtools
|
18
18
|
@lib_hooks = Hash.new{|h,k| h[k] = [] }
|
19
|
-
@libs = %w[rubygems]
|
19
|
+
@libs = [] # %w[rubygems]
|
20
|
+
@libs_in_proc = []
|
21
|
+
@packages = []
|
20
22
|
@railsrc = '~/.railsrc'
|
21
23
|
|
22
24
|
class << self
|
23
|
-
|
24
|
-
|
25
|
-
end
|
26
|
-
aliases_for :libraries, :gems, :libs
|
25
|
+
# lets you define the path to the irbrc or deactivate this feature with nil
|
26
|
+
attr_accessor :railsrc
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
aliases_for :
|
28
|
+
# an array of the libraries which get loaded at start
|
29
|
+
attr_accessor :libs
|
30
|
+
aliases_for :libs, :libraries, :gems
|
31
|
+
aliases_for :libs=, :libraries=, :gems=
|
32
|
+
|
33
|
+
# an array of the libraries which get loaded everytime a new subirb starts (IRB.conf[:IRB_RC])
|
34
|
+
attr_accessor :libs_in_proc
|
35
|
+
aliases_for :libs_in_proc, :libraries_in_proc, :gems_in_proc
|
36
|
+
aliases_for :libs_in_proc=, :libraries_in_proc=, :gems_in_proc=
|
37
|
+
|
38
|
+
# an array of extension packages which get loaded (e.g. irbtools-more)
|
39
|
+
attr_accessor :packages
|
40
|
+
|
41
|
+
# add a library. the block gets executed, when the library was loaded.
|
42
|
+
# if the second param is true, it's hooked in into IRB.conf[:IRB_RC] instead of the start.
|
43
|
+
def add_library(lib, in_proc = false, &block)
|
44
|
+
libs = in_proc ? @libs_in_proc : @libs
|
45
|
+
libs << lib.to_s unless libs.include? lib.to_s
|
32
46
|
|
33
|
-
def add_library(lib, &block)
|
34
|
-
@libs << lib.to_s unless @libs.include? lib.to_s
|
35
47
|
@lib_hooks[lib.to_s] << block if block_given?
|
36
48
|
end
|
37
49
|
aliases_for :add_library, :add_lib, :add_gem
|
38
50
|
|
51
|
+
# don't load a specific library
|
39
52
|
def remove_library(lib)
|
40
53
|
@libs.delete lib.to_s
|
54
|
+
@libs_in_proc.delete lib.to_s
|
41
55
|
@lib_hooks.delete lib.to_s
|
42
56
|
end
|
43
57
|
aliases_for :remove_library, :remove_lib, :remove_gem
|
44
58
|
|
45
|
-
|
46
|
-
|
59
|
+
# add extensions packages
|
60
|
+
def add_package(pkg)
|
61
|
+
@packages << pkg.to_s
|
47
62
|
end
|
48
63
|
|
49
|
-
|
50
|
-
|
64
|
+
# remove extension package
|
65
|
+
def remove_package(pkg)
|
66
|
+
@packages.delete pkg.to_s
|
51
67
|
end
|
52
68
|
|
53
|
-
|
69
|
+
|
70
|
+
def library_loaded(lib) #:nodoc:
|
54
71
|
@lib_hooks[lib.to_s].each{ |hook| hook.call }
|
55
72
|
end
|
56
73
|
private :library_loaded
|
57
74
|
|
75
|
+
# loads all the stuff ;)
|
58
76
|
def init
|
59
77
|
require File.expand_path( '../irbtools.rb', File.dirname(__FILE__) )
|
60
78
|
end
|
61
79
|
alias start init
|
62
80
|
end
|
63
81
|
|
64
|
-
VERSION = File.read File.expand_path( '../../VERSION', File.dirname(__FILE__) ).chomp
|
82
|
+
VERSION = ( File.read File.expand_path( '../../VERSION', File.dirname(__FILE__)) ).chomp
|
65
83
|
end
|
66
84
|
|
67
85
|
# # # # #
|
data/lib/irbtools/general.rb
CHANGED
@@ -9,11 +9,23 @@ def cat(path)
|
|
9
9
|
File.read path
|
10
10
|
end
|
11
11
|
|
12
|
-
# allows concise syntax like rq:mathn
|
12
|
+
# allows concise syntax like rq:mathn and reloading/requireing
|
13
13
|
def rq(lib)
|
14
14
|
require lib.to_s
|
15
15
|
end
|
16
16
|
|
17
|
+
# reloading, hints from http://www.themomorohoax.com/2009/03/27/irb-tip-load-files-faster
|
18
|
+
def rerequire(lib)
|
19
|
+
$".delete( "#{lib}.rb" )
|
20
|
+
require( lib.to_s )
|
21
|
+
end
|
22
|
+
alias rrq rerequire
|
23
|
+
|
24
|
+
# load shortcut
|
25
|
+
def ld(lib)
|
26
|
+
load lib.to_s + '.rb'
|
27
|
+
end
|
28
|
+
|
17
29
|
# returns the last lines, needed for some copy_ methods
|
18
30
|
def session_history(number_of_lines = context.instance_variable_get(:@line_no) )
|
19
31
|
Readline::HISTORY.entries[-number_of_lines...-1]*"\n"
|
@@ -25,7 +37,13 @@ def reset!
|
|
25
37
|
exit
|
26
38
|
end
|
27
39
|
|
28
|
-
|
40
|
+
# just clear the screen
|
41
|
+
def clear
|
42
|
+
system 'clear'
|
43
|
+
end
|
44
|
+
|
45
|
+
# change ruby version (requires rvm)
|
46
|
+
def use_ruby(which = nil)
|
29
47
|
# test if installed
|
30
48
|
unless `rvm -v` =~ /Seguin/
|
31
49
|
raise 'Ruby Version Manager must be installed to use this command'
|
@@ -53,7 +71,7 @@ def ruby_version(which = nil)
|
|
53
71
|
puts "Sorry, that Ruby version could not be found."
|
54
72
|
end
|
55
73
|
end
|
56
|
-
alias use
|
74
|
+
alias use use_ruby
|
57
75
|
|
58
76
|
# load debugger, inspired by rdp
|
59
77
|
def dbg
|
@@ -64,3 +82,19 @@ def dbg
|
|
64
82
|
throw "Sorry, unable to load ruby-debug gem for debugger: #{e}"
|
65
83
|
end
|
66
84
|
end
|
85
|
+
|
86
|
+
class Object
|
87
|
+
# display ri entry
|
88
|
+
def ri(meth)
|
89
|
+
ri_cmd = 'ri'
|
90
|
+
if instance_of?( Kernel ) || instance_of?( Object )
|
91
|
+
puts `#{ri_cmd} #{meth}`
|
92
|
+
elsif is_a? Module
|
93
|
+
puts `#{ri_cmd} #{self}.#{meth}`
|
94
|
+
else
|
95
|
+
puts `#{ri_cmd} #{self.class}##{meth}`
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
# J-_-L
|
data/lib/irbtools/libraries.rb
CHANGED
@@ -70,13 +70,13 @@ Irbtools.add_library 'zucker/debug' # nice debug printing (q, o, c, .m, .d)
|
|
70
70
|
Irbtools.add_library 'ap' # nice debug printing (ap)
|
71
71
|
Irbtools.add_library 'yaml' # nice debug printing (y)
|
72
72
|
Irbtools.add_library 'g' # nice debug printing (g) - MacOS only :/
|
73
|
-
Irbtools.add_library 'guessmethod'
|
73
|
+
Irbtools.add_library 'guessmethod', true # automatically correct typos (method_missing hook)
|
74
74
|
Irbtools.add_library 'interactive_editor' # lets you open vim (or your favourite editor), hack something, save it, and it's loaded in the current irb session
|
75
|
-
#Irbtools.add_library 'zucker/all'
|
75
|
+
#Irbtools.add_library 'zucker/all' # see rubyzucker.info
|
76
76
|
|
77
77
|
Irbtools.add_library :boson do
|
78
|
-
|
79
|
-
|
78
|
+
undef :install if respond_to?( :install, true )
|
79
|
+
Boson.start :verbose => false
|
80
80
|
end
|
81
81
|
|
82
82
|
# remove failing/not needed libs
|
@@ -89,8 +89,7 @@ unless OS.mac?
|
|
89
89
|
end
|
90
90
|
|
91
91
|
if RubyVersion.is? 1.9
|
92
|
-
Irbtools.
|
92
|
+
Irbtools.libraries_in_proc -= %w[guessmethod]
|
93
93
|
end
|
94
94
|
|
95
95
|
# J-_-L
|
96
|
-
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: irbtools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 63
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 8
|
9
|
+
- 0
|
10
|
+
version: 0.8.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jan Lelis
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-10-
|
18
|
+
date: 2010-10-12 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -211,7 +211,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
211
211
|
- 0
|
212
212
|
version: "0"
|
213
213
|
requirements:
|
214
|
-
-
|
214
|
+
- "It's recommended to use the irb_rocket gem: gem install irb_rocket --source http://merbi.st"
|
215
215
|
rubyforge_project:
|
216
216
|
rubygems_version: 1.3.7
|
217
217
|
signing_key:
|