~ubuntu-branches/ubuntu/hardy/ruby1.8/hardy-updates

« back to all changes in this revision

Viewing changes to lib/irb/ext/use-loader.rb

  • Committer: Bazaar Package Importer
  • Author(s): akira yamada
  • Date: 2007-03-13 22:11:58 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20070313221158-h3oql37brlaf2go2
Tags: 1.8.6-1
* new upstream version, 1.8.6.
* libruby1.8 conflicts with libopenssl-ruby1.8 (< 1.8.6) (closes: #410018)
* changed packaging style to cdbs from dbs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
#   use-loader.rb - 
 
3
#       $Release Version: 0.9.5$
 
4
#       $Revision: 11708 $
 
5
#       $Date: 2007-02-13 08:01:19 +0900 (Tue, 13 Feb 2007) $
 
6
#       by Keiju ISHITSUKA(keiju@ruby-lang.org)
 
7
#
 
8
# --
 
9
#
 
10
#   
 
11
#
 
12
 
 
13
require "irb/cmd/load"
 
14
require "irb/ext/loader"
 
15
 
 
16
class Object
 
17
  alias __original__load__IRB_use_loader__ load
 
18
  alias __original__require__IRB_use_loader__ require
 
19
end
 
20
 
 
21
module IRB
 
22
  module ExtendCommandBundle
 
23
    def irb_load(*opts, &b)
 
24
      ExtendCommand::Load.execute(irb_context, *opts, &b)
 
25
    end
 
26
    def irb_require(*opts, &b)
 
27
      ExtendCommand::Require.execute(irb_context, *opts, &b)
 
28
    end
 
29
  end
 
30
 
 
31
  class Context
 
32
 
 
33
    IRB.conf[:USE_LOADER] = false
 
34
    
 
35
    def use_loader
 
36
      IRB.conf[:USE_LOADER]
 
37
    end
 
38
 
 
39
    alias use_loader? use_loader
 
40
 
 
41
    def use_loader=(opt)
 
42
 
 
43
      if IRB.conf[:USE_LOADER] != opt
 
44
        IRB.conf[:USE_LOADER] = opt
 
45
        if opt
 
46
          if !$".include?("irb/cmd/load")
 
47
          end
 
48
          (class<<@workspace.main;self;end).instance_eval {
 
49
            alias_method :load, :irb_load
 
50
            alias_method :require, :irb_require
 
51
          }
 
52
        else
 
53
          (class<<@workspace.main;self;end).instance_eval {
 
54
            alias_method :load, :__original__load__IRB_use_loader__
 
55
            alias_method :require, :__original__require__IRB_use_loader__
 
56
          }
 
57
        end
 
58
      end
 
59
      print "Switch to load/require#{unless use_loader; ' non';end} trace mode.\n" if verbose?
 
60
      opt
 
61
    end
 
62
  end
 
63
end
 
64
 
 
65