irbtools 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ 1.0.6
2
+ * add possibility to modify library callbacks without removing the library by using: replace_library_callback or add_library_callback
3
+ * fix hirb dependency issue
4
+ * readme improvements
5
+
1
6
  1.0.5
2
7
  * use paint gem for terminal colors
3
8
 
data/README.rdoc CHANGED
@@ -1,5 +1,5 @@
1
1
  = irbtools
2
- This is a meta gem that installs useful irb gems and configures your irb. It has a modular structure and supports multiple library-loading mechanisms, e.g. via <tt>autoload</tt> or threads.
2
+ This is a meta gem that installs useful irb gems and configures them for you. It has a modular structure and supports multiple library-loading mechanisms, e.g. via <tt>autoload</tt> or threads, allowing you to use only the gems you need.
3
3
 
4
4
  == Setup
5
5
  gem install irbtools
@@ -9,84 +9,88 @@ This is a meta gem that installs useful irb gems and configures your irb. It has
9
9
  * On MacOS, you will need growl, if you want to use the +g+ gem.
10
10
 
11
11
  === Wrong display widths?
12
- When using double-width unicode chars, you should need to pass the <tt>:east_asian_width = true</tt> when starting <tt>FancyIrb</tt>. It is deactivated because of performance issues.
12
+ When using double-width unicode chars, you need to paste the following snippet to your <tt>.irbrc</tt>.
13
+
14
+ Irbtools.replace_library_callback :fancy_irb do
15
+ FancyIrb.start :east_asian_width => true
16
+ end
17
+
18
+ This setting is deactivated by default because of performance issues.
13
19
 
14
20
  == Usage
15
- To use it, put the following in your <tt>~/.irbrc</tt> file (this file is loaded every time you start an irb):
21
+ To use it, put the following in your <tt>~/.irbrc</tt> file (this file is loaded every time you start irb):
16
22
 
17
23
  require 'rubygems' unless defined? Gem # rubygems is only needed in 1.8
18
24
  require 'irbtools'
19
25
 
20
- If it does not exist, just create a new one.
26
+ If the file does not exist, just create a new one.
21
27
 
22
- It's possible to modify, which libraries get loaded:
28
+ It's possible to modify, which libraries should be loaded:
23
29
 
24
- # don't require 'irbtools'
30
+ # don't require 'irbtools', but:
25
31
  require 'irbtools/configure'
26
- # here you can modify which libraries get loaded (see below)
32
+ # here you can modify the libraries using the methods below
27
33
  Irbtools.start
28
34
 
29
- You can also deactivate the loading of the complete default set of irbtools libraries by using <tt>require 'irbtools/minimal'</tt> instead of <tt>configure</tt>. You need to use the below methods for adding libraries in this case, or it won't modify anything of your irb ;).
35
+ If you don't want to load the default set of irbtools gems, you will have to use <tt>require 'irbtools/minimal'</tt> instead of <tt>configure</tt>. You need to use the below methods for adding libraries in this case or *Irbtools* won't modify anything of your irb ;).
30
36
 
31
37
  === Rails notes
32
- To use irbtools within the rails console, you will have to add irbtools to your Gemfile <b>in this way:</b> (or there will be some bundler double require issues..)
38
+ To use irbtools within the rails console, you will have to add <tt>irbtools</tt> to your Gemfile <b>in this way:</b> (or there will be some bundler double require issues..)
33
39
 
34
40
  gem 'irbtools', :require => 'irbtools/configure'
35
41
 
36
- You can put Rails specific configuration in a <tt>~/.railsrc</tt> file which gets loaded only in Rails environments.
37
-
38
- === How to load more or less libraries
39
- You have the following ways:
40
- * <tt>Irbtools.add_library(lib, options_hash, &block)</tt>
41
- * <tt>Irbtools.remove_library(lib)</tt>
42
-
43
- The <tt>options_hash</tt> defines the way in which Irbtools loads the library. Following options are possible
44
- * (no options)/<tt>:start</tt> - The library is required on startup before doing anything else (before displaying the prompt)
45
- * <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)
46
- * <tt>:late => true</tt> - The library is required just before showing the prompt (note: loading threads might still be in process)
47
- * <tt>:late_thread => identifier</tt> - Same as <tt>:thread</tt>, but after loading late libraries.
48
- * <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.
49
- * <tt>:autoload => :Constant</tt> - Use Ruby's <tt>autoload</tt> feature. It loads the library as soon as the constant is encountered.
42
+ You can put Rails specific configuration in a <tt>~/.railsrc</tt> file that gets only loaded in Rails environments.
50
43
 
