Skip to content

Commit

Permalink
add irbtools/minimal mode for starting Irbtools without the default s…
Browse files Browse the repository at this point in the history
…et of libraries
  • Loading branch information
janlelis committed May 17, 2011
1 parent 6117dc4 commit d434884
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Expand Up @@ -3,6 +3,7 @@
* 4 different loading schemas: require, after_rc, thread, autoload
* load almost every feature in threads
* don't use zucker/alias_for, autload zucker/env (except zucker/os) for performance reasons
* add irbtools/minimal mode for starting Irbtools without the default set of libraries

0.8.8
* fix 0.8.7 file permissions
Expand Down
2 changes: 2 additions & 0 deletions README.rdoc
Expand Up @@ -26,6 +26,8 @@ It's possible to modify, which libraries get loaded:
# here you can modify which libraries get loaded (see below)
Irbtools.start

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 ;).

=== Rails notes
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..)

Expand Down
2 changes: 1 addition & 1 deletion irbtools.gemspec
Expand Up @@ -10,7 +10,7 @@ Gem::Specification.new do |s|
s.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.'
s.email = 'mail@janlelis.de'
s.extra_rdoc_files = %w[LICENSE README.rdoc]
s.files = %w[lib/irbtools.rb lib/irbtools/configure.rb lib/irbtools/libraries.rb VERSION CHANGELOG Rakefile irbtools.gemspec]
s.files = %w[lib/irbtools.rb lib/irbtools/configure.rb lib/irbtools/libraries.rb lib/irbtools/minimal.rb VERSION CHANGELOG Rakefile irbtools.gemspec]
s.homepage = 'http://github.com/janlelis/irbtools'
s.required_ruby_version = '>= 1.8.7'

Expand Down
6 changes: 5 additions & 1 deletion lib/irbtools/configure.rb
Expand Up @@ -16,6 +16,7 @@ module Irbtools
@railsrc = '~/.railsrc'
@shell_name = File.split($0)[-1].upcase
@welcome_message = "Welcome to #{ @shell_name }. You are using #{ RUBY_DESCRIPTION }. Have fun ;)"
@minimal ||= false

class << self
# message to display when starting. Set to nil to disable
Expand All @@ -27,6 +28,9 @@ class << self
# lets you define the path to the railsrc file or deactivate this feature with nil
attr_accessor :railsrc

# set this to true before loading this file to deactivate loading of default libraries
attr_accessor :minimal

# a hash of arrays of libraries that get loaded
# keys determine if lib is required, required on sub-session or autoloaded
attr_accessor :libraries
Expand Down Expand Up @@ -104,7 +108,7 @@ def init

# # # # #
# libraries
require File.expand_path( 'libraries.rb', File.dirname(__FILE__) )
require File.expand_path( 'libraries.rb', File.dirname(__FILE__) ) unless Irbtools.minimal

# J-_-L

9 changes: 9 additions & 0 deletions lib/irbtools/minimal.rb
@@ -0,0 +1,9 @@
# require this file (instead of configure) to deactivate loading of default set of libraries

module Irbtools
@minimal = true
end

require File.expand_path( 'configure.rb', File.dirname(__FILE__) )

# J-_-L

0 comments on commit d434884

Please sign in to comment.