From d434884e59f2b74a0746a43393675e333a718ff2 Mon Sep 17 00:00:00 2001 From: Jan Lelis Date: Tue, 17 May 2011 21:13:58 +0200 Subject: [PATCH] add irbtools/minimal mode for starting Irbtools without the default set of libraries --- CHANGELOG | 1 + README.rdoc | 2 ++ irbtools.gemspec | 2 +- lib/irbtools/configure.rb | 6 +++++- lib/irbtools/minimal.rb | 9 +++++++++ 5 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 lib/irbtools/minimal.rb diff --git a/CHANGELOG b/CHANGELOG index ea97330..c6913da 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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 diff --git a/README.rdoc b/README.rdoc index 40548bd..ab041b9 100644 --- a/README.rdoc +++ b/README.rdoc @@ -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 require 'irbtools/minimal' instead of configure. 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 in this way: (or there will be some bundler double require issues..) diff --git a/irbtools.gemspec b/irbtools.gemspec index fdacf74..d2fc1a1 100644 --- a/irbtools.gemspec +++ b/irbtools.gemspec @@ -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' diff --git a/lib/irbtools/configure.rb b/lib/irbtools/configure.rb index 23659d5..1ac70cf 100644 --- a/lib/irbtools/configure.rb +++ b/lib/irbtools/configure.rb @@ -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 @@ -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 @@ -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 diff --git a/lib/irbtools/minimal.rb b/lib/irbtools/minimal.rb new file mode 100644 index 0000000..2807f66 --- /dev/null +++ b/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