51
- You can also apply a block that gets executed after the library is loaded (except for autoload, the code will executed on startup in this case).
44
+ See {this blog post}[http://rbjl.net/49-railsrc-rails-console-snippets] for some Rails goodies. Please open an issue/say +1 in the comments there to get that stuff packaged into a gem.
52
45
 
53
- When adding a new library, you should consider adding it via autoload, try loading it via thread if autoload is not suitable and fallback to some other method, if not via thread is not possible.
46
+ === Included gems and libraries
54
47
 
55
- See the <tt>Irbtools.libraries</tt> hash for the current Irbtools configuration that actually will be used when calling <tt>Irbtools.start</tt>.
48
+ See http://rbjl.net/40-irbtools-release-the-power-of-irb or read the commented source files to get some examples of what you can do with irbtools.
49
+
50
+ [paint[https://github.com/janlelis/paint/]] terminal colors
51
+ [wirb[https://github.com/janlelis/wirb/]] colorize ruby objects
52
+ [hirb[http://tagaholic.me/2009/03/13/hirb-irb-on-the-good-stuff.html]]
53
+ (active record) tables and custom views for specific objects
54
+ [fancy_irb[https://github.com/janlelis/fancy_irb]] use hash rockets for output and more colorization
55
+ [every_day_irb[https://github.com/janlelis/irbtools/tree/master/lib/every_day_irb.rb]]
56
+ helper methods that might be useful in every-day irb usage, e.g.: ls, cat, rq, rrq, ld, session_history, reset!, clear, dbg
57
+ [clipboard[http://github.com/janlelis/clipboard]] easy clipboard access (copy & paste)
58
+ [interactive_editor[https://github.com/jberkel/interactive_editor]]
59
+ lets you open vim, hack something, and it gets loaded into the current session, also possible: yaml object editing
60
+ [sketches[http://sketches.rubyforge.org/]] another, more flexible "start editor and it gets loaded into your irb session" plugin
61
+ [zucker[http:/rubyzucker.info]] nice debug printing (q, o, c, .m, .d) + useful pseudo-constants (Info, OS, RubyVersion, RubyEngine)
62
+ [ap[https://github.com/michaeldv/awesome_print]] nice debug printing (ap) [also see wp from wirb/wp]
63
+ [coderay[http://coderay.rubychan.de/]] some colorful code view helpers :)
64
+ [boson[http://tagaholic.me/boson/]] commands framework (commands also work in the shell!)
65
+ [methodfinder[https://github.com/citizen428/methodfinder]] interesting method finder (mf)
66
+ [ori[https://github.com/dadooda/ori]] object-oriented <tt>.ri</tt> method
67
+ [*fileutils* (stdlib)] cd, pwd, ln_s, mv, rm, mkdir, touch ... ;)
56
68
 
57
- ==== Packages
58
- There are irbtools extension packages, which can be modified via:
59
- * <tt>Irbtools.add_package(pkg)</tt>
60
- * <tt>Irbtools.remove_package(pkg)</tt>
69
+ === Not included anymore
61
70
 
62
- These packages add/modify the libraries to be loaded. For an example, see {irbtools-more}[https://github.com/janlelis/irbtools-more].
71
+ [guessmethod[http://guessmethod.rubyforge.org/]] automatically corrects typos (method_missing hook)
63
72
 
64
- == Features
65
- See http://rbjl.net/40-irbtools-release-the-power-of-irb or read the commented source files.
73
+ ==== RVM
74
+ If you have RVM installed, you can switch your gemset or ruby with <tt>gemset</tt> and <tt>use</tt> (use <tt>gemsets</tt> and <tt>rubies</tt> to get a list). The gemset can be changed within the session, while changing ruby starts a new one. Please also note that you need to have installed irbtools for that ruby version. I recommend installing it in the <tt>global</tt> gemset.
66
75
 
67
- === Included gems and libraries
68
- * paint[https://github.com/janlelis/paint/] terminal colors
69
- * wirb[https://github.com/janlelis/wirb/] colorize ruby objects
70
- * hirb[http://tagaholic.me/2009/03/13/hirb-irb-on-the-good-stuff.html] (active record) tables and custom views for specific objects
71
- * fancy_irb[https://github.com/janlelis/fancy_irb] put result as comment and more colorization
72
- * every_day_irb[https://github.com/janlelis/irbtools/tree/master/lib/every_day_irb.rb] helper methods that might be useful in every-day irb usage, e.g.: ls, cat, rq, rrq, ld, session_history, reset!, clear, dbg
73
- * clipboard[http://github.com/janlelis/clipboard] easy clipboard access (copy & paste)
74
- * interactive_editor[https://github.com/jberkel/interactive_editor] lets you open vim, hack something, and it gets loaded into the current session, also possible: yaml object editing
75
- * sketches[http://sketches.rubyforge.org/] another, more flexible "start editor and it gets loaded into your irb session" plugin
76
- * zucker[http:/rubyzucker.info] nice debug printing (q, o, c, .m, .d) + useful pseudo-constants (Info, OS, RubyVersion, RubyEngine)
77
- * ap[https://github.com/michaeldv/awesome_print] nice debug printing (ap) [also see wp from wirb/wp]
78
- * coderay[http://coderay.rubychan.de/] some colorful code displaying ;)
79
- * boson[http://tagaholic.me/boson/] commands repository (commands also work in the shell!)
80
- * methodfinder[https://github.com/citizen428/methodfinder] interesting method finder (mf)
81
- * ori[https://github.com/dadooda/ori] object-oriented ri method
82
- * *fileutils* (stdlib) cd, pwd, ln_s, mv, rm, mkdir, touch ... ;)
76
+ === How to load more or less libraries
77
+ You have the following methods:
78
+ * <tt>Irbtools.add_library(lib, options_hash, &block)</tt>
79
+ * <tt>Irbtools.remove_library(lib)</tt>
83
80
 
84
- === Not included anymore
81
+ The <tt>options_hash</tt> defines the way in which Irbtools loads the library. Following options are possible
82
+ [(no options)/<tt>:start</tt>] The library is required on startup before doing anything else (before displaying the prompt)
83
+ [<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)
84
+ [<tt>:late => true</tt>] The library is required just before showing the prompt (note: loading threads might still be in process)
85
+ [<tt>:late_thread => identifier</tt>] Same as <tt>:thread</tt>, but after loading late libraries.
86
+ [<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.
87
+ [<tt>:autoload => :Constant</tt>] Use Ruby's <tt>autoload</tt> feature. It loads the library as soon as the constant is encountered.
85
88
 
86
- * guessmethod[http://guessmethod.rubyforge.org/] automatically corrects typos (method_missing hook)
89
+ You can also apply a block that gets executed after the library is loaded (except for autoload, the code will executed on startup in this case). You can also just add callback block by using the <tt>Irbtools.add_library_callback</tt> or the <tt>Irbtools.replace_library_callback</tt> method.
87
90
 
88
- ==== RVM
89
- If you have RVM installed, you can switch your gemset or ruby with <tt>gemset</tt> and <tt>use</tt> (use <tt>gemsets</tt> and <tt>rubies</tt> to get a list). The gemset can be changed within the session, while changing ruby starts a new one. Please also note that you need to have installed irbtools for that ruby version. I recommend installing it in the <tt>global</tt> gemset.
91
+ When adding a new library, you should firstly consider some way to load it via <tt>:autoload</tt>.
92
+ If not possible, try loading via thread.
93
+ If that is not possible either, fallback to the default loading.
90
94
 
91
95
  == Hint: Faster start-up
92
96
 
@@ -102,6 +106,19 @@ You can get an about a second faster start-up time by changing the loading metho
102
106
  == Welcome message
103
107
  The welcome message can be customized with <tt>Irbtools.welcome_message=</tt>
104
108
 
109
+ == Packages
110
+ There are irbtools extension packages, which can be modified via:
111
+ * <tt>Irbtools.add_package(pkg)</tt>
112
+ * <tt>Irbtools.remove_package(pkg)</tt>
113
+
114
+ These packages add/modify the libraries to be loaded. For an example, see {irbtools-more}[https://github.com/janlelis/irbtools-more].
115
+
116
+ == TODO irbtools 1.1.0
117
+ * Fix/Improve RVM stuff
118
+ * Way to use irbtools without
119
+ * Better hirb interaction
120
+ * Show some features in README
121
+
105
122
  == Copyright
106
123
  Copyright (c) 2010-2011 Jan Lelis, http://rbjl.net, released under the MIT license.
107
124
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.5
1
+ 1.0.6
data/irbtools.gemspec CHANGED
@@ -14,15 +14,15 @@ Gem::Specification.new do |s|
14
14
  s.homepage = 'https://github.com/janlelis/irbtools'
15
15
  s.required_ruby_version = '>= 1.8.7'
16
16
 
17
- s.add_dependency %q<paint>, ">= 0.8.1"
17
+ s.add_dependency %q<paint>, ">= 0.8.3"
18
18
  s.add_dependency %q<fancy_irb>, ">= 0.7.0"
19
19
  s.add_dependency %q<zucker>, ">= 11"
20
- s.add_dependency %q<hirb>, "~> 0.4.5"
20
+ s.add_dependency %q<hirb>, "~> 0.5.0"
21
21
  s.add_dependency %q<awesome_print>, "~> 0.4.0"
22
22
  s.add_dependency %q<clipboard>, ">= 0.9.9"
23
23
  s.add_dependency %q<coderay>, "~> 0.9"
24
- s.add_dependency %q<boson>, ">= 0.3.3"
25
- s.add_dependency %q<wirb>, ">= 0.4.0"
24
+ s.add_dependency %q<boson>, ">= 0.3.4"
25
+ s.add_dependency %q<wirb>, ">= 0.4.1"
26
26
  s.add_dependency %q<interactive_editor>, ">= 0.0.8"
27
27
  s.add_dependency %q<ori>, "~> 0.1.0"
28
28
  s.add_dependency %q<sketches>, ">= 0"
@@ -71,11 +71,29 @@ module Irbtools
71
71
  @libraries[:start] << lib
72
72
  end
73
73
 
74
- @lib_hooks[lib] << block if block_given?
74
+ add_library_callback(lib, &block) if block_given?
75
75
  end
76
76
  alias add_lib add_library
77
77
  alias add_gem add_library
78
78
 
79
+ # add a callback that gets (usually) executed after loading the library
80
+ def add_library_callback(lib, &block)
81
+ lib = lib.to_s
82
+ @lib_hooks[lib] << block
83
+ end
84
+ alias add_lib_callback add_library_callback
85
+ alias add_gem_callback add_library_callback
86
+
87
+ # replace all callbacks with the new one given in the block
88
+ # a callback that gets (usually) executed after loading the library
89
+ def replace_library_callback(lib, &block)
90
+ lib = lib.to_s
91
+ @lib_hooks[lib].clear
92
+ @lib_hooks[lib] << block
93
+ end
94
+ alias replace_lib_callback replace_library_callback
95
+ alias replace_gem_callback replace_library_callback
96
+
79
97
  # don't load a specific library
80
98
  def remove_library(lib)
81
99
  lib = lib.to_s
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: irbtools
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.5
5
+ version: 1.0.6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jan Lelis
@@ -10,7 +10,8 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-07-07 00:00:00 Z
13
+ date: 2011-08-20 00:00:00 +02:00
14
+ default_executable:
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
16
17
  name: paint
@@ -20,7 +21,7 @@ dependencies:
20
21
  requirements:
21
22
  - - ">="
22
23
  - !ruby/object:Gem::Version
23
- version: 0.8.1
24
+ version: 0.8.3
24
25
  type: :runtime
25
26
  version_requirements: *id001
26
27
  - !ruby/object:Gem::Dependency
@@ -53,7 +54,7 @@ dependencies:
53
54
  requirements:
54
55
  - - ~>
55
56
  - !ruby/object:Gem::Version
56
- version: 0.4.5
57
+ version: 0.5.0
57
58
  type: :runtime
58
59
  version_requirements: *id004
59
60
  - !ruby/object:Gem::Dependency
@@ -97,7 +98,7 @@ dependencies:
97
98
  requirements:
98
99
  - - ">="
99
100
  - !ruby/object:Gem::Version
100
- version: 0.3.3
101
+ version: 0.3.4
101
102
  type: :runtime
102
103
  version_requirements: *id008
103
104
  - !ruby/object:Gem::Dependency
@@ -108,7 +109,7 @@ dependencies:
108
109
  requirements:
109
110
  - - ">="
110
111
  - !ruby/object:Gem::Version
111
- version: 0.4.0
112
+ version: 0.4.1
112
113
  type: :runtime
113
114
  version_requirements: *id009
114
115
  - !ruby/object:Gem::Dependency
@@ -185,7 +186,7 @@ dependencies:
185
186
  requirements:
186
187
  - - ">="
187
188
  - !ruby/object:Gem::Version
188
- version: 1.0.5
189
+ version: 1.0.6
189
190
  type: :runtime
190
191
  version_requirements: *id016
191
192
  description: irbtools is a meta gem that installs useful irb gems and configures your irb. Simply put a require "irbtools" in the .irbrc file in your home directory.
@@ -208,6 +209,7 @@ files:
208
209
  - irbtools.gemspec
209
210
  - LICENSE
210
211
  - README.rdoc
212
+ has_rdoc: true
211
213
  homepage: https://github.com/janlelis/irbtools
212
214
  licenses: []
213
215
 
@@ -231,7 +233,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
231
233
  requirements: []
232
234
 
233
235
  rubyforge_project:
234
- rubygems_version: 1.8.1
236
+ rubygems_version: 1.6.2
235
237
  signing_key:
236
238
  specification_version: 3
237
239
  summary: irbtools is a meta gem that installs useful irb gems and configures your irb.