mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	* {ext,lib,test}/**/*.rb: removed trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@27366 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									c89882197e
								
							
						
					
					
						commit
						75c1cac7f3
					
				
					 442 changed files with 4654 additions and 4654 deletions
				
			
		| 
						 | 
				
			
			@ -11,10 +11,10 @@ It uses Win32API to call Win32 Registry APIs.
 | 
			
		|||
    reg['foo'] = 'bar'                               # write a value
 | 
			
		||||
    reg['foo', Win32::Registry::REG_SZ] = 'bar'      # write a value with type
 | 
			
		||||
    reg.write('foo', Win32::Registry::REG_SZ, 'bar') # write a value
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    reg.each_value { |name, type, data| ... }        # Enumerate values
 | 
			
		||||
    reg.each_key { |key, wtime| ... }                # Enumerate subkeys
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    reg.delete_value(name)                         # Delete a value
 | 
			
		||||
    reg.delete_key(name)                           # Delete a subkey
 | 
			
		||||
    reg.delete_key(name, true)                     # Delete a subkey recursively
 | 
			
		||||
| 
						 | 
				
			
			@ -35,26 +35,26 @@ It uses Win32API to call Win32 Registry APIs.
 | 
			
		|||
    Open the registry key ((|subkey|)) under ((|key|)).
 | 
			
		||||
    ((|key|)) is Win32::Registry object of parent key.
 | 
			
		||||
    You can use predefined key HKEY_* (see ((<constants>)))
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    ((|desired|)) and ((|opt|)) is access mask and key option.
 | 
			
		||||
    For detail, see ((<MSDN Library|URL:http://msdn.microsoft.com/library/en-us/sysinfo/base/regopenkeyex.asp>)).
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    If block is given, the key is closed automatically.
 | 
			
		||||
 | 
			
		||||
--- Registry.create(key, subkey, desired = KEY_ALL_ACCESS, opt = REG_OPTION_RESERVED)
 | 
			
		||||
--- Registry.create(key, subkey, desired = KEY_ALL_ACCESS, opt = REG_OPTION_RESERVED) { |reg| ... }
 | 
			
		||||
    Create or open the registry key ((|subkey|)) under ((|key|)).
 | 
			
		||||
    You can use predefined key HKEY_* (see ((<constants>)))
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    If subkey is already exists, key is opened and Registry#((<created?>))
 | 
			
		||||
    method will return false.
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    If block is given, the key is closed automatically.
 | 
			
		||||
 | 
			
		||||
--- Registry.expand_environ(str)
 | 
			
		||||
    Replace (({%\w+%})) into the environment value of ((|str|)).
 | 
			
		||||
    This method is used for REG_EXPAND_SZ.
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    For detail, see ((<ExpandEnvironmentStrings|URL:http://msdn.microsoft.com/library/en-us/sysinfo/base/expandenvironmentstrings.asp>)) Win32 API.
 | 
			
		||||
 | 
			
		||||
--- Registry.type2name(type)
 | 
			
		||||
| 
						 | 
				
			
			@ -75,14 +75,14 @@ It uses Win32API to call Win32 Registry APIs.
 | 
			
		|||
 | 
			
		||||
--- close
 | 
			
		||||
    Close key.
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    After closed, most method raises error.
 | 
			
		||||
 | 
			
		||||
--- read(name, *rtype)
 | 
			
		||||
    Read a registry value named ((|name|)) and return array of
 | 
			
		||||
    [ ((|type|)), ((|data|)) ].
 | 
			
		||||
    When name is nil, the `default' value is read.
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    ((|type|)) is value type. (see ((<Win32::Registry::Constants module>)))
 | 
			
		||||
    ((|data|)) is value data, its class is:
 | 
			
		||||
    :REG_SZ, REG_EXPAND_SZ
 | 
			
		||||
| 
						 | 
				
			
			@ -93,19 +93,19 @@ It uses Win32API to call Win32 Registry APIs.
 | 
			
		|||
       Integer
 | 
			
		||||
    :REG_BINARY
 | 
			
		||||
       String (contains binary data)
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    When ((|rtype|)) is specified, the value type must be included by
 | 
			
		||||
    ((|rtype|)) array, or TypeError is raised.
 | 
			
		||||
 | 
			
		||||
--- self[name, *rtype]
 | 
			
		||||
    Read a registry value named ((|name|)) and return its value data.
 | 
			
		||||
    The class of value is same as ((<read>)) method returns.
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    If the value type is REG_EXPAND_SZ, returns value data whose environment
 | 
			
		||||
    variables are replaced.
 | 
			
		||||
    If the value type is neither REG_SZ, REG_MULTI_SZ, REG_DWORD,
 | 
			
		||||
    REG_DWORD_BIG_ENDIAN, nor REG_QWORD, TypeError is raised.
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    The meaning of ((|rtype|)) is same as ((<read>)) method.
 | 
			
		||||
 | 
			
		||||
--- read_s(name)
 | 
			
		||||
| 
						 | 
				
			
			@ -113,26 +113,26 @@ It uses Win32API to call Win32 Registry APIs.
 | 
			
		|||
--- read_bin(name)
 | 
			
		||||
    Read a REG_SZ(read_s), REG_DWORD(read_i), or REG_BINARY(read_bin)
 | 
			
		||||
    registry value named ((|name|)).
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    If the values type does not match, TypeError is raised.
 | 
			
		||||
 | 
			
		||||
--- read_s_expand(name)
 | 
			
		||||
    Read a REG_SZ or REG_EXPAND_SZ registry value named ((|name|)).
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    If the value type is REG_EXPAND_SZ, environment variables are replaced.
 | 
			
		||||
    Unless the value type is REG_SZ or REG_EXPAND_SZ, TypeError is raised.
 | 
			
		||||
 | 
			
		||||
--- write(name, type, data)
 | 
			
		||||
    Write ((|data|)) to a registry value named ((|name|)).
 | 
			
		||||
    When name is nil, write to the `default' value.
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    ((|type|)) is type value. (see ((<Registry::Constants module>)))
 | 
			
		||||
    Class of ((|data|)) must be same as which ((<read>))
 | 
			
		||||
    method returns.
 | 
			
		||||
 | 
			
		||||
--- self[name, wtype = nil] = value
 | 
			
		||||
    Write ((|value|)) to a registry value named ((|name|)).
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    If ((|wtype|)) is specified, the value type is it.
 | 
			
		||||
    Otherwise, the value type is depend on class of ((|value|)):
 | 
			
		||||
    :Integer
 | 
			
		||||
| 
						 | 
				
			
			@ -146,7 +146,7 @@ It uses Win32API to call Win32 Registry APIs.
 | 
			
		|||
--- write_i(name, value)
 | 
			
		||||
--- write_bin(name, value)
 | 
			
		||||
    Write ((|value|)) to a registry value named ((|name|)).
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    The value type is REG_SZ(write_s), REG_DWORD(write_i), or
 | 
			
		||||
    REG_BINARY(write_bin).
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -156,7 +156,7 @@ It uses Win32API to call Win32 Registry APIs.
 | 
			
		|||
 | 
			
		||||
--- each_key { |subkey, wtime| ... }
 | 
			
		||||
    Enumerate subkeys.
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    ((|subkey|)) is String which contains name of subkey.
 | 
			
		||||
    ((|wtime|)) is last write time as FILETIME (64-bit integer).
 | 
			
		||||
    (see ((<Registry.wtime2time>)))
 | 
			
		||||
| 
						 | 
				
			
			@ -168,7 +168,7 @@ It uses Win32API to call Win32 Registry APIs.
 | 
			
		|||
 | 
			
		||||
--- delete_key(name, recursive = false)
 | 
			
		||||
    Delete a subkey named ((|name|)) and all its values.
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    If ((|recursive|)) is false, the subkey must not have subkeys.
 | 
			
		||||
    Otherwise, this method deletes all subkeys and values recursively.
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -215,7 +215,7 @@ It uses Win32API to call Win32 Registry APIs.
 | 
			
		|||
      Length of security descriptor.
 | 
			
		||||
    :wtime
 | 
			
		||||
      Last write time as FILETIME(64-bit integer)
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    For detail, see ((<RegQueryInfoKey|URL:http://msdn.microsoft.com/library/en-us/sysinfo/base/regqueryinfokey.asp>)) Win32 API.
 | 
			
		||||
 | 
			
		||||
--- num_keys
 | 
			
		||||
| 
						 | 
				
			
			@ -275,7 +275,7 @@ module Win32
 | 
			
		|||
      HKEY_PERFORMANCE_NLSTEXT = 0x80000060
 | 
			
		||||
      HKEY_CURRENT_CONFIG = 0x80000005
 | 
			
		||||
      HKEY_DYN_DATA = 0x80000006
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      REG_NONE = 0
 | 
			
		||||
      REG_SZ = 1
 | 
			
		||||
      REG_EXPAND_SZ = 2
 | 
			
		||||
| 
						 | 
				
			
			@ -290,7 +290,7 @@ module Win32
 | 
			
		|||
      REG_RESOURCE_REQUIREMENTS_LIST = 10
 | 
			
		||||
      REG_QWORD = 11
 | 
			
		||||
      REG_QWORD_LITTLE_ENDIAN = 11
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      STANDARD_RIGHTS_READ = 0x00020000
 | 
			
		||||
      STANDARD_RIGHTS_WRITE = 0x00020000
 | 
			
		||||
      KEY_QUERY_VALUE = 0x0001
 | 
			
		||||
| 
						 | 
				
			
			@ -305,7 +305,7 @@ module Win32
 | 
			
		|||
        KEY_SET_VALUE | KEY_CREATE_SUB_KEY
 | 
			
		||||
      KEY_EXECUTE = KEY_READ
 | 
			
		||||
      KEY_ALL_ACCESS = KEY_READ | KEY_WRITE | KEY_CREATE_LINK
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      REG_OPTION_RESERVED = 0x0000
 | 
			
		||||
      REG_OPTION_NON_VOLATILE = 0x0000
 | 
			
		||||
      REG_OPTION_VOLATILE = 0x0001
 | 
			
		||||
| 
						 | 
				
			
			@ -315,21 +315,21 @@ module Win32
 | 
			
		|||
      REG_LEGAL_OPTION = REG_OPTION_RESERVED |
 | 
			
		||||
        REG_OPTION_NON_VOLATILE | REG_OPTION_CREATE_LINK |
 | 
			
		||||
        REG_OPTION_BACKUP_RESTORE | REG_OPTION_OPEN_LINK
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      REG_CREATED_NEW_KEY = 1
 | 
			
		||||
      REG_OPENED_EXISTING_KEY = 2
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      REG_WHOLE_HIVE_VOLATILE = 0x0001
 | 
			
		||||
      REG_REFRESH_HIVE = 0x0002
 | 
			
		||||
      REG_NO_LAZY_FLUSH = 0x0004
 | 
			
		||||
      REG_FORCE_RESTORE = 0x0008
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      MAX_KEY_LENGTH = 514
 | 
			
		||||
      MAX_VALUE_LENGTH = 32768
 | 
			
		||||
    end
 | 
			
		||||
    include Constants
 | 
			
		||||
    include Enumerable
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    #
 | 
			
		||||
    # Error
 | 
			
		||||
    #
 | 
			
		||||
| 
						 | 
				
			
			@ -343,7 +343,7 @@ module Win32
 | 
			
		|||
      end
 | 
			
		||||
      attr_reader :code
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    #
 | 
			
		||||
    # Predefined Keys
 | 
			
		||||
    #
 | 
			
		||||
| 
						 | 
				
			
			@ -354,23 +354,23 @@ module Win32
 | 
			
		|||
        @keyname = keyname
 | 
			
		||||
        @disposition = REG_OPENED_EXISTING_KEY
 | 
			
		||||
      end
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      # Predefined keys cannot be closed
 | 
			
		||||
      def close
 | 
			
		||||
        raise Error.new(5) ## ERROR_ACCESS_DENIED
 | 
			
		||||
      end
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      # Fake class for Registry#open, Registry#create
 | 
			
		||||
      def class
 | 
			
		||||
        Registry
 | 
			
		||||
      end
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      # Make all
 | 
			
		||||
      Constants.constants.grep(/^HKEY_/) do |c|
 | 
			
		||||
        Registry.const_set c, new(Constants.const_get(c), c)
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    #
 | 
			
		||||
    # Win32 APIs
 | 
			
		||||
    #
 | 
			
		||||
| 
						 | 
				
			
			@ -390,37 +390,37 @@ module Win32
 | 
			
		|||
      ].each do |fn|
 | 
			
		||||
        const_set fn[0].intern, Win32API.new('advapi32.dll', *fn)
 | 
			
		||||
      end
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      module_function
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      def check(result)
 | 
			
		||||
        raise Error, result, caller(2) if result != 0
 | 
			
		||||
      end
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      def packdw(dw)
 | 
			
		||||
        [dw].pack('V')
 | 
			
		||||
      end
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      def unpackdw(dw)
 | 
			
		||||
        dw += [0].pack('V')
 | 
			
		||||
        dw.unpack('V')[0]
 | 
			
		||||
      end
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      def packqw(qw)
 | 
			
		||||
        [ qw & 0xFFFFFFFF, qw >> 32 ].pack('VV')
 | 
			
		||||
      end
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      def unpackqw(qw)
 | 
			
		||||
        qw = qw.unpack('VV')
 | 
			
		||||
        (qw[1] << 32) | qw[0]
 | 
			
		||||
      end
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      def OpenKey(hkey, name, opt, desired)
 | 
			
		||||
        result = packdw(0)
 | 
			
		||||
        check RegOpenKeyExA.call(hkey, name, opt, desired, result)
 | 
			
		||||
        unpackdw(result)
 | 
			
		||||
      end
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      def CreateKey(hkey, name, opt, desired)
 | 
			
		||||
        result = packdw(0)
 | 
			
		||||
        disp = packdw(0)
 | 
			
		||||
| 
						 | 
				
			
			@ -428,14 +428,14 @@ module Win32
 | 
			
		|||
                                   0, result, disp)
 | 
			
		||||
        [ unpackdw(result), unpackdw(disp) ]
 | 
			
		||||
      end
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      def EnumValue(hkey, index)
 | 
			
		||||
        name = ' ' * Constants::MAX_KEY_LENGTH
 | 
			
		||||
        size = packdw(Constants::MAX_KEY_LENGTH)
 | 
			
		||||
        check RegEnumValueA.call(hkey, index, name, size, 0, 0, 0, 0)
 | 
			
		||||
        name[0, unpackdw(size)]
 | 
			
		||||
      end
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      def EnumKey(hkey, index)
 | 
			
		||||
        name = ' ' * Constants::MAX_KEY_LENGTH
 | 
			
		||||
        size = packdw(Constants::MAX_KEY_LENGTH)
 | 
			
		||||
| 
						 | 
				
			
			@ -443,7 +443,7 @@ module Win32
 | 
			
		|||
        check RegEnumKeyExA.call(hkey, index, name, size, 0, 0, 0, wtime)
 | 
			
		||||
        [ name[0, unpackdw(size)], unpackqw(wtime) ]
 | 
			
		||||
      end
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      def QueryValue(hkey, name)
 | 
			
		||||
        type = packdw(0)
 | 
			
		||||
        size = packdw(0)
 | 
			
		||||
| 
						 | 
				
			
			@ -452,27 +452,27 @@ module Win32
 | 
			
		|||
        check RegQueryValueExA.call(hkey, name, 0, type, data, size)
 | 
			
		||||
        [ unpackdw(type), data[0, unpackdw(size)] ]
 | 
			
		||||
      end
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      def SetValue(hkey, name, type, data, size)
 | 
			
		||||
        check RegSetValueExA.call(hkey, name, 0, type, data, size)
 | 
			
		||||
      end
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      def DeleteValue(hkey, name)
 | 
			
		||||
        check RegDeleteValue.call(hkey, name)
 | 
			
		||||
      end
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      def DeleteKey(hkey, name)
 | 
			
		||||
        check RegDeleteKey.call(hkey, name)
 | 
			
		||||
      end
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      def FlushKey(hkey)
 | 
			
		||||
        check RegFlushKey.call(hkey)
 | 
			
		||||
      end
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      def CloseKey(hkey)
 | 
			
		||||
        check RegCloseKey.call(hkey)
 | 
			
		||||
      end
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      def QueryInfoKey(hkey)
 | 
			
		||||
        subkeys = packdw(0)
 | 
			
		||||
        maxsubkeylen = packdw(0)
 | 
			
		||||
| 
						 | 
				
			
			@ -488,14 +488,14 @@ module Win32
 | 
			
		|||
          unpackdw(secdescs), unpackqw(wtime) ]
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    #
 | 
			
		||||
    # utility functions
 | 
			
		||||
    #
 | 
			
		||||
    def self.expand_environ(str)
 | 
			
		||||
      str.gsub(/%([^%]+)%/) { ENV[$1] || ENV[$1.upcase] || $& }
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @@type2name = { }
 | 
			
		||||
    %w[
 | 
			
		||||
      REG_NONE REG_SZ REG_EXPAND_SZ REG_BINARY REG_DWORD
 | 
			
		||||
| 
						 | 
				
			
			@ -505,24 +505,24 @@ module Win32
 | 
			
		|||
    ].each do |type|
 | 
			
		||||
      @@type2name[Constants.const_get(type)] = type
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    def self.type2name(type)
 | 
			
		||||
      @@type2name[type] || type.to_s
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    def self.wtime2time(wtime)
 | 
			
		||||
      Time.at((wtime - 116444736000000000) / 10000000)
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    def self.time2wtime(time)
 | 
			
		||||
      time.to_i * 10000000 + 116444736000000000
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    #
 | 
			
		||||
    # constructors
 | 
			
		||||
    #
 | 
			
		||||
    private_class_method :new
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    def self.open(hkey, subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED)
 | 
			
		||||
      subkey = subkey.chomp('\\')
 | 
			
		||||
      newkey = API.OpenKey(hkey.hkey, subkey, opt, desired)
 | 
			
		||||
| 
						 | 
				
			
			@ -537,7 +537,7 @@ module Win32
 | 
			
		|||
        obj
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    def self.create(hkey, subkey, desired = KEY_ALL_ACCESS, opt = REG_OPTION_RESERVED)
 | 
			
		||||
      newkey, disp = API.CreateKey(hkey.hkey, subkey, opt, desired)
 | 
			
		||||
      obj = new(newkey, hkey, subkey, disp)
 | 
			
		||||
| 
						 | 
				
			
			@ -551,12 +551,12 @@ module Win32
 | 
			
		|||
        obj
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    #
 | 
			
		||||
    # finalizer
 | 
			
		||||
    #
 | 
			
		||||
    @@final = proc { |hkey| proc { API.CloseKey(hkey[0]) if hkey[0] } }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    #
 | 
			
		||||
    # initialize
 | 
			
		||||
    #
 | 
			
		||||
| 
						 | 
				
			
			@ -569,18 +569,18 @@ module Win32
 | 
			
		|||
      ObjectSpace.define_finalizer self, @@final.call(@hkeyfinal)
 | 
			
		||||
    end
 | 
			
		||||
    attr_reader :hkey, :parent, :keyname, :disposition
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    #
 | 
			
		||||
    # attributes
 | 
			
		||||
    #
 | 
			
		||||
    def created?
 | 
			
		||||
      @disposition == REG_CREATED_NEW_KEY
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    def open?
 | 
			
		||||
      !@hkey.nil?
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    def name
 | 
			
		||||
      parent = self
 | 
			
		||||
      name = @keyname
 | 
			
		||||
| 
						 | 
				
			
			@ -589,35 +589,35 @@ module Win32
 | 
			
		|||
      end
 | 
			
		||||
      name
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    def inspect
 | 
			
		||||
      "\#<Win32::Registry key=#{name.inspect}>"
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    #
 | 
			
		||||
    # marshalling
 | 
			
		||||
    #
 | 
			
		||||
    def _dump(depth)
 | 
			
		||||
      raise TypeError, "can't dump Win32::Registry"
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    #
 | 
			
		||||
    # open/close
 | 
			
		||||
    #
 | 
			
		||||
    def open(subkey, desired = KEY_READ, opt = REG_OPTION_RESERVED, &blk)
 | 
			
		||||
      self.class.open(self, subkey, desired, opt, &blk)
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    def create(subkey, desired = KEY_ALL_ACCESS, opt = REG_OPTION_RESERVED, &blk)
 | 
			
		||||
      self.class.create(self, subkey, desired, opt, &blk)
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    def close
 | 
			
		||||
      API.CloseKey(@hkey)
 | 
			
		||||
      @hkey = @parent = @keyname = nil
 | 
			
		||||
      @hkeyfinal[0] = nil
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    #
 | 
			
		||||
    # iterator
 | 
			
		||||
    #
 | 
			
		||||
| 
						 | 
				
			
			@ -640,7 +640,7 @@ module Win32
 | 
			
		|||
      index
 | 
			
		||||
    end
 | 
			
		||||
    alias each each_value
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    def each_key
 | 
			
		||||
      index = 0
 | 
			
		||||
      while true
 | 
			
		||||
| 
						 | 
				
			
			@ -654,13 +654,13 @@ module Win32
 | 
			
		|||
      end
 | 
			
		||||
      index
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    def keys
 | 
			
		||||
      keys_ary = []
 | 
			
		||||
      each_key { |key,| keys_ary << key }
 | 
			
		||||
      keys_ary
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    #
 | 
			
		||||
    # reader
 | 
			
		||||
    #
 | 
			
		||||
| 
						 | 
				
			
			@ -686,7 +686,7 @@ module Win32
 | 
			
		|||
        raise TypeError, "Type #{type} is not supported."
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    def [](name, *rtype)
 | 
			
		||||
      type, data = read(name, *rtype)
 | 
			
		||||
      case type
 | 
			
		||||
| 
						 | 
				
			
			@ -698,11 +698,11 @@ module Win32
 | 
			
		|||
        raise TypeError, "Type #{type} is not supported."
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    def read_s(name)
 | 
			
		||||
      read(name, REG_SZ)[1]
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    def read_s_expand(name)
 | 
			
		||||
      type, data = read(name, REG_SZ, REG_EXPAND_SZ)
 | 
			
		||||
      if type == REG_EXPAND_SZ
 | 
			
		||||
| 
						 | 
				
			
			@ -711,15 +711,15 @@ module Win32
 | 
			
		|||
        data
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    def read_i(name)
 | 
			
		||||
      read(name, REG_DWORD, REG_DWORD_BIG_ENDIAN, REG_QWORD)[1]
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    def read_bin(name)
 | 
			
		||||
      read(name, REG_BINARY)[1]
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    #
 | 
			
		||||
    # writer
 | 
			
		||||
    #
 | 
			
		||||
| 
						 | 
				
			
			@ -742,7 +742,7 @@ module Win32
 | 
			
		|||
      end
 | 
			
		||||
      API.SetValue(@hkey, name, type, data, data.length)
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    def []=(name, rtype, value = nil)
 | 
			
		||||
      if value
 | 
			
		||||
        write name, rtype, value
 | 
			
		||||
| 
						 | 
				
			
			@ -760,19 +760,19 @@ module Win32
 | 
			
		|||
      end
 | 
			
		||||
      value
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    def write_s(name, value)
 | 
			
		||||
      write name, REG_SZ, value.to_s
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    def write_i(name, value)
 | 
			
		||||
      write name, REG_DWORD, value.to_i
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    def write_bin(name, value)
 | 
			
		||||
      write name, REG_BINARY, value.to_s
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    #
 | 
			
		||||
    # delete
 | 
			
		||||
    #
 | 
			
		||||
| 
						 | 
				
			
			@ -780,7 +780,7 @@ module Win32
 | 
			
		|||
      API.DeleteValue(@hkey, name)
 | 
			
		||||
    end
 | 
			
		||||
    alias delete delete_value
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    def delete_key(name, recursive = false)
 | 
			
		||||
      if recursive
 | 
			
		||||
        open(name, KEY_ALL_ACCESS) do |reg|
 | 
			
		||||
| 
						 | 
				
			
			@ -802,14 +802,14 @@ module Win32
 | 
			
		|||
        raise Error.new(5) ## ERROR_ACCESS_DENIED
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    #
 | 
			
		||||
    # flush
 | 
			
		||||
    #
 | 
			
		||||
    def flush
 | 
			
		||||
      API.FlushKey @hkey
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    #
 | 
			
		||||
    # key information
 | 
			
		||||
    #
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,13 +8,13 @@ require 'win32/registry'
 | 
			
		|||
module Win32
 | 
			
		||||
  module Resolv
 | 
			
		||||
    API = Registry::API
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    def self.get_hosts_path
 | 
			
		||||
      path = get_hosts_dir
 | 
			
		||||
      path = File.expand_path('hosts', path)
 | 
			
		||||
      File.exist?(path) ? path : nil
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    def self.get_resolv_info
 | 
			
		||||
      search, nameserver = get_info
 | 
			
		||||
      if search.empty?
 | 
			
		||||
| 
						 | 
				
			
			@ -42,7 +42,7 @@ if info.unpack('V5')[4] == 2  # VER_PLATFORM_WIN32_NT
 | 
			
		|||
#====================================================================
 | 
			
		||||
  module_eval <<-'__EOS__', __FILE__, __LINE__+1
 | 
			
		||||
    TCPIP_NT = 'SYSTEM\CurrentControlSet\Services\Tcpip\Parameters'
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    class << self
 | 
			
		||||
      private
 | 
			
		||||
      def get_hosts_dir
 | 
			
		||||
| 
						 | 
				
			
			@ -50,7 +50,7 @@ if info.unpack('V5')[4] == 2  # VER_PLATFORM_WIN32_NT
 | 
			
		|||
          reg.read_s_expand('DataBasePath')
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      def get_info
 | 
			
		||||
        search = nil
 | 
			
		||||
        nameserver = []
 | 
			
		||||
| 
						 | 
				
			
			@ -60,7 +60,7 @@ if info.unpack('V5')[4] == 2  # VER_PLATFORM_WIN32_NT
 | 
			
		|||
            search = slist.split(/,\s*/) unless slist.empty?
 | 
			
		||||
          rescue Registry::Error
 | 
			
		||||
          end
 | 
			
		||||
          
 | 
			
		||||
 | 
			
		||||
          if add_search = search.nil?
 | 
			
		||||
            search = []
 | 
			
		||||
            begin
 | 
			
		||||
| 
						 | 
				
			
			@ -76,7 +76,7 @@ if info.unpack('V5')[4] == 2  # VER_PLATFORM_WIN32_NT
 | 
			
		|||
            rescue Registry::Error
 | 
			
		||||
            end
 | 
			
		||||
          end
 | 
			
		||||
          
 | 
			
		||||
 | 
			
		||||
          reg.open('Interfaces') do |reg|
 | 
			
		||||
            reg.each_key do |iface,|
 | 
			
		||||
              reg.open(iface) do |regif|
 | 
			
		||||
| 
						 | 
				
			
			@ -90,7 +90,7 @@ if info.unpack('V5')[4] == 2  # VER_PLATFORM_WIN32_NT
 | 
			
		|||
                  end
 | 
			
		||||
                rescue Registry::Error
 | 
			
		||||
                end
 | 
			
		||||
                
 | 
			
		||||
 | 
			
		||||
                if add_search
 | 
			
		||||
                  begin
 | 
			
		||||
                    [ 'Domain', 'DhcpDomain' ].each do |key|
 | 
			
		||||
| 
						 | 
				
			
			@ -120,16 +120,16 @@ else
 | 
			
		|||
    TCPIP_9X = 'SYSTEM\CurrentControlSet\Services\VxD\MSTCP'
 | 
			
		||||
    DHCP_9X = 'SYSTEM\CurrentControlSet\Services\VxD\DHCP'
 | 
			
		||||
    WINDOWS = 'Software\Microsoft\Windows\CurrentVersion'
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    class << self
 | 
			
		||||
   #   private
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      def get_hosts_dir
 | 
			
		||||
        Registry::HKEY_LOCAL_MACHINE.open(WINDOWS) do |reg|
 | 
			
		||||
          reg.read_s_expand('SystemRoot')
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      def get_info
 | 
			
		||||
        search = []
 | 
			
		||||
        nameserver = []
 | 
			
		||||
| 
						 | 
				
			
			@ -146,13 +146,13 @@ else
 | 
			
		|||
          end
 | 
			
		||||
        rescue Registry::Error
 | 
			
		||||
        end
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        dhcpinfo = get_dhcpinfo
 | 
			
		||||
        search.concat(dhcpinfo[0])
 | 
			
		||||
        nameserver.concat(dhcpinfo[1])
 | 
			
		||||
        [ search, nameserver ]
 | 
			
		||||
      end
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      def get_dhcpinfo
 | 
			
		||||
        macaddrs = {}
 | 
			
		||||
        ipaddrs = {}
 | 
			
		||||
| 
						 | 
				
			
			@ -161,7 +161,7 @@ else
 | 
			
		|||
          ipaddr.each { |ipaddr| ipaddrs[ipaddr] = 1 }
 | 
			
		||||
        end
 | 
			
		||||
        iflist = [ macaddrs, ipaddrs ]
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        search = []
 | 
			
		||||
        nameserver = []
 | 
			
		||||
        version = -1
 | 
			
		||||
| 
						 | 
				
			
			@ -170,7 +170,7 @@ else
 | 
			
		|||
            version = API.unpackdw(reg.read_bin("Version"))
 | 
			
		||||
          rescue Registry::Error
 | 
			
		||||
          end
 | 
			
		||||
          
 | 
			
		||||
 | 
			
		||||
          reg.each_key do |key,|
 | 
			
		||||
            catch(:not_used) do
 | 
			
		||||
              reg.open(key) do |regdi|
 | 
			
		||||
| 
						 | 
				
			
			@ -183,7 +183,7 @@ else
 | 
			
		|||
        end
 | 
			
		||||
        [ search, nameserver ]
 | 
			
		||||
      end
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      def get_dhcpinfo_95(reg)
 | 
			
		||||
        dhcp = reg.read_bin("DhcpInfo")
 | 
			
		||||
        [
 | 
			
		||||
| 
						 | 
				
			
			@ -194,7 +194,7 @@ else
 | 
			
		|||
          reg.read_bin("OptionInfo"),
 | 
			
		||||
        ]
 | 
			
		||||
      end
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      def get_dhcpinfo_98(reg)
 | 
			
		||||
        [
 | 
			
		||||
          API.unpackdw(reg.read_bin("DhcpIPAddress")),
 | 
			
		||||
| 
						 | 
				
			
			@ -204,7 +204,7 @@ else
 | 
			
		|||
          reg.read_bin("OptionInfo"),
 | 
			
		||||
        ]
 | 
			
		||||
      end
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      def get_dhcpinfo_key(version, reg, iflist)
 | 
			
		||||
        info = case version
 | 
			
		||||
               when 1
 | 
			
		||||
| 
						 | 
				
			
			@ -225,7 +225,7 @@ else
 | 
			
		|||
          macaddr and macaddr.size == 6 and
 | 
			
		||||
          hwtype == 1 and
 | 
			
		||||
          iflist[0][macaddr] and iflist[1][ipaddr]
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        size = opt.size
 | 
			
		||||
        idx = 0
 | 
			
		||||
        while idx <= size
 | 
			
		||||
| 
						 | 
				
			
			@ -249,11 +249,11 @@ else
 | 
			
		|||
        throw :not_used
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    module WsControl
 | 
			
		||||
      WsControl = Win32API.new('wsock32.dll', 'WsControl', 'LLPPPP', 'L')
 | 
			
		||||
      WSAGetLastError = Win32API.new('wsock32.dll', 'WSAGetLastError', 'V', 'L')
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      MAX_TDI_ENTITIES = 512
 | 
			
		||||
      IPPROTO_TCP = 6
 | 
			
		||||
      WSCTL_TCP_QUERY_INFORMATION = 0
 | 
			
		||||
| 
						 | 
				
			
			@ -269,7 +269,7 @@ else
 | 
			
		|||
      IF_MIB = 0x202
 | 
			
		||||
      IF_MIB_STATS_ID = 1
 | 
			
		||||
      IP_MIB_ADDRTABLE_ENTRY_ID = 0x102
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      def self.wsctl(tei_entity, tei_instance,
 | 
			
		||||
                     toi_class, toi_type, toi_id,
 | 
			
		||||
                     buffsize)
 | 
			
		||||
| 
						 | 
				
			
			@ -295,7 +295,7 @@ else
 | 
			
		|||
        [ buff, API.unpackdw(buffsize) ]
 | 
			
		||||
      end
 | 
			
		||||
      private_class_method :wsctl
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      def self.get_iflist
 | 
			
		||||
        # Get TDI Entity List
 | 
			
		||||
        entities, size =
 | 
			
		||||
| 
						 | 
				
			
			@ -332,7 +332,7 @@ else
 | 
			
		|||
            end
 | 
			
		||||
          end
 | 
			
		||||
        end
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        # Get IP Addresses
 | 
			
		||||
        entities.each do |entity, instance|
 | 
			
		||||
          if entity == CL_NL_ENTITY
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -17,7 +17,7 @@ module LUSolve
 | 
			
		|||
      end
 | 
			
		||||
      if nrmrow>zero then
 | 
			
		||||
         scales <<= one.div(nrmrow,prec)
 | 
			
		||||
      else 
 | 
			
		||||
      else
 | 
			
		||||
         raise "Singular matrix"
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -30,10 +30,10 @@
 | 
			
		|||
#
 | 
			
		||||
module BigMath
 | 
			
		||||
 | 
			
		||||
  # Computes the square root of x to the specified number of digits of 
 | 
			
		||||
  # Computes the square root of x to the specified number of digits of
 | 
			
		||||
  # precision.
 | 
			
		||||
  #
 | 
			
		||||
  # BigDecimal.new('2').sqrt(16).to_s 
 | 
			
		||||
  # BigDecimal.new('2').sqrt(16).to_s
 | 
			
		||||
  #  -> "0.14142135623730950488016887242096975E1"
 | 
			
		||||
  #
 | 
			
		||||
  def sqrt(x,prec)
 | 
			
		||||
| 
						 | 
				
			
			@ -120,7 +120,7 @@ module BigMath
 | 
			
		|||
    y
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # Computes the value of e (the base of natural logarithms) raised to the 
 | 
			
		||||
  # Computes the value of e (the base of natural logarithms) raised to the
 | 
			
		||||
  # power of x, to the specified number of digits of precision.
 | 
			
		||||
  #
 | 
			
		||||
  # If x is infinite or NaN, returns NaN.
 | 
			
		||||
| 
						 | 
				
			
			@ -148,7 +148,7 @@ module BigMath
 | 
			
		|||
    y
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # Computes the natural logarithm of x to the specified number of digits 
 | 
			
		||||
  # Computes the natural logarithm of x to the specified number of digits
 | 
			
		||||
  # of precision.
 | 
			
		||||
  #
 | 
			
		||||
  # Returns x if x is infinite or NaN.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
#
 | 
			
		||||
# newton.rb 
 | 
			
		||||
# newton.rb
 | 
			
		||||
#
 | 
			
		||||
# Solves the nonlinear algebraic equation system f = 0 by Newton's method.
 | 
			
		||||
# This program is not dependent on BigDecimal.
 | 
			
		||||
| 
						 | 
				
			
			@ -28,7 +28,7 @@ require "bigdecimal/jacobian"
 | 
			
		|||
module Newton
 | 
			
		||||
  include LUSolve
 | 
			
		||||
  include Jacobian
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  def norm(fv,zero=0.0)
 | 
			
		||||
    s = zero
 | 
			
		||||
    n = fv.size
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -41,7 +41,7 @@ class BigDecimal < Numeric
 | 
			
		|||
  end
 | 
			
		||||
 | 
			
		||||
  # Converts a BigDecimal to a Rational.
 | 
			
		||||
  def to_r 
 | 
			
		||||
  def to_r
 | 
			
		||||
     sign,digits,base,power = self.split
 | 
			
		||||
     numerator = sign*digits.to_i
 | 
			
		||||
     denomi_power = power - digits.size # base is always 10
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -67,10 +67,10 @@ while TRUE
 | 
			
		|||
      else
 | 
			
		||||
	break
 | 
			
		||||
      end
 | 
			
		||||
      i += 1 
 | 
			
		||||
      i += 1
 | 
			
		||||
    end
 | 
			
		||||
    #wscrl(i)
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
  when "p"  #when KEY_UP
 | 
			
		||||
    i = 0
 | 
			
		||||
    while i < n
 | 
			
		||||
| 
						 | 
				
			
			@ -79,8 +79,8 @@ while TRUE
 | 
			
		|||
      else
 | 
			
		||||
	break
 | 
			
		||||
      end
 | 
			
		||||
      i += 1 
 | 
			
		||||
    end    
 | 
			
		||||
      i += 1
 | 
			
		||||
    end
 | 
			
		||||
    #wscrl(-i)
 | 
			
		||||
 | 
			
		||||
  when "q"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -23,7 +23,7 @@ module Digest
 | 
			
		|||
 | 
			
		||||
  class ::Digest::Class
 | 
			
		||||
    # creates a digest object and reads a given file, _name_.
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #  p Digest::SHA256.file("X11R6.8.2-src.tar.bz2").hexdigest
 | 
			
		||||
    #  # => "f02e3c85572dc9ad7cb77c2a638e3be24cc1b5bea9fdbb0b0299c9668475c534"
 | 
			
		||||
    def self.file(name)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -149,7 +149,7 @@ module DL
 | 
			
		|||
	  mname[0,1] = mname[0,1].downcase
 | 
			
		||||
	end
 | 
			
		||||
	@SYM[mname] = [sym,rdec,enc,dec]
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
	module_eval [
 | 
			
		||||
	  "def #{mname}(*args)",
 | 
			
		||||
	  "  sym,rdec,enc,dec  = @SYM['#{mname}']",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -113,7 +113,7 @@ module DL
 | 
			
		|||
	  }
 | 
			
		||||
	  @size = DL.sizeof(@tys)
 | 
			
		||||
	end
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
	def parse_elem(elem)
 | 
			
		||||
	  elem.strip!
 | 
			
		||||
	  case elem
 | 
			
		||||
| 
						 | 
				
			
			@ -135,7 +135,7 @@ module DL
 | 
			
		|||
	  return [name,ty,num,enc,dec]
 | 
			
		||||
	end
 | 
			
		||||
      end  # class Struct
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      class Union < Struct
 | 
			
		||||
	def new
 | 
			
		||||
	  ptr = DL::malloc(@size)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,7 +9,7 @@ module DL
 | 
			
		|||
      # ["alias name",
 | 
			
		||||
      #  "type name", encoding_method, decoding_method,   for function prototypes
 | 
			
		||||
      #  "type name", encoding_method, decoding_method]   for structures (not implemented)
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      # for Windows
 | 
			
		||||
      ["DWORD",  "unsigned long", nil, nil,
 | 
			
		||||
                 "unsigned long", nil, nil],
 | 
			
		||||
| 
						 | 
				
			
			@ -49,7 +49,7 @@ module DL
 | 
			
		|||
                 "unsigned int", nil, nil],
 | 
			
		||||
      ["HWND",   "unsigned int", nil, nil,
 | 
			
		||||
                 "unsigned int", nil, nil],
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      # Others
 | 
			
		||||
      ["uint",   "unsigned int", nil, nil,
 | 
			
		||||
                 "unsigned int", nil, nil],
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,7 +15,7 @@ LIBNAME = ARGV[0] || "libsample.so"
 | 
			
		|||
class Person
 | 
			
		||||
  module Core
 | 
			
		||||
    extend DL::Importable
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    dlload LIBNAME
 | 
			
		||||
 | 
			
		||||
    # mangled symbol names
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -43,7 +43,7 @@ types = [
 | 
			
		|||
  "unknown",
 | 
			
		||||
  "no root dir",
 | 
			
		||||
  "Removable",
 | 
			
		||||
  "Fixed", 
 | 
			
		||||
  "Fixed",
 | 
			
		||||
  "Remote",
 | 
			
		||||
  "CDROM",
 | 
			
		||||
  "RAM",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -18,9 +18,9 @@ module Kconv
 | 
			
		|||
  #
 | 
			
		||||
  # Public Constants
 | 
			
		||||
  #
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  #Constant of Encoding
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  # Auto-Detect
 | 
			
		||||
  AUTO = NKF::AUTO
 | 
			
		||||
  # ISO-2022-JP
 | 
			
		||||
| 
						 | 
				
			
			@ -47,16 +47,16 @@ module Kconv
 | 
			
		|||
  #
 | 
			
		||||
  # Private Constants
 | 
			
		||||
  #
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  # Revision of kconv.rb
 | 
			
		||||
  REVISION = %q$Revision$
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  #Regexp of Encoding
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  # Regexp of Shift_JIS string (private constant)
 | 
			
		||||
  RegexpShiftjis = /\A(?:
 | 
			
		||||
		       [\x00-\x7f\xa1-\xdf] |
 | 
			
		||||
		       [\x81-\x9f\xe0-\xfc][\x40-\x7e\x80-\xfc] 
 | 
			
		||||
		       [\x81-\x9f\xe0-\xfc][\x40-\x7e\x80-\xfc]
 | 
			
		||||
		      )*\z/nx
 | 
			
		||||
 | 
			
		||||
  # Regexp of EUC-JP string (private constant)
 | 
			
		||||
| 
						 | 
				
			
			@ -81,7 +81,7 @@ module Kconv
 | 
			
		|||
  #
 | 
			
		||||
  # Public Methods
 | 
			
		||||
  #
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  # call-seq:
 | 
			
		||||
  #    Kconv.kconv(str, out_code, in_code = Kconv::AUTO)
 | 
			
		||||
  #
 | 
			
		||||
| 
						 | 
				
			
			@ -277,11 +277,11 @@ class String
 | 
			
		|||
  def kconv(out_code, in_code=Kconv::AUTO)
 | 
			
		||||
    Kconv::kconv(self, out_code, in_code)
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  #
 | 
			
		||||
  # to Encoding
 | 
			
		||||
  #
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  # call-seq:
 | 
			
		||||
  #    String#tojis   -> string
 | 
			
		||||
  #
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -14,7 +14,7 @@
 | 
			
		|||
 | 
			
		||||
= Version
 | 
			
		||||
  $Id$
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
= Notes
 | 
			
		||||
  Tested on FreeBSD 5-CURRENT and 4-STABLE
 | 
			
		||||
  - ruby 1.6.8 (2003-01-17) [i386-freebsd5]
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,7 +12,7 @@
 | 
			
		|||
 | 
			
		||||
= Version
 | 
			
		||||
  $Id$
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  2001/11/06: Contiributed to Ruby/OpenSSL project.
 | 
			
		||||
 | 
			
		||||
== class Net::Telnet
 | 
			
		||||
| 
						 | 
				
			
			@ -145,7 +145,7 @@ module Net
 | 
			
		|||
        end
 | 
			
		||||
      end
 | 
			
		||||
    end # preprocess
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    alias waitfor_org waitfor
 | 
			
		||||
 | 
			
		||||
    def waitfor(options)
 | 
			
		||||
| 
						 | 
				
			
			@ -181,7 +181,7 @@ module Net
 | 
			
		|||
        begin
 | 
			
		||||
          c = @rest + @sock.sysread(1024 * 1024)
 | 
			
		||||
          @dumplog.log_dump('<', c) if @options.has_key?("Dump_log")
 | 
			
		||||
          if @options["Telnetmode"]   
 | 
			
		||||
          if @options["Telnetmode"]
 | 
			
		||||
            pos = 0
 | 
			
		||||
            catch(:next){
 | 
			
		||||
              while true
 | 
			
		||||
| 
						 | 
				
			
			@ -213,11 +213,11 @@ module Net
 | 
			
		|||
          end
 | 
			
		||||
          @log.print(buf) if @options.has_key?("Output_log")
 | 
			
		||||
          line.concat(buf)
 | 
			
		||||
          yield buf if block_given?   
 | 
			
		||||
          yield buf if block_given?
 | 
			
		||||
        rescue EOFError # End of file reached
 | 
			
		||||
          if line == ''
 | 
			
		||||
            line = nil
 | 
			
		||||
            yield nil if block_given? 
 | 
			
		||||
            yield nil if block_given?
 | 
			
		||||
          end
 | 
			
		||||
          break
 | 
			
		||||
        end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,9 +12,9 @@ require 'expect'
 | 
			
		|||
fnames = []
 | 
			
		||||
PTY.spawn("ftp ftp.ruby-lang.org") do |r_f,w_f,pid|
 | 
			
		||||
  w_f.sync = true
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  $expect_verbose = false
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  if !ENV['USER'].nil?
 | 
			
		||||
    username = ENV['USER']
 | 
			
		||||
  elsif !ENV['LOGNAME'].nil?
 | 
			
		||||
| 
						 | 
				
			
			@ -22,14 +22,14 @@ PTY.spawn("ftp ftp.ruby-lang.org") do |r_f,w_f,pid|
 | 
			
		|||
  else
 | 
			
		||||
    username = 'guest'
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  r_f.expect(/^(Name).*: |(word):|> /) do
 | 
			
		||||
    w_f.puts($1 ? "ftp" : $2 ? "#{username}@" : "cd pub/ruby")
 | 
			
		||||
  end
 | 
			
		||||
  r_f.expect("> ") do
 | 
			
		||||
    w_f.print "dir\n"
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  r_f.expect(/[^\-]> /) do |output|
 | 
			
		||||
    for x in output[0].split("\n")
 | 
			
		||||
      if x =~ /(ruby.*?\.tar\.gz)/ then
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -18,7 +18,7 @@ PTY.spawn("/bin/csh") do |r_pty,w_pty,pid|
 | 
			
		|||
      w_pty.flush
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  begin
 | 
			
		||||
    while true
 | 
			
		||||
      c = r_pty.sysread(512)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,7 +6,7 @@
 | 
			
		|||
#       by Keiju ISHITSUKA(SHL Japan Inc.)
 | 
			
		||||
#
 | 
			
		||||
# Documentation by Kevin Jackson and Gavin Sinclair.
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
# Performance improvements by Kurt Stephens.
 | 
			
		||||
#
 | 
			
		||||
# When you <tt>require 'rational'</tt>, all interactions between numbers
 | 
			
		||||
| 
						 | 
				
			
			@ -15,7 +15,7 @@
 | 
			
		|||
#   1.quo(2)              # -> 0.5
 | 
			
		||||
#   require 'rational'
 | 
			
		||||
#   1.quo(2)              # -> Rational(1,2)
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
# See Rational for full documentation.
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -24,7 +24,7 @@ require "rational.so"
 | 
			
		|||
 | 
			
		||||
#
 | 
			
		||||
# Creates a Rational number (i.e. a fraction).  +a+ and +b+ should be Integers:
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
#   Rational(1,3)           # -> 1/3
 | 
			
		||||
#
 | 
			
		||||
# Note: trying to construct a Rational with floating point or real values
 | 
			
		||||
| 
						 | 
				
			
			@ -55,7 +55,7 @@ end
 | 
			
		|||
# Examples:
 | 
			
		||||
#   Rational(5,6)             # -> 5/6
 | 
			
		||||
#   Rational(5)               # -> 5/1
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
# Rational numbers are reduced to their lowest terms:
 | 
			
		||||
#   Rational(6,10)            # -> 3/5
 | 
			
		||||
#
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -47,7 +47,7 @@ class TestSyslog < Test::Unit::TestCase
 | 
			
		|||
    Syslog.close
 | 
			
		||||
 | 
			
		||||
    # given parameters
 | 
			
		||||
    Syslog.open("foo", Syslog::LOG_NDELAY | Syslog::LOG_PERROR, Syslog::LOG_DAEMON) 
 | 
			
		||||
    Syslog.open("foo", Syslog::LOG_NDELAY | Syslog::LOG_PERROR, Syslog::LOG_DAEMON)
 | 
			
		||||
 | 
			
		||||
    assert_equal('foo', Syslog.ident)
 | 
			
		||||
    assert_equal(Syslog::LOG_NDELAY | Syslog::LOG_PERROR, Syslog.options)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,7 +20,7 @@ end
 | 
			
		|||
def create_win32ole_makefile
 | 
			
		||||
  if have_library("ole32") and
 | 
			
		||||
     have_library("oleaut32") and
 | 
			
		||||
     have_library("uuid") and 
 | 
			
		||||
     have_library("uuid") and
 | 
			
		||||
     have_library("user32") and
 | 
			
		||||
     have_library("kernel32") and
 | 
			
		||||
     have_library("advapi32") and
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,7 +20,7 @@ end
 | 
			
		|||
# Remark!!! CONSTANTS has not tested enoughly!!!
 | 
			
		||||
# CONSTANTS is alpha release.
 | 
			
		||||
# If there are constants which first letter is not [a-zA-Z],
 | 
			
		||||
# like a '_Foo', then maybe you can access the value by 
 | 
			
		||||
# like a '_Foo', then maybe you can access the value by
 | 
			
		||||
# using CONSTANTS['_Foo']
 | 
			
		||||
#------------------------------------------------------------
 | 
			
		||||
IE_CONST::CONSTANTS.each do |k, v|
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -26,7 +26,7 @@ ev = WIN32OLE_EVENT.new(ie, 'DWebBrowserEvents')
 | 
			
		|||
 | 
			
		||||
ev.on_event {|*args| default_handler(*args)}
 | 
			
		||||
ev.on_event("NavigateComplete") {|url| navigate(url)}
 | 
			
		||||
ev.on_event("Quit") {|*args| stop_msg_loop} 
 | 
			
		||||
ev.on_event("Quit") {|*args| stop_msg_loop}
 | 
			
		||||
 | 
			
		||||
$LOOP = TRUE
 | 
			
		||||
while ($LOOP)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,7 +7,7 @@ require "win32ole"
 | 
			
		|||
def listup(items)
 | 
			
		||||
#  items.each do |i|
 | 
			
		||||
  for i in items
 | 
			
		||||
    puts i.name 
 | 
			
		||||
    puts i.name
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -50,7 +50,7 @@ class WIN32COMGen
 | 
			
		|||
    ts = ''
 | 
			
		||||
    typedetails.each do |t|
 | 
			
		||||
      case t
 | 
			
		||||
      when 'CARRAY', 'VOID', 'UINT', 'RESULT', 'DECIMAL', 'I8', 'UI8' 
 | 
			
		||||
      when 'CARRAY', 'VOID', 'UINT', 'RESULT', 'DECIMAL', 'I8', 'UI8'
 | 
			
		||||
#	  raise "Sorry type\"" + t + "\" not supported"
 | 
			
		||||
      ts << "\"??? NOT SUPPORTED TYPE:`#{t}'\""
 | 
			
		||||
      when 'USERDEFINED', 'Unknown Type 9'
 | 
			
		||||
| 
						 | 
				
			
			@ -81,7 +81,7 @@ class WIN32COMGen
 | 
			
		|||
      generate_argtype(param.ole_type_detail)
 | 
			
		||||
    }.join(", ")
 | 
			
		||||
    if proptypes
 | 
			
		||||
      types += ", " if types.size > 0 
 | 
			
		||||
      types += ", " if types.size > 0
 | 
			
		||||
      types += generate_argtype(proptypes)
 | 
			
		||||
    end
 | 
			
		||||
    types
 | 
			
		||||
| 
						 | 
				
			
			@ -98,8 +98,8 @@ class WIN32COMGen
 | 
			
		|||
  end
 | 
			
		||||
 | 
			
		||||
  def generate_method_help(method, type = nil)
 | 
			
		||||
    str = "  # "  
 | 
			
		||||
    if type 
 | 
			
		||||
    str = "  # "
 | 
			
		||||
    if type
 | 
			
		||||
      str += type
 | 
			
		||||
    else
 | 
			
		||||
      str += method.return_type
 | 
			
		||||
| 
						 | 
				
			
			@ -124,7 +124,7 @@ class WIN32COMGen
 | 
			
		|||
  def generate_method_args_help(method)
 | 
			
		||||
    args = []
 | 
			
		||||
    method.params.each_with_index {|param, i|
 | 
			
		||||
      h = "  #   #{param.ole_type} arg#{i} --- #{param.name}" 
 | 
			
		||||
      h = "  #   #{param.ole_type} arg#{i} --- #{param.name}"
 | 
			
		||||
      inout = []
 | 
			
		||||
      inout.push "IN" if param.input?
 | 
			
		||||
      inout.push "OUT" if param.output?
 | 
			
		||||
| 
						 | 
				
			
			@ -167,14 +167,14 @@ class WIN32COMGen
 | 
			
		|||
      method.visible? &&
 | 
			
		||||
      method.size_params > 0
 | 
			
		||||
    }.each do |method|
 | 
			
		||||
      types = method.return_type_detail 
 | 
			
		||||
      types = method.return_type_detail
 | 
			
		||||
      io.puts "\n"
 | 
			
		||||
      io.puts  generate_method_help(method, types[0])
 | 
			
		||||
      io.puts  "  def #{method.name}"
 | 
			
		||||
      if klass.ole_type == "Class"
 | 
			
		||||
        io.print "    OLEProperty.new(@dispatch, #{method.dispid}, [" 
 | 
			
		||||
        io.print "    OLEProperty.new(@dispatch, #{method.dispid}, ["
 | 
			
		||||
      else
 | 
			
		||||
        io.print "    OLEProperty.new(self, #{method.dispid}, [" 
 | 
			
		||||
        io.print "    OLEProperty.new(self, #{method.dispid}, ["
 | 
			
		||||
      end
 | 
			
		||||
      io.print generate_argtypes(method, nil)
 | 
			
		||||
      io.print "], ["
 | 
			
		||||
| 
						 | 
				
			
			@ -321,8 +321,8 @@ STR
 | 
			
		|||
 | 
			
		||||
    ole_classes(typelib).select{|klass|
 | 
			
		||||
      klass.visible? &&
 | 
			
		||||
      (klass.ole_type == "Class" || 
 | 
			
		||||
       klass.ole_type == "Interface" || 
 | 
			
		||||
      (klass.ole_type == "Class" ||
 | 
			
		||||
       klass.ole_type == "Interface" ||
 | 
			
		||||
       klass.ole_type == "Dispatch" ||
 | 
			
		||||
       klass.ole_type == "Enum")
 | 
			
		||||
    }.each do |klass|
 | 
			
		||||
| 
						 | 
				
			
			@ -330,7 +330,7 @@ STR
 | 
			
		|||
    end
 | 
			
		||||
    begin
 | 
			
		||||
      @ole.quit if @ole
 | 
			
		||||
    rescue 
 | 
			
		||||
    rescue
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,11 +1,11 @@
 | 
			
		|||
# 
 | 
			
		||||
#
 | 
			
		||||
# This file created by olegen.rb as following.
 | 
			
		||||
#    ruby olegen.rb 'Microsoft XML, version 2.0' > xml.rb
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
require 'win32ole'
 | 
			
		||||
require 'win32ole/property'
 | 
			
		||||
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
module IXMLDOMImplementation
 | 
			
		||||
  include WIN32OLE::VARIANT
 | 
			
		||||
  attr_reader :lastargs
 | 
			
		||||
| 
						 | 
				
			
			@ -343,7 +343,7 @@ module OLEtagDOMNodeType
 | 
			
		|||
  NODE_NOTATION = 12
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
module IXMLDOMNodeList
 | 
			
		||||
  include WIN32OLE::VARIANT
 | 
			
		||||
  attr_reader :lastargs
 | 
			
		||||
| 
						 | 
				
			
			@ -380,7 +380,7 @@ module IXMLDOMNodeList
 | 
			
		|||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
module IXMLDOMNamedNodeMap
 | 
			
		||||
  include WIN32OLE::VARIANT
 | 
			
		||||
  attr_reader :lastargs
 | 
			
		||||
| 
						 | 
				
			
			@ -464,7 +464,7 @@ module IXMLDOMNamedNodeMap
 | 
			
		|||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
module IXMLDOMDocument
 | 
			
		||||
  include WIN32OLE::VARIANT
 | 
			
		||||
  attr_reader :lastargs
 | 
			
		||||
| 
						 | 
				
			
			@ -1040,7 +1040,7 @@ module IXMLDOMDocument
 | 
			
		|||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
module IXMLDOMDocumentType
 | 
			
		||||
  include WIN32OLE::VARIANT
 | 
			
		||||
  attr_reader :lastargs
 | 
			
		||||
| 
						 | 
				
			
			@ -1368,7 +1368,7 @@ module IXMLDOMDocumentType
 | 
			
		|||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
module IXMLDOMElement
 | 
			
		||||
  include WIN32OLE::VARIANT
 | 
			
		||||
  attr_reader :lastargs
 | 
			
		||||
| 
						 | 
				
			
			@ -1752,7 +1752,7 @@ module IXMLDOMElement
 | 
			
		|||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
module IXMLDOMAttribute
 | 
			
		||||
  include WIN32OLE::VARIANT
 | 
			
		||||
  attr_reader :lastargs
 | 
			
		||||
| 
						 | 
				
			
			@ -2080,7 +2080,7 @@ module IXMLDOMAttribute
 | 
			
		|||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
module IXMLDOMDocumentFragment
 | 
			
		||||
  include WIN32OLE::VARIANT
 | 
			
		||||
  attr_reader :lastargs
 | 
			
		||||
| 
						 | 
				
			
			@ -2384,7 +2384,7 @@ module IXMLDOMDocumentFragment
 | 
			
		|||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
module IXMLDOMText
 | 
			
		||||
  include WIN32OLE::VARIANT
 | 
			
		||||
  attr_reader :lastargs
 | 
			
		||||
| 
						 | 
				
			
			@ -2771,7 +2771,7 @@ module IXMLDOMText
 | 
			
		|||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
module IXMLDOMCharacterData
 | 
			
		||||
  include WIN32OLE::VARIANT
 | 
			
		||||
  attr_reader :lastargs
 | 
			
		||||
| 
						 | 
				
			
			@ -3149,7 +3149,7 @@ module IXMLDOMCharacterData
 | 
			
		|||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
module IXMLDOMComment
 | 
			
		||||
  include WIN32OLE::VARIANT
 | 
			
		||||
  attr_reader :lastargs
 | 
			
		||||
| 
						 | 
				
			
			@ -3527,7 +3527,7 @@ module IXMLDOMComment
 | 
			
		|||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
module IXMLDOMCDATASection
 | 
			
		||||
  include WIN32OLE::VARIANT
 | 
			
		||||
  attr_reader :lastargs
 | 
			
		||||
| 
						 | 
				
			
			@ -3914,7 +3914,7 @@ module IXMLDOMCDATASection
 | 
			
		|||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
module IXMLDOMProcessingInstruction
 | 
			
		||||
  include WIN32OLE::VARIANT
 | 
			
		||||
  attr_reader :lastargs
 | 
			
		||||
| 
						 | 
				
			
			@ -4242,7 +4242,7 @@ module IXMLDOMProcessingInstruction
 | 
			
		|||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
module IXMLDOMEntityReference
 | 
			
		||||
  include WIN32OLE::VARIANT
 | 
			
		||||
  attr_reader :lastargs
 | 
			
		||||
| 
						 | 
				
			
			@ -4608,7 +4608,7 @@ module IXMLDOMParseError
 | 
			
		|||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
module IXMLDOMNotation
 | 
			
		||||
  include WIN32OLE::VARIANT
 | 
			
		||||
  attr_reader :lastargs
 | 
			
		||||
| 
						 | 
				
			
			@ -4928,7 +4928,7 @@ module IXMLDOMNotation
 | 
			
		|||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
module IXMLDOMEntity
 | 
			
		||||
  include WIN32OLE::VARIANT
 | 
			
		||||
  attr_reader :lastargs
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,4 @@
 | 
			
		|||
# You need RubyUnit and MS Excel and MSI to run this test script 
 | 
			
		||||
# You need RubyUnit and MS Excel and MSI to run this test script
 | 
			
		||||
 | 
			
		||||
require 'rubyunit'
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,4 @@
 | 
			
		|||
# You need RubyUnit and MS Excel and MSI to run this test script 
 | 
			
		||||
# You need RubyUnit and MS Excel and MSI to run this test script
 | 
			
		||||
 | 
			
		||||
require 'rubyunit'
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -46,7 +46,7 @@ class TestOLEPARAM < RUNIT::TestCase
 | 
			
		|||
    f = methods.find {|m| m.name == 'SaveAs'}
 | 
			
		||||
    assert(f.params[0].input?)
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  def test_output
 | 
			
		||||
    classes = WIN32OLE_TYPE.ole_classes(MS_EXCEL_TYPELIB)
 | 
			
		||||
    methods = classes.find {|c| c.name == 'Worksheet'}.ole_methods
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,4 @@
 | 
			
		|||
# You need RubyUnit and MS Excel and MSI to run this test script 
 | 
			
		||||
# You need RubyUnit and MS Excel and MSI to run this test script
 | 
			
		||||
 | 
			
		||||
require 'rubyunit'
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,4 @@
 | 
			
		|||
# You need RubyUnit and MS Excel and MSI to run this test script 
 | 
			
		||||
# You need RubyUnit and MS Excel and MSI to run this test script
 | 
			
		||||
 | 
			
		||||
require 'rubyunit'
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,4 @@
 | 
			
		|||
# You need RubyUnit and MS Excel and MSI to run this test script 
 | 
			
		||||
# You need RubyUnit and MS Excel and MSI to run this test script
 | 
			
		||||
 | 
			
		||||
require 'rubyunit'
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,4 @@
 | 
			
		|||
# You need RubyUnit and MS Excel and MSI to run this test script 
 | 
			
		||||
# You need RubyUnit and MS Excel and MSI to run this test script
 | 
			
		||||
 | 
			
		||||
require 'runit/testcase'
 | 
			
		||||
require 'runit/cui/testrunner'
 | 
			
		||||
| 
						 | 
				
			
			@ -289,7 +289,7 @@ class TestWin32OLE_WITH_MSI < RUNIT::TestCase
 | 
			
		|||
    @record = installer.CreateRecord(2)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # Sorry, this test fails. 
 | 
			
		||||
  # Sorry, this test fails.
 | 
			
		||||
  # Win32OLE does not support this style to set property.
 | 
			
		||||
  # Use Win32OLE#setproperty or Win32OLE#[]= .
 | 
			
		||||
  # def test_invoke
 | 
			
		||||
| 
						 | 
				
			
			@ -317,7 +317,7 @@ end
 | 
			
		|||
# a subclass of Win32OLE
 | 
			
		||||
# override new() and connect()
 | 
			
		||||
class MyExcel<WIN32OLE
 | 
			
		||||
    def MyExcel.new 
 | 
			
		||||
    def MyExcel.new
 | 
			
		||||
        super "Excel.Application"
 | 
			
		||||
    end
 | 
			
		||||
    def MyExcel.connect
 | 
			
		||||
| 
						 | 
				
			
			@ -330,7 +330,7 @@ class TestMyExcel < TestWin32OLE
 | 
			
		|||
# because we overrided new() and connect()
 | 
			
		||||
# we need to change the test.
 | 
			
		||||
# also, because the class will be different
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
  def setup
 | 
			
		||||
    @excel = MyExcel.new
 | 
			
		||||
    @excel.visible = true
 | 
			
		||||
| 
						 | 
				
			
			@ -344,7 +344,7 @@ class TestMyExcel < TestWin32OLE
 | 
			
		|||
  end
 | 
			
		||||
#
 | 
			
		||||
# const_load didn't like to be called twice,
 | 
			
		||||
# and I don't know how to undefine something in Ruby yet 
 | 
			
		||||
# and I don't know how to undefine something in Ruby yet
 | 
			
		||||
# so, hide the test.
 | 
			
		||||
#
 | 
			
		||||
  private :test_s_const_load
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,7 +9,7 @@ require "test/unit"
 | 
			
		|||
 | 
			
		||||
if defined?(WIN32OLE)
 | 
			
		||||
  class TestWIN32OLE_FOR_PROPERTYPUTREF < Test::Unit::TestCase
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    def setup
 | 
			
		||||
      @obj = WIN32OLE.new('Scripting.Dictionary')
 | 
			
		||||
    end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -35,8 +35,8 @@ if defined?(WIN32OLE_EVENT)
 | 
			
		|||
      ev.on_event {|*args| default_handler(*args)}
 | 
			
		||||
      @ie.navigate("file:///#{@f}")
 | 
			
		||||
      while @ie.busy
 | 
			
		||||
        WIN32OLE_EVENT.new(@ie, 'DWebBrowserEvents') 
 | 
			
		||||
        GC.start  
 | 
			
		||||
        WIN32OLE_EVENT.new(@ie, 'DWebBrowserEvents')
 | 
			
		||||
        GC.start
 | 
			
		||||
        sleep 0.1
 | 
			
		||||
      end
 | 
			
		||||
      assert_match(/BeforeNavigate/, @event)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,7 +9,7 @@ require "test/unit"
 | 
			
		|||
 | 
			
		||||
if defined?(WIN32OLE)
 | 
			
		||||
  class TestWIN32OLE_WITH_WORD < Test::Unit::TestCase
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    def setup
 | 
			
		||||
      begin
 | 
			
		||||
        @obj = WIN32OLE.new('Word.Application')
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,7 +11,7 @@
 | 
			
		|||
#  With English:
 | 
			
		||||
#
 | 
			
		||||
#      require "English"
 | 
			
		||||
#      
 | 
			
		||||
#
 | 
			
		||||
#      $OUTPUT_FIELD_SEPARATOR = ' -- '
 | 
			
		||||
#      "waterbuffalo" =~ /buff/
 | 
			
		||||
#      print $LOADED_FEATURES, $POSTMATCH, $PID, "\n"
 | 
			
		||||
| 
						 | 
				
			
			@ -83,7 +83,7 @@ alias $DEFAULT_OUTPUT          $>
 | 
			
		|||
# of the contents of all the files
 | 
			
		||||
# given as command-line arguments, or <tt>$stdin</tt>
 | 
			
		||||
# (in the case where there are no
 | 
			
		||||
# arguments). <tt>$<</tt> supports methods similar to a 
 | 
			
		||||
# arguments). <tt>$<</tt> supports methods similar to a
 | 
			
		||||
# +File+ object:
 | 
			
		||||
# +inmode+, +close+,
 | 
			
		||||
# <tt>closed?</tt>, +each+,
 | 
			
		||||
| 
						 | 
				
			
			@ -91,7 +91,7 @@ alias $DEFAULT_OUTPUT          $>
 | 
			
		|||
# +eof+, <tt>eof?</tt>, +file+,
 | 
			
		||||
# +filename+, +fileno+,
 | 
			
		||||
# +getc+, +gets+, +lineno+,
 | 
			
		||||
# <tt>lineno=</tt>, +path+, 
 | 
			
		||||
# <tt>lineno=</tt>, +path+,
 | 
			
		||||
# +pos+, <tt>pos=</tt>,
 | 
			
		||||
# +read+, +readchar+,
 | 
			
		||||
# +readline+, +readlines+,
 | 
			
		||||
| 
						 | 
				
			
			@ -139,12 +139,12 @@ alias $ARGV                    $*
 | 
			
		|||
alias $MATCH                   $&
 | 
			
		||||
 | 
			
		||||
# The string preceding the match in the last
 | 
			
		||||
# successful pattern match. This variable is local to 
 | 
			
		||||
# successful pattern match. This variable is local to
 | 
			
		||||
# the current scope. Read only. Thread local.
 | 
			
		||||
alias $PREMATCH                $`
 | 
			
		||||
 | 
			
		||||
# The string following the match in the last
 | 
			
		||||
# successful pattern match. This variable is local to 
 | 
			
		||||
# successful pattern match. This variable is local to
 | 
			
		||||
# the current scope. Read only. Thread local.
 | 
			
		||||
alias $POSTMATCH               $'
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,7 +1,7 @@
 | 
			
		|||
#
 | 
			
		||||
# = base64.rb: methods for base64-encoding and -decoding strings
 | 
			
		||||
#
 | 
			
		||||
# Author:: Yukihiro Matsumoto 
 | 
			
		||||
# Author:: Yukihiro Matsumoto
 | 
			
		||||
# Documentation:: Dave Thomas and Gavin Sinclair
 | 
			
		||||
#
 | 
			
		||||
# Until Ruby 1.8.1, these methods were defined at the top-level.  Now
 | 
			
		||||
| 
						 | 
				
			
			@ -16,7 +16,7 @@ require "kconv"
 | 
			
		|||
 | 
			
		||||
# The Base64 module provides for the encoding (#encode64) and decoding
 | 
			
		||||
# (#decode64) of binary data using a Base64 representation.
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
# The following particular features are also provided:
 | 
			
		||||
# - encode into lines of a given length (#b64encode)
 | 
			
		||||
# - decode the special format specified in RFC2047 for the
 | 
			
		||||
| 
						 | 
				
			
			@ -24,12 +24,12 @@ require "kconv"
 | 
			
		|||
#
 | 
			
		||||
# == Example
 | 
			
		||||
#
 | 
			
		||||
# A simple encoding and decoding. 
 | 
			
		||||
# 
 | 
			
		||||
# A simple encoding and decoding.
 | 
			
		||||
#
 | 
			
		||||
#     require "base64"
 | 
			
		||||
#
 | 
			
		||||
#     enc   = Base64.encode64('Send reinforcements')
 | 
			
		||||
#                         # -> "U2VuZCByZWluZm9yY2VtZW50cw==\n" 
 | 
			
		||||
#                         # -> "U2VuZCByZWluZm9yY2VtZW50cw==\n"
 | 
			
		||||
#     plain = Base64.decode64(enc)
 | 
			
		||||
#                         # -> "Send reinforcements"
 | 
			
		||||
#
 | 
			
		||||
| 
						 | 
				
			
			@ -78,7 +78,7 @@ module Base64
 | 
			
		|||
      decode64($1)
 | 
			
		||||
    }
 | 
			
		||||
    str = Kconv::toeuc(str)
 | 
			
		||||
    str.gsub!(/\n/, ' ') 
 | 
			
		||||
    str.gsub!(/\n/, ' ')
 | 
			
		||||
    str.gsub!(/\0/, '')
 | 
			
		||||
    str
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			@ -135,7 +135,7 @@ module Base64
 | 
			
		|||
  # +len+ (default 60) characters.
 | 
			
		||||
  #
 | 
			
		||||
  #    require 'base64'
 | 
			
		||||
  #    data = "Now is the time for all good coders\nto learn Ruby" 
 | 
			
		||||
  #    data = "Now is the time for all good coders\nto learn Ruby"
 | 
			
		||||
  #    Base64.b64encode(data)
 | 
			
		||||
  #
 | 
			
		||||
  # <i>Generates:</i>
 | 
			
		||||
| 
						 | 
				
			
			@ -147,7 +147,7 @@ module Base64
 | 
			
		|||
    encode64(bin).scan(/.{1,#{len}}/) do
 | 
			
		||||
      print $&, "\n"
 | 
			
		||||
    end
 | 
			
		||||
  end 
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  module Deprecated # :nodoc:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										164
									
								
								lib/benchmark.rb
									
										
									
									
									
								
							
							
						
						
									
										164
									
								
								lib/benchmark.rb
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1,13 +1,13 @@
 | 
			
		|||
=begin
 | 
			
		||||
#
 | 
			
		||||
# benchmark.rb - a performance benchmarking library 
 | 
			
		||||
# 
 | 
			
		||||
# benchmark.rb - a performance benchmarking library
 | 
			
		||||
#
 | 
			
		||||
# $Id$
 | 
			
		||||
# 
 | 
			
		||||
# Created by Gotoken (gotoken@notwork.org). 
 | 
			
		||||
#
 | 
			
		||||
# Created by Gotoken (gotoken@notwork.org).
 | 
			
		||||
#
 | 
			
		||||
# Documentation by Gotoken (original RD), Lyle Johnson (RDoc conversion), and
 | 
			
		||||
# Gavin Sinclair (editing). 
 | 
			
		||||
# Gavin Sinclair (editing).
 | 
			
		||||
#
 | 
			
		||||
=end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -26,15 +26,15 @@
 | 
			
		|||
#       require 'benchmark'
 | 
			
		||||
#
 | 
			
		||||
#       puts Benchmark.measure { "a"*1_000_000 }
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
#   On my machine (FreeBSD 3.2 on P5, 100MHz) this generates:
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
#       1.166667   0.050000   1.216667 (  0.571355)
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
#   This report shows the user CPU time, system CPU time, the sum of
 | 
			
		||||
#   the user and system CPU times, and the elapsed real time. The unit
 | 
			
		||||
#   of time is seconds.
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
# * Do some experiments sequentially using the #bm method:
 | 
			
		||||
#
 | 
			
		||||
#       require 'benchmark'
 | 
			
		||||
| 
						 | 
				
			
			@ -45,7 +45,7 @@
 | 
			
		|||
#         x.report { n.times do   ; a = "1"; end }
 | 
			
		||||
#         x.report { 1.upto(n) do ; a = "1"; end }
 | 
			
		||||
#       end
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
#   The result:
 | 
			
		||||
#
 | 
			
		||||
#              user     system      total        real
 | 
			
		||||
| 
						 | 
				
			
			@ -63,14 +63,14 @@
 | 
			
		|||
#         x.report("times:") { n.times do   ; a = "1"; end }
 | 
			
		||||
#         x.report("upto:")  { 1.upto(n) do ; a = "1"; end }
 | 
			
		||||
#       end
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
# The result:
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
#                     user     system      total        real
 | 
			
		||||
#        for:     1.050000   0.000000   1.050000 (  0.503462)
 | 
			
		||||
#        times:   1.533333   0.016667   1.550000 (  0.735473)
 | 
			
		||||
#        upto:    1.500000   0.016667   1.516667 (  0.711239)
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
# * The times for some benchmarks depend on the order in which items
 | 
			
		||||
#   are run.  These differences are due to the cost of memory
 | 
			
		||||
| 
						 | 
				
			
			@ -79,21 +79,21 @@
 | 
			
		|||
#   sort an array of floats:
 | 
			
		||||
#
 | 
			
		||||
#       require 'benchmark'
 | 
			
		||||
#       
 | 
			
		||||
#
 | 
			
		||||
#       array = (1..1000000).map { rand }
 | 
			
		||||
#       
 | 
			
		||||
#
 | 
			
		||||
#       Benchmark.bmbm do |x|
 | 
			
		||||
#         x.report("sort!") { array.dup.sort! }
 | 
			
		||||
#         x.report("sort")  { array.dup.sort  }
 | 
			
		||||
#       end
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
#   The result:
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
#        Rehearsal -----------------------------------------
 | 
			
		||||
#        sort!  11.928000   0.010000  11.938000 ( 12.756000)
 | 
			
		||||
#        sort   13.048000   0.020000  13.068000 ( 13.857000)
 | 
			
		||||
#        ------------------------------- total: 25.006000sec
 | 
			
		||||
#        
 | 
			
		||||
#
 | 
			
		||||
#                    user     system      total        real
 | 
			
		||||
#        sort!  12.959000   0.010000  12.969000 ( 13.793000)
 | 
			
		||||
#        sort   12.007000   0.000000  12.007000 ( 12.791000)
 | 
			
		||||
| 
						 | 
				
			
			@ -103,7 +103,7 @@
 | 
			
		|||
#   using the #benchmark method:
 | 
			
		||||
#
 | 
			
		||||
#       require 'benchmark'
 | 
			
		||||
#       include Benchmark         # we need the CAPTION and FMTSTR constants 
 | 
			
		||||
#       include Benchmark         # we need the CAPTION and FMTSTR constants
 | 
			
		||||
#
 | 
			
		||||
#       n = 50000
 | 
			
		||||
#       Benchmark.benchmark(" "*7 + CAPTION, 7, FMTSTR, ">total:", ">avg:") do |x|
 | 
			
		||||
| 
						 | 
				
			
			@ -112,9 +112,9 @@
 | 
			
		|||
#         tu = x.report("upto:")  { 1.upto(n) do ; a = "1"; end }
 | 
			
		||||
#         [tf+tt+tu, (tf+tt+tu)/3]
 | 
			
		||||
#       end
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
#   The result:
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
#                     user     system      total        real
 | 
			
		||||
#        for:     1.016667   0.016667   1.033333 (  0.485749)
 | 
			
		||||
#        times:   1.450000   0.016667   1.466667 (  0.681367)
 | 
			
		||||
| 
						 | 
				
			
			@ -145,10 +145,10 @@ module Benchmark
 | 
			
		|||
  # suitable for nearly all benchmarking requirements.  See the examples in
 | 
			
		||||
  # Benchmark, and the #bm and #bmbm methods.
 | 
			
		||||
  #
 | 
			
		||||
  # Example: 
 | 
			
		||||
  # Example:
 | 
			
		||||
  #
 | 
			
		||||
  #     require 'benchmark'
 | 
			
		||||
  #     include Benchmark          # we need the CAPTION and FMTSTR constants 
 | 
			
		||||
  #     include Benchmark          # we need the CAPTION and FMTSTR constants
 | 
			
		||||
  #
 | 
			
		||||
  #     n = 50000
 | 
			
		||||
  #     Benchmark.benchmark(" "*7 + CAPTION, 7, FMTSTR, ">total:", ">avg:") do |x|
 | 
			
		||||
| 
						 | 
				
			
			@ -157,16 +157,16 @@ module Benchmark
 | 
			
		|||
  #       tu = x.report("upto:")  { 1.upto(n) do ; a = "1"; end }
 | 
			
		||||
  #       [tf+tt+tu, (tf+tt+tu)/3]
 | 
			
		||||
  #     end
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  # <i>Generates:</i>
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  #                     user     system      total        real
 | 
			
		||||
  #        for:     1.016667   0.016667   1.033333 (  0.485749)
 | 
			
		||||
  #        times:   1.450000   0.016667   1.466667 (  0.681367)
 | 
			
		||||
  #        upto:    1.533333   0.000000   1.533333 (  0.722166)
 | 
			
		||||
  #        >total:  4.000000   0.033333   4.033333 (  1.889282)
 | 
			
		||||
  #        >avg:    1.333333   0.011111   1.344444 (  0.629761)
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
 | 
			
		||||
  def benchmark(caption = "", label_width = nil, fmtstr = nil, *labels) # :yield: report
 | 
			
		||||
    sync = STDOUT.sync
 | 
			
		||||
| 
						 | 
				
			
			@ -177,7 +177,7 @@ module Benchmark
 | 
			
		|||
    print caption
 | 
			
		||||
    results = yield(Report.new(label_width, fmtstr))
 | 
			
		||||
    Array === results and results.grep(Tms).each {|t|
 | 
			
		||||
      print((labels.shift || t.label || "").ljust(label_width), 
 | 
			
		||||
      print((labels.shift || t.label || "").ljust(label_width),
 | 
			
		||||
            t.format(fmtstr))
 | 
			
		||||
    }
 | 
			
		||||
    STDOUT.sync = sync
 | 
			
		||||
| 
						 | 
				
			
			@ -186,7 +186,7 @@ module Benchmark
 | 
			
		|||
 | 
			
		||||
  # A simple interface to the #benchmark method, #bm is generates sequential reports
 | 
			
		||||
  # with labels.  The parameters have the same meaning as for #benchmark.
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  #     require 'benchmark'
 | 
			
		||||
  #
 | 
			
		||||
  #     n = 50000
 | 
			
		||||
| 
						 | 
				
			
			@ -195,9 +195,9 @@ module Benchmark
 | 
			
		|||
  #       x.report("times:") { n.times do   ; a = "1"; end }
 | 
			
		||||
  #       x.report("upto:")  { 1.upto(n) do ; a = "1"; end }
 | 
			
		||||
  #     end
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  # <i>Generates:</i>
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  #                     user     system      total        real
 | 
			
		||||
  #        for:     1.050000   0.000000   1.050000 (  0.503462)
 | 
			
		||||
  #        times:   1.533333   0.016667   1.550000 (  0.735473)
 | 
			
		||||
| 
						 | 
				
			
			@ -224,21 +224,21 @@ module Benchmark
 | 
			
		|||
  # calculate the required label width.
 | 
			
		||||
  #
 | 
			
		||||
  #       require 'benchmark'
 | 
			
		||||
  #       
 | 
			
		||||
  #
 | 
			
		||||
  #       array = (1..1000000).map { rand }
 | 
			
		||||
  #       
 | 
			
		||||
  #
 | 
			
		||||
  #       Benchmark.bmbm do |x|
 | 
			
		||||
  #         x.report("sort!") { array.dup.sort! }
 | 
			
		||||
  #         x.report("sort")  { array.dup.sort  }
 | 
			
		||||
  #       end
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  # <i>Generates:</i>
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  #        Rehearsal -----------------------------------------
 | 
			
		||||
  #        sort!  11.928000   0.010000  11.938000 ( 12.756000)
 | 
			
		||||
  #        sort   13.048000   0.020000  13.068000 ( 13.857000)
 | 
			
		||||
  #        ------------------------------- total: 25.006000sec
 | 
			
		||||
  #        
 | 
			
		||||
  #
 | 
			
		||||
  #                    user     system      total        real
 | 
			
		||||
  #        sort!  12.959000   0.010000  12.969000 ( 13.793000)
 | 
			
		||||
  #        sort   12.007000   0.000000  12.007000 ( 12.791000)
 | 
			
		||||
| 
						 | 
				
			
			@ -267,7 +267,7 @@ module Benchmark
 | 
			
		|||
    ets = sum.format("total: %tsec")
 | 
			
		||||
    printf("%s %s\n\n",
 | 
			
		||||
           "-"*(width+CAPTION.length-ets.length-1), ets)
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    # take
 | 
			
		||||
    print ' '*width, CAPTION
 | 
			
		||||
    list = []
 | 
			
		||||
| 
						 | 
				
			
			@ -285,7 +285,7 @@ module Benchmark
 | 
			
		|||
    ary
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  # Returns the time used to execute the given block as a
 | 
			
		||||
  # Benchmark::Tms object.
 | 
			
		||||
  #
 | 
			
		||||
| 
						 | 
				
			
			@ -293,10 +293,10 @@ module Benchmark
 | 
			
		|||
    t0, r0 = Benchmark.times, Time.now
 | 
			
		||||
    yield
 | 
			
		||||
    t1, r1 = Benchmark.times, Time.now
 | 
			
		||||
    Benchmark::Tms.new(t1.utime  - t0.utime, 
 | 
			
		||||
                       t1.stime  - t0.stime, 
 | 
			
		||||
                       t1.cutime - t0.cutime, 
 | 
			
		||||
                       t1.cstime - t0.cstime, 
 | 
			
		||||
    Benchmark::Tms.new(t1.utime  - t0.utime,
 | 
			
		||||
                       t1.stime  - t0.stime,
 | 
			
		||||
                       t1.cutime - t0.cutime,
 | 
			
		||||
                       t1.cstime - t0.cstime,
 | 
			
		||||
                       r1.to_f - r0.to_f,
 | 
			
		||||
                       label)
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			@ -323,8 +323,8 @@ module Benchmark
 | 
			
		|||
    # Usually, one doesn't call this method directly, as new
 | 
			
		||||
    # Job objects are created by the #bmbm method.
 | 
			
		||||
    # _width_ is a initial value for the label offset used in formatting;
 | 
			
		||||
    # the #bmbm method passes its _width_ argument to this constructor. 
 | 
			
		||||
    # 
 | 
			
		||||
    # the #bmbm method passes its _width_ argument to this constructor.
 | 
			
		||||
    #
 | 
			
		||||
    def initialize(width)
 | 
			
		||||
      @width = width
 | 
			
		||||
      @list = []
 | 
			
		||||
| 
						 | 
				
			
			@ -343,11 +343,11 @@ module Benchmark
 | 
			
		|||
    end
 | 
			
		||||
 | 
			
		||||
    alias report item
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    # An array of 2-element arrays, consisting of label and block pairs.
 | 
			
		||||
    attr_reader :list
 | 
			
		||||
    
 | 
			
		||||
    # Length of the widest label in the #list, plus one.  
 | 
			
		||||
 | 
			
		||||
    # Length of the widest label in the #list, plus one.
 | 
			
		||||
    attr_reader :width
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -363,10 +363,10 @@ module Benchmark
 | 
			
		|||
    #
 | 
			
		||||
    # Returns an initialized Report instance.
 | 
			
		||||
    # Usually, one doesn't call this method directly, as new
 | 
			
		||||
    # Report objects are created by the #benchmark and #bm methods. 
 | 
			
		||||
    # _width_ and _fmtstr_ are the label offset and 
 | 
			
		||||
    # format string used by Tms#format. 
 | 
			
		||||
    # 
 | 
			
		||||
    # Report objects are created by the #benchmark and #bm methods.
 | 
			
		||||
    # _width_ and _fmtstr_ are the label offset and
 | 
			
		||||
    # format string used by Tms#format.
 | 
			
		||||
    #
 | 
			
		||||
    def initialize(width = 0, fmtstr = nil)
 | 
			
		||||
      @width, @fmtstr = width, fmtstr
 | 
			
		||||
    end
 | 
			
		||||
| 
						 | 
				
			
			@ -398,50 +398,50 @@ module Benchmark
 | 
			
		|||
 | 
			
		||||
    # User CPU time
 | 
			
		||||
    attr_reader :utime
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    # System CPU time
 | 
			
		||||
    attr_reader :stime
 | 
			
		||||
   
 | 
			
		||||
 | 
			
		||||
    # User CPU time of children
 | 
			
		||||
    attr_reader :cutime
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    # System CPU time of children
 | 
			
		||||
    attr_reader :cstime
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    # Elapsed real time
 | 
			
		||||
    attr_reader :real
 | 
			
		||||
    
 | 
			
		||||
    # Total time, that is _utime_ + _stime_ + _cutime_ + _cstime_ 
 | 
			
		||||
 | 
			
		||||
    # Total time, that is _utime_ + _stime_ + _cutime_ + _cstime_
 | 
			
		||||
    attr_reader :total
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    # Label
 | 
			
		||||
    attr_reader :label
 | 
			
		||||
 | 
			
		||||
    #
 | 
			
		||||
    # Returns an initialized Tms object which has
 | 
			
		||||
    # _u_ as the user CPU time, _s_ as the system CPU time, 
 | 
			
		||||
    # _u_ as the user CPU time, _s_ as the system CPU time,
 | 
			
		||||
    # _cu_ as the children's user CPU time, _cs_ as the children's
 | 
			
		||||
    # system CPU time, _real_ as the elapsed real time and _l_
 | 
			
		||||
    # as the label. 
 | 
			
		||||
    # 
 | 
			
		||||
    # as the label.
 | 
			
		||||
    #
 | 
			
		||||
    def initialize(u = 0.0, s = 0.0, cu = 0.0, cs = 0.0, real = 0.0, l = nil)
 | 
			
		||||
      @utime, @stime, @cutime, @cstime, @real, @label = u, s, cu, cs, real, l
 | 
			
		||||
      @total = @utime + @stime + @cutime + @cstime
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    # Returns a new Tms object whose times are the sum of the times for this
 | 
			
		||||
    # Tms object, plus the time required to execute the code block (_blk_).
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    def add(&blk) # :yield:
 | 
			
		||||
      self + Benchmark::measure(&blk) 
 | 
			
		||||
      self + Benchmark::measure(&blk)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    # An in-place version of #add.
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    def add!
 | 
			
		||||
      t = Benchmark::measure(&blk) 
 | 
			
		||||
      t = Benchmark::measure(&blk)
 | 
			
		||||
      @utime  = utime + t.utime
 | 
			
		||||
      @stime  = stime + t.stime
 | 
			
		||||
      @cutime = cutime + t.cutime
 | 
			
		||||
| 
						 | 
				
			
			@ -450,32 +450,32 @@ module Benchmark
 | 
			
		|||
      self
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    # Returns a new Tms object obtained by memberwise summation
 | 
			
		||||
    # of the individual times for this Tms object with those of the other
 | 
			
		||||
    # Tms object.
 | 
			
		||||
    # This method and #/() are useful for taking statistics. 
 | 
			
		||||
    # 
 | 
			
		||||
    # This method and #/() are useful for taking statistics.
 | 
			
		||||
    #
 | 
			
		||||
    def +(other); memberwise(:+, other) end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    #
 | 
			
		||||
    # Returns a new Tms object obtained by memberwise subtraction
 | 
			
		||||
    # of the individual times for the other Tms object from those of this
 | 
			
		||||
    # Tms object.
 | 
			
		||||
    #
 | 
			
		||||
    def -(other); memberwise(:-, other) end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    #
 | 
			
		||||
    # Returns a new Tms object obtained by memberwise multiplication
 | 
			
		||||
    # of the individual times for this Tms object by _x_.
 | 
			
		||||
    #
 | 
			
		||||
    def *(x); memberwise(:*, x) end
 | 
			
		||||
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    # Returns a new Tms object obtained by memberwise division
 | 
			
		||||
    # of the individual times for this Tms object by _x_.
 | 
			
		||||
    # This method and #+() are useful for taking statistics. 
 | 
			
		||||
    # 
 | 
			
		||||
    # This method and #+() are useful for taking statistics.
 | 
			
		||||
    #
 | 
			
		||||
    def /(x); memberwise(:/, x) end
 | 
			
		||||
 | 
			
		||||
    #
 | 
			
		||||
| 
						 | 
				
			
			@ -486,15 +486,15 @@ module Benchmark
 | 
			
		|||
    #
 | 
			
		||||
    # <tt>%u</tt>::     Replaced by the user CPU time, as reported by Tms#utime.
 | 
			
		||||
    # <tt>%y</tt>::     Replaced by the system CPU time, as reported by #stime (Mnemonic: y of "s*y*stem")
 | 
			
		||||
    # <tt>%U</tt>::     Replaced by the children's user CPU time, as reported by Tms#cutime 
 | 
			
		||||
    # <tt>%U</tt>::     Replaced by the children's user CPU time, as reported by Tms#cutime
 | 
			
		||||
    # <tt>%Y</tt>::     Replaced by the children's system CPU time, as reported by Tms#cstime
 | 
			
		||||
    # <tt>%t</tt>::     Replaced by the total CPU time, as reported by Tms#total
 | 
			
		||||
    # <tt>%r</tt>::     Replaced by the elapsed real time, as reported by Tms#real
 | 
			
		||||
    # <tt>%n</tt>::     Replaced by the label string, as reported by Tms#label (Mnemonic: n of "*n*ame")
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    # If _fmtstr_ is not given, FMTSTR is used as default value, detailing the
 | 
			
		||||
    # user, system and real elapsed time.
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    def format(arg0 = nil, *args)
 | 
			
		||||
      fmtstr = (arg0 || FMTSTR).dup
 | 
			
		||||
      fmtstr.gsub!(/(%[-+\.\d]*)n/){"#{$1}s" % label}
 | 
			
		||||
| 
						 | 
				
			
			@ -507,19 +507,19 @@ module Benchmark
 | 
			
		|||
      arg0 ? Kernel::format(fmtstr, *args) : fmtstr
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    # Same as #format.
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    def to_s
 | 
			
		||||
      format
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    # Returns a new 6-element array, consisting of the
 | 
			
		||||
    # label, user CPU time, system CPU time, children's
 | 
			
		||||
    # user CPU time, children's system CPU time and elapsed
 | 
			
		||||
    # real time.
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    def to_a
 | 
			
		||||
      [@label, @utime, @stime, @cutime, @cstime, @real]
 | 
			
		||||
    end
 | 
			
		||||
| 
						 | 
				
			
			@ -548,7 +548,7 @@ module Benchmark
 | 
			
		|||
  # The default caption string (heading above the output times).
 | 
			
		||||
  CAPTION = Benchmark::Tms::CAPTION
 | 
			
		||||
 | 
			
		||||
  # The default format string used to display times.  See also Benchmark::Tms#format. 
 | 
			
		||||
  # The default format string used to display times.  See also Benchmark::Tms#format.
 | 
			
		||||
  FMTSTR = Benchmark::Tms::FMTSTR
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										248
									
								
								lib/cgi.rb
									
										
									
									
									
								
							
							
						
						
									
										248
									
								
								lib/cgi.rb
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1,14 +1,14 @@
 | 
			
		|||
# 
 | 
			
		||||
#
 | 
			
		||||
# cgi.rb - cgi support library
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
# Copyright (C) 2000  Network Applied Communication Laboratory, Inc.
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
# Copyright (C) 2000  Information-technology Promotion Agency, Japan
 | 
			
		||||
#
 | 
			
		||||
# Author: Wakou Aoyama <wakou@ruby-lang.org>
 | 
			
		||||
#
 | 
			
		||||
# Documentation: Wakou Aoyama (RDoc'd and embellished by William Webber) 
 | 
			
		||||
# 
 | 
			
		||||
# Documentation: Wakou Aoyama (RDoc'd and embellished by William Webber)
 | 
			
		||||
#
 | 
			
		||||
# == Overview
 | 
			
		||||
#
 | 
			
		||||
# The Common Gateway Interface (CGI) is a simple protocol
 | 
			
		||||
| 
						 | 
				
			
			@ -18,7 +18,7 @@
 | 
			
		|||
# parameters of the request passed in either in the
 | 
			
		||||
# environment (GET) or via $stdin (POST), and everything
 | 
			
		||||
# it prints to $stdout is returned to the client.
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
# This file holds the +CGI+ class.  This class provides
 | 
			
		||||
# functionality for retrieving HTTP request parameters,
 | 
			
		||||
# managing cookies, and generating HTML output.  See the
 | 
			
		||||
| 
						 | 
				
			
			@ -77,18 +77,18 @@ require 'English'
 | 
			
		|||
#
 | 
			
		||||
#
 | 
			
		||||
# For each of these variables, there is a corresponding attribute with the
 | 
			
		||||
# same name, except all lower case and without a preceding HTTP_.  
 | 
			
		||||
# same name, except all lower case and without a preceding HTTP_.
 | 
			
		||||
# +content_length+ and +server_port+ are integers; the rest are strings.
 | 
			
		||||
#
 | 
			
		||||
# === Parameters
 | 
			
		||||
#
 | 
			
		||||
# The method #params() returns a hash of all parameters in the request as
 | 
			
		||||
# name/value-list pairs, where the value-list is an Array of one or more
 | 
			
		||||
# values.  The CGI object itself also behaves as a hash of parameter names 
 | 
			
		||||
# to values, but only returns a single value (as a String) for each 
 | 
			
		||||
# values.  The CGI object itself also behaves as a hash of parameter names
 | 
			
		||||
# to values, but only returns a single value (as a String) for each
 | 
			
		||||
# parameter name.
 | 
			
		||||
#
 | 
			
		||||
# For instance, suppose the request contains the parameter 
 | 
			
		||||
# For instance, suppose the request contains the parameter
 | 
			
		||||
# "favourite_colours" with the multiple values "blue" and "green".  The
 | 
			
		||||
# following behaviour would occur:
 | 
			
		||||
#
 | 
			
		||||
| 
						 | 
				
			
			@ -107,7 +107,7 @@ require 'English'
 | 
			
		|||
#
 | 
			
		||||
# === Multipart requests
 | 
			
		||||
#
 | 
			
		||||
# If a request's method is POST and its content type is multipart/form-data, 
 | 
			
		||||
# If a request's method is POST and its content type is multipart/form-data,
 | 
			
		||||
# then it may contain uploaded files.  These are stored by the QueryExtension
 | 
			
		||||
# module in the parameters of the request.  The parameter name is the name
 | 
			
		||||
# attribute of the file input field, as usual.  However, the value is not
 | 
			
		||||
| 
						 | 
				
			
			@ -138,7 +138,7 @@ require 'English'
 | 
			
		|||
#
 | 
			
		||||
# Each HTML element has a corresponding method for generating that
 | 
			
		||||
# element as a String.  The name of this method is the same as that
 | 
			
		||||
# of the element, all lowercase.  The attributes of the element are 
 | 
			
		||||
# of the element, all lowercase.  The attributes of the element are
 | 
			
		||||
# passed in as a hash, and the body as a no-argument block that evaluates
 | 
			
		||||
# to a String.  The HTML generation module knows which elements are
 | 
			
		||||
# always empty, and silently drops any passed-in body.  It also knows
 | 
			
		||||
| 
						 | 
				
			
			@ -152,57 +152,57 @@ require 'English'
 | 
			
		|||
# as arguments, rather than via a hash.
 | 
			
		||||
#
 | 
			
		||||
# == Examples of use
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
# === Get form values
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
#   require "cgi"
 | 
			
		||||
#   cgi = CGI.new
 | 
			
		||||
#   value = cgi['field_name']   # <== value string for 'field_name'
 | 
			
		||||
#     # if not 'field_name' included, then return "".
 | 
			
		||||
#   fields = cgi.keys            # <== array of field names
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
#   # returns true if form has 'field_name'
 | 
			
		||||
#   cgi.has_key?('field_name')
 | 
			
		||||
#   cgi.has_key?('field_name')
 | 
			
		||||
#   cgi.include?('field_name')
 | 
			
		||||
# 
 | 
			
		||||
# CAUTION! cgi['field_name'] returned an Array with the old 
 | 
			
		||||
#
 | 
			
		||||
# CAUTION! cgi['field_name'] returned an Array with the old
 | 
			
		||||
# cgi.rb(included in ruby 1.6)
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
# === Get form values as hash
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
#   require "cgi"
 | 
			
		||||
#   cgi = CGI.new
 | 
			
		||||
#   params = cgi.params
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
# cgi.params is a hash.
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
#   cgi.params['new_field_name'] = ["value"]  # add new param
 | 
			
		||||
#   cgi.params['field_name'] = ["new_value"]  # change value
 | 
			
		||||
#   cgi.params.delete('field_name')           # delete param
 | 
			
		||||
#   cgi.params.clear                          # delete all params
 | 
			
		||||
# 
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
# === Save form values to file
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
#   require "pstore"
 | 
			
		||||
#   db = PStore.new("query.db")
 | 
			
		||||
#   db.transaction do
 | 
			
		||||
#     db["params"] = cgi.params
 | 
			
		||||
#   end
 | 
			
		||||
# 
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
# === Restore form values from file
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
#   require "pstore"
 | 
			
		||||
#   db = PStore.new("query.db")
 | 
			
		||||
#   db.transaction do
 | 
			
		||||
#     cgi.params = db["params"]
 | 
			
		||||
#   end
 | 
			
		||||
# 
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
# === Get multipart form values
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
#   require "cgi"
 | 
			
		||||
#   cgi = CGI.new
 | 
			
		||||
#   value = cgi['field_name']   # <== value string for 'field_name'
 | 
			
		||||
| 
						 | 
				
			
			@ -210,37 +210,37 @@ require 'English'
 | 
			
		|||
#   value.local_path            # <== path to local file of value
 | 
			
		||||
#   value.original_filename     # <== original filename of value
 | 
			
		||||
#   value.content_type          # <== content_type of value
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
# and value has StringIO or Tempfile class methods.
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
# === Get cookie values
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
#   require "cgi"
 | 
			
		||||
#   cgi = CGI.new
 | 
			
		||||
#   values = cgi.cookies['name']  # <== array of 'name'
 | 
			
		||||
#     # if not 'name' included, then return [].
 | 
			
		||||
#   names = cgi.cookies.keys      # <== array of cookie names
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
# and cgi.cookies is a hash.
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
# === Get cookie objects
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
#   require "cgi"
 | 
			
		||||
#   cgi = CGI.new
 | 
			
		||||
#   for name, cookie in cgi.cookies
 | 
			
		||||
#     cookie.expires = Time.now + 30
 | 
			
		||||
#   end
 | 
			
		||||
#   cgi.out("cookie" => cgi.cookies) {"string"}
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
#   cgi.cookies # { "name1" => cookie1, "name2" => cookie2, ... }
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
#   require "cgi"
 | 
			
		||||
#   cgi = CGI.new
 | 
			
		||||
#   cgi.cookies['name'].expires = Time.now + 30
 | 
			
		||||
#   cgi.out("cookie" => cgi.cookies['name']) {"string"}
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
# === Print http header and html string to $DEFAULT_OUTPUT ($>)
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
#   require "cgi"
 | 
			
		||||
#   cgi = CGI.new("html3")  # add HTML generation methods
 | 
			
		||||
#   cgi.out() do
 | 
			
		||||
| 
						 | 
				
			
			@ -264,7 +264,7 @@ require 'English'
 | 
			
		|||
#       end
 | 
			
		||||
#     end
 | 
			
		||||
#   end
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
#   # add HTML generation methods
 | 
			
		||||
#   CGI.new("html3")    # html3.2
 | 
			
		||||
#   CGI.new("html4")    # html4.01 (Strict)
 | 
			
		||||
| 
						 | 
				
			
			@ -286,7 +286,7 @@ class CGI
 | 
			
		|||
 | 
			
		||||
  REVISION = '$Id$' #:nodoc:
 | 
			
		||||
 | 
			
		||||
  NEEDS_BINMODE = true if /WIN/ni.match(RUBY_PLATFORM) 
 | 
			
		||||
  NEEDS_BINMODE = true if /WIN/ni.match(RUBY_PLATFORM)
 | 
			
		||||
 | 
			
		||||
  # Path separators in different environments.
 | 
			
		||||
  PATH_SEPARATOR = {'UNIX'=>'/', 'WINDOWS'=>'\\', 'MACINTOSH'=>':'}
 | 
			
		||||
| 
						 | 
				
			
			@ -321,7 +321,7 @@ class CGI
 | 
			
		|||
 | 
			
		||||
  # :startdoc:
 | 
			
		||||
 | 
			
		||||
  def env_table 
 | 
			
		||||
  def env_table
 | 
			
		||||
    ENV
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -431,7 +431,7 @@ class CGI
 | 
			
		|||
  #   print CGI::unescapeElement(
 | 
			
		||||
  #           CGI::escapeHTML('<BR><A HREF="url"></A>'), "A", "IMG")
 | 
			
		||||
  #     # "<BR><A HREF="url"></A>"
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  #   print CGI::unescapeElement(
 | 
			
		||||
  #           CGI::escapeHTML('<BR><A HREF="url"></A>'), ["A", "IMG"])
 | 
			
		||||
  #     # "<BR><A HREF="url"></A>"
 | 
			
		||||
| 
						 | 
				
			
			@ -475,7 +475,7 @@ class CGI
 | 
			
		|||
  # status:: the HTTP status code, returned as the Status header.  See the
 | 
			
		||||
  #          list of available status codes below.
 | 
			
		||||
  # server:: the server software, returned as the Server header.
 | 
			
		||||
  # connection:: the connection type, returned as the Connection header (for 
 | 
			
		||||
  # connection:: the connection type, returned as the Connection header (for
 | 
			
		||||
  #              instance, "close".
 | 
			
		||||
  # length:: the length of the content that will be sent, returned as the
 | 
			
		||||
  #          Content-Length header.
 | 
			
		||||
| 
						 | 
				
			
			@ -485,19 +485,19 @@ class CGI
 | 
			
		|||
  #           object, returned as the Expires header.
 | 
			
		||||
  # cookie:: a cookie or cookies, returned as one or more Set-Cookie headers.
 | 
			
		||||
  #          The value can be the literal string of the cookie; a CGI::Cookie
 | 
			
		||||
  #          object; an Array of literal cookie strings or Cookie objects; or a 
 | 
			
		||||
  #          object; an Array of literal cookie strings or Cookie objects; or a
 | 
			
		||||
  #          hash all of whose values are literal cookie strings or Cookie objects.
 | 
			
		||||
  #          These cookies are in addition to the cookies held in the
 | 
			
		||||
  #          @output_cookies field.
 | 
			
		||||
  #
 | 
			
		||||
  # Other header lines can also be set; they are appended as key: value.
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  #   header
 | 
			
		||||
  #     # Content-Type: text/html
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  #   header("text/plain")
 | 
			
		||||
  #     # Content-Type: text/plain
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  #   header("nph"        => true,
 | 
			
		||||
  #          "status"     => "OK",  # == "200 OK"
 | 
			
		||||
  #            # "status"     => "200 GOOD",
 | 
			
		||||
| 
						 | 
				
			
			@ -512,9 +512,9 @@ class CGI
 | 
			
		|||
  #          "cookie"     => [cookie1, cookie2],
 | 
			
		||||
  #          "my_header1" => "my_value"
 | 
			
		||||
  #          "my_header2" => "my_value")
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  # The status codes are:
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  #   "OK"                  --> "200 OK"
 | 
			
		||||
  #   "PARTIAL_CONTENT"     --> "206 Partial Content"
 | 
			
		||||
  #   "MULTIPLE_CHOICES"    --> "300 Multiple Choices"
 | 
			
		||||
| 
						 | 
				
			
			@ -533,8 +533,8 @@ class CGI
 | 
			
		|||
  #   "NOT_IMPLEMENTED"     --> "501 Method Not Implemented"
 | 
			
		||||
  #   "BAD_GATEWAY"         --> "502 Bad Gateway"
 | 
			
		||||
  #   "VARIANT_ALSO_VARIES" --> "506 Variant Also Negotiates"
 | 
			
		||||
  # 
 | 
			
		||||
  # This method does not perform charset conversion. 
 | 
			
		||||
  #
 | 
			
		||||
  # This method does not perform charset conversion.
 | 
			
		||||
  #
 | 
			
		||||
  def header(options = "text/html")
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -670,13 +670,13 @@ class CGI
 | 
			
		|||
  #     # Content-Length: 6
 | 
			
		||||
  #     #
 | 
			
		||||
  #     # string
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  #   cgi.out("text/plain") { "string" }
 | 
			
		||||
  #     # Content-Type: text/plain
 | 
			
		||||
  #     # Content-Length: 6
 | 
			
		||||
  #     #
 | 
			
		||||
  #     # string
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  #   cgi.out("nph"        => true,
 | 
			
		||||
  #           "status"     => "OK",  # == "200 OK"
 | 
			
		||||
  #           "server"     => ENV['SERVER_SOFTWARE'],
 | 
			
		||||
| 
						 | 
				
			
			@ -689,16 +689,16 @@ class CGI
 | 
			
		|||
  #           "cookie"     => [cookie1, cookie2],
 | 
			
		||||
  #           "my_header1" => "my_value",
 | 
			
		||||
  #           "my_header2" => "my_value") { "string" }
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  # Content-Length is automatically calculated from the size of
 | 
			
		||||
  # the String returned by the content block.
 | 
			
		||||
  #
 | 
			
		||||
  # If ENV['REQUEST_METHOD'] == "HEAD", then only the header
 | 
			
		||||
  # is outputted (the content block is still required, but it
 | 
			
		||||
  # is ignored).
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  # If the charset is "iso-2022-jp" or "euc-jp" or "shift_jis" then
 | 
			
		||||
  # the content is converted to this charset, and the language is set 
 | 
			
		||||
  # the content is converted to this charset, and the language is set
 | 
			
		||||
  # to "ja".
 | 
			
		||||
  def out(options = "text/html") # :yield:
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -755,16 +755,16 @@ class CGI
 | 
			
		|||
  #                              'expires' => Time.now, # optional
 | 
			
		||||
  #                              'secure'  => true      # optional
 | 
			
		||||
  #                             )
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  #   cgi.out("cookie" => [cookie1, cookie2]) { "string" }
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  #   name    = cookie1.name
 | 
			
		||||
  #   values  = cookie1.value
 | 
			
		||||
  #   path    = cookie1.path
 | 
			
		||||
  #   domain  = cookie1.domain
 | 
			
		||||
  #   expires = cookie1.expires
 | 
			
		||||
  #   secure  = cookie1.secure
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  #   cookie1.name    = 'name'
 | 
			
		||||
  #   cookie1.value   = ['value1', 'value2', ...]
 | 
			
		||||
  #   cookie1.path    = 'path'
 | 
			
		||||
| 
						 | 
				
			
			@ -787,7 +787,7 @@ class CGI
 | 
			
		|||
    # domain:: the domain for which this cookie applies.
 | 
			
		||||
    # expires:: the time at which this cookie expires, as a +Time+ object.
 | 
			
		||||
    # secure:: whether this cookie is a secure cookie or not (default to
 | 
			
		||||
    #          false).  Secure cookies are only transmitted to HTTPS 
 | 
			
		||||
    #          false).  Secure cookies are only transmitted to HTTPS
 | 
			
		||||
    #          servers.
 | 
			
		||||
    #
 | 
			
		||||
    # These keywords correspond to attributes of the cookie object.
 | 
			
		||||
| 
						 | 
				
			
			@ -914,7 +914,7 @@ class CGI
 | 
			
		|||
 | 
			
		||||
  # Mixin module. It provides the follow functionality groups:
 | 
			
		||||
  #
 | 
			
		||||
  # 1. Access to CGI environment variables as methods.  See 
 | 
			
		||||
  # 1. Access to CGI environment variables as methods.  See
 | 
			
		||||
  #    documentation to the CGI class for a list of these variables.
 | 
			
		||||
  #
 | 
			
		||||
  # 2. Access to cookies, including the cookies attribute.
 | 
			
		||||
| 
						 | 
				
			
			@ -1050,7 +1050,7 @@ class CGI
 | 
			
		|||
	    (not /MSIE/ni.match(env_table['HTTP_USER_AGENT']))
 | 
			
		||||
	  filename = CGI::unescape(filename)
 | 
			
		||||
	end
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        /Content-Type: ([^\s]*)/ni.match(head)
 | 
			
		||||
        content_type = ($1 or "")
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1169,7 +1169,7 @@ class CGI
 | 
			
		|||
 | 
			
		||||
    # Get the value for the parameter with a given key.
 | 
			
		||||
    #
 | 
			
		||||
    # If the parameter has multiple values, only the first will be 
 | 
			
		||||
    # If the parameter has multiple values, only the first will be
 | 
			
		||||
    # retrieved; use #params() to get the array of values.
 | 
			
		||||
    def [](key)
 | 
			
		||||
      params = @params[key]
 | 
			
		||||
| 
						 | 
				
			
			@ -1216,7 +1216,7 @@ class CGI
 | 
			
		|||
  #     #   <BODY>
 | 
			
		||||
  #     #   </BODY>
 | 
			
		||||
  #     # </HTML>
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  #   print CGI::pretty("<HTML><BODY></BODY></HTML>", "\t")
 | 
			
		||||
  #     # <HTML>
 | 
			
		||||
  #     #         <BODY>
 | 
			
		||||
| 
						 | 
				
			
			@ -1301,7 +1301,7 @@ class CGI
 | 
			
		|||
  # Modules Http3, Http4, etc., contain more basic HTML-generation methods
 | 
			
		||||
  # (:title, :center, etc.).
 | 
			
		||||
  #
 | 
			
		||||
  # See class CGI for a detailed example. 
 | 
			
		||||
  # See class CGI for a detailed example.
 | 
			
		||||
  #
 | 
			
		||||
  module HtmlExtension
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1334,7 +1334,7 @@ class CGI
 | 
			
		|||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    # Generate a Document Base URI element as a String. 
 | 
			
		||||
    # Generate a Document Base URI element as a String.
 | 
			
		||||
    #
 | 
			
		||||
    # +href+ can either by a string, giving the base URL for the HREF
 | 
			
		||||
    # attribute, or it can be a has of the element's attributes.
 | 
			
		||||
| 
						 | 
				
			
			@ -1414,10 +1414,10 @@ class CGI
 | 
			
		|||
    #
 | 
			
		||||
    #   checkbox("name")
 | 
			
		||||
    #     # = checkbox("NAME" => "name")
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   checkbox("name", "value")
 | 
			
		||||
    #     # = checkbox("NAME" => "name", "VALUE" => "value")
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   checkbox("name", "value", true)
 | 
			
		||||
    #     # = checkbox("NAME" => "name", "VALUE" => "value", "CHECKED" => true)
 | 
			
		||||
    def checkbox(name = "", value = nil, checked = nil)
 | 
			
		||||
| 
						 | 
				
			
			@ -1455,23 +1455,23 @@ class CGI
 | 
			
		|||
    #     # <INPUT TYPE="checkbox" NAME="name" VALUE="foo">foo
 | 
			
		||||
    #     # <INPUT TYPE="checkbox" NAME="name" VALUE="bar">bar
 | 
			
		||||
    #     # <INPUT TYPE="checkbox" NAME="name" VALUE="baz">baz
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   checkbox_group("name", ["foo"], ["bar", true], "baz")
 | 
			
		||||
    #     # <INPUT TYPE="checkbox" NAME="name" VALUE="foo">foo
 | 
			
		||||
    #     # <INPUT TYPE="checkbox" CHECKED NAME="name" VALUE="bar">bar
 | 
			
		||||
    #     # <INPUT TYPE="checkbox" NAME="name" VALUE="baz">baz
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   checkbox_group("name", ["1", "Foo"], ["2", "Bar", true], "Baz")
 | 
			
		||||
    #     # <INPUT TYPE="checkbox" NAME="name" VALUE="1">Foo
 | 
			
		||||
    #     # <INPUT TYPE="checkbox" CHECKED NAME="name" VALUE="2">Bar
 | 
			
		||||
    #     # <INPUT TYPE="checkbox" NAME="name" VALUE="Baz">Baz
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   checkbox_group("NAME" => "name",
 | 
			
		||||
    #                    "VALUES" => ["foo", "bar", "baz"])
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   checkbox_group("NAME" => "name",
 | 
			
		||||
    #                    "VALUES" => [["foo"], ["bar", true], "baz"])
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   checkbox_group("NAME" => "name",
 | 
			
		||||
    #                    "VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"])
 | 
			
		||||
    def checkbox_group(name = "", *values)
 | 
			
		||||
| 
						 | 
				
			
			@ -1507,13 +1507,13 @@ class CGI
 | 
			
		|||
    #
 | 
			
		||||
    #   file_field("name")
 | 
			
		||||
    #     # <INPUT TYPE="file" NAME="name" SIZE="20">
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   file_field("name", 40)
 | 
			
		||||
    #     # <INPUT TYPE="file" NAME="name" SIZE="40">
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   file_field("name", 40, 100)
 | 
			
		||||
    #     # <INPUT TYPE="file" NAME="name" SIZE="40" MAXLENGTH="100">
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   file_field("NAME" => "name", "SIZE" => 40)
 | 
			
		||||
    #     # <INPUT TYPE="file" NAME="name" SIZE="40">
 | 
			
		||||
    def file_field(name = "", size = 20, maxlength = nil)
 | 
			
		||||
| 
						 | 
				
			
			@ -1533,7 +1533,7 @@ class CGI
 | 
			
		|||
    #
 | 
			
		||||
    # +method+ should be either "get" or "post", and defaults to the latter.
 | 
			
		||||
    # +action+ defaults to the current CGI script name.  +enctype+
 | 
			
		||||
    # defaults to "application/x-www-form-urlencoded".  
 | 
			
		||||
    # defaults to "application/x-www-form-urlencoded".
 | 
			
		||||
    #
 | 
			
		||||
    # Alternatively, the attributes can be specified as a hash.
 | 
			
		||||
    #
 | 
			
		||||
| 
						 | 
				
			
			@ -1541,19 +1541,19 @@ class CGI
 | 
			
		|||
    #
 | 
			
		||||
    #   form{ "string" }
 | 
			
		||||
    #     # <FORM METHOD="post" ENCTYPE="application/x-www-form-urlencoded">string</FORM>
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   form("get") { "string" }
 | 
			
		||||
    #     # <FORM METHOD="get" ENCTYPE="application/x-www-form-urlencoded">string</FORM>
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   form("get", "url") { "string" }
 | 
			
		||||
    #     # <FORM METHOD="get" ACTION="url" ENCTYPE="application/x-www-form-urlencoded">string</FORM>
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   form("METHOD" => "post", "ENCTYPE" => "enctype") { "string" }
 | 
			
		||||
    #     # <FORM METHOD="post" ENCTYPE="enctype">string</FORM>
 | 
			
		||||
    def form(method = "post", action = script_name, enctype = "application/x-www-form-urlencoded")
 | 
			
		||||
      attributes = if method.kind_of?(String)
 | 
			
		||||
                     { "METHOD" => method, "ACTION" => action,
 | 
			
		||||
                       "ENCTYPE" => enctype } 
 | 
			
		||||
                       "ENCTYPE" => enctype }
 | 
			
		||||
                   else
 | 
			
		||||
                     unless method.has_key?("METHOD")
 | 
			
		||||
                       method["METHOD"] = "post"
 | 
			
		||||
| 
						 | 
				
			
			@ -1585,10 +1585,10 @@ class CGI
 | 
			
		|||
    #
 | 
			
		||||
    #   hidden("name")
 | 
			
		||||
    #     # <INPUT TYPE="hidden" NAME="name">
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   hidden("name", "value")
 | 
			
		||||
    #     # <INPUT TYPE="hidden" NAME="name" VALUE="value">
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   hidden("NAME" => "name", "VALUE" => "reset", "ID" => "foo")
 | 
			
		||||
    #     # <INPUT TYPE="hidden" NAME="name" VALUE="value" ID="foo">
 | 
			
		||||
    def hidden(name = "", value = nil)
 | 
			
		||||
| 
						 | 
				
			
			@ -1611,36 +1611,36 @@ class CGI
 | 
			
		|||
    # should include the entire text of this tag, including angle brackets.
 | 
			
		||||
    #
 | 
			
		||||
    # The body of the html element is supplied as a block.
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   html{ "string" }
 | 
			
		||||
    #     # <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><HTML>string</HTML>
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   html("LANG" => "ja") { "string" }
 | 
			
		||||
    #     # <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><HTML LANG="ja">string</HTML>
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   html("DOCTYPE" => false) { "string" }
 | 
			
		||||
    #     # <HTML>string</HTML>
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   html("DOCTYPE" => '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">') { "string" }
 | 
			
		||||
    #     # <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"><HTML>string</HTML>
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   html("PRETTY" => "  ") { "<BODY></BODY>" }
 | 
			
		||||
    #     # <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
 | 
			
		||||
    #     # <HTML>
 | 
			
		||||
    #     #   <BODY>
 | 
			
		||||
    #     #   </BODY>
 | 
			
		||||
    #     # </HTML>
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   html("PRETTY" => "\t") { "<BODY></BODY>" }
 | 
			
		||||
    #     # <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
 | 
			
		||||
    #     # <HTML>
 | 
			
		||||
    #     #         <BODY>
 | 
			
		||||
    #     #         </BODY>
 | 
			
		||||
    #     # </HTML>
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   html("PRETTY") { "<BODY></BODY>" }
 | 
			
		||||
    #     # = html("PRETTY" => "  ") { "<BODY></BODY>" }
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   html(if $VERBOSE then "PRETTY" end) { "HTML string" }
 | 
			
		||||
    #
 | 
			
		||||
    def html(attributes = {}) # :yield:
 | 
			
		||||
| 
						 | 
				
			
			@ -1679,17 +1679,17 @@ class CGI
 | 
			
		|||
 | 
			
		||||
    # Generate an Image Button Input element as a string.
 | 
			
		||||
    #
 | 
			
		||||
    # +src+ is the URL of the image to use for the button.  +name+ 
 | 
			
		||||
    # +src+ is the URL of the image to use for the button.  +name+
 | 
			
		||||
    # is the input name.  +alt+ is the alternative text for the image.
 | 
			
		||||
    #
 | 
			
		||||
    # Alternatively, the attributes can be specified as a hash.
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   image_button("url")
 | 
			
		||||
    #     # <INPUT TYPE="image" SRC="url">
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   image_button("url", "name", "string")
 | 
			
		||||
    #     # <INPUT TYPE="image" SRC="url" NAME="name" ALT="string">
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   image_button("SRC" => "url", "ATL" => "string")
 | 
			
		||||
    #     # <INPUT TYPE="image" SRC="url" ALT="string">
 | 
			
		||||
    def image_button(src = "", name = nil, alt = nil)
 | 
			
		||||
| 
						 | 
				
			
			@ -1715,7 +1715,7 @@ class CGI
 | 
			
		|||
    #
 | 
			
		||||
    #   img("src", "alt", 100, 50)
 | 
			
		||||
    #     # <IMG SRC="src" ALT="alt" WIDTH="100" HEIGHT="50">
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   img("SRC" => "src", "ALT" => "alt", "WIDTH" => 100, "HEIGHT" => 50)
 | 
			
		||||
    #     # <IMG SRC="src" ALT="alt" WIDTH="100" HEIGHT="50">
 | 
			
		||||
    def img(src = "", alt = "", width = nil, height = nil)
 | 
			
		||||
| 
						 | 
				
			
			@ -1741,15 +1741,15 @@ class CGI
 | 
			
		|||
    #
 | 
			
		||||
    #   multipart_form{ "string" }
 | 
			
		||||
    #     # <FORM METHOD="post" ENCTYPE="multipart/form-data">string</FORM>
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   multipart_form("url") { "string" }
 | 
			
		||||
    #     # <FORM METHOD="post" ACTION="url" ENCTYPE="multipart/form-data">string</FORM>
 | 
			
		||||
    def multipart_form(action = nil, enctype = "multipart/form-data")
 | 
			
		||||
      attributes = if action == nil
 | 
			
		||||
                     { "METHOD" => "post", "ENCTYPE" => enctype } 
 | 
			
		||||
                     { "METHOD" => "post", "ENCTYPE" => enctype }
 | 
			
		||||
                   elsif action.kind_of?(String)
 | 
			
		||||
                     { "METHOD" => "post", "ACTION" => action,
 | 
			
		||||
                       "ENCTYPE" => enctype } 
 | 
			
		||||
                       "ENCTYPE" => enctype }
 | 
			
		||||
                   else
 | 
			
		||||
                     unless action.has_key?("METHOD")
 | 
			
		||||
                       action["METHOD"] = "post"
 | 
			
		||||
| 
						 | 
				
			
			@ -1777,13 +1777,13 @@ class CGI
 | 
			
		|||
    #
 | 
			
		||||
    #   password_field("name")
 | 
			
		||||
    #     # <INPUT TYPE="password" NAME="name" SIZE="40">
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   password_field("name", "value")
 | 
			
		||||
    #     # <INPUT TYPE="password" NAME="name" VALUE="value" SIZE="40">
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   password_field("password", "value", 80, 200)
 | 
			
		||||
    #     # <INPUT TYPE="password" NAME="name" VALUE="value" SIZE="80" MAXLENGTH="200">
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   password_field("NAME" => "name", "VALUE" => "value")
 | 
			
		||||
    #     # <INPUT TYPE="password" NAME="name" VALUE="value">
 | 
			
		||||
    def password_field(name = "", value = nil, size = 40, maxlength = nil)
 | 
			
		||||
| 
						 | 
				
			
			@ -1819,21 +1819,21 @@ class CGI
 | 
			
		|||
    #     #   <OPTION VALUE="bar">bar</OPTION>
 | 
			
		||||
    #     #   <OPTION VALUE="baz">baz</OPTION>
 | 
			
		||||
    #     # </SELECT>
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   popup_menu("name", ["foo"], ["bar", true], "baz")
 | 
			
		||||
    #     # <SELECT NAME="name">
 | 
			
		||||
    #     #   <OPTION VALUE="foo">foo</OPTION>
 | 
			
		||||
    #     #   <OPTION VALUE="bar" SELECTED>bar</OPTION>
 | 
			
		||||
    #     #   <OPTION VALUE="baz">baz</OPTION>
 | 
			
		||||
    #     # </SELECT>
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   popup_menu("name", ["1", "Foo"], ["2", "Bar", true], "Baz")
 | 
			
		||||
    #     # <SELECT NAME="name">
 | 
			
		||||
    #     #   <OPTION VALUE="1">Foo</OPTION>
 | 
			
		||||
    #     #   <OPTION SELECTED VALUE="2">Bar</OPTION>
 | 
			
		||||
    #     #   <OPTION VALUE="Baz">Baz</OPTION>
 | 
			
		||||
    #     # </SELECT>
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   popup_menu("NAME" => "name", "SIZE" => 2, "MULTIPLE" => true,
 | 
			
		||||
    #               "VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"])
 | 
			
		||||
    #     # <SELECT NAME="name" MULTIPLE SIZE="2">
 | 
			
		||||
| 
						 | 
				
			
			@ -1884,10 +1884,10 @@ class CGI
 | 
			
		|||
    #
 | 
			
		||||
    #   radio_button("name", "value")
 | 
			
		||||
    #     # <INPUT TYPE="radio" NAME="name" VALUE="value">
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   radio_button("name", "value", true)
 | 
			
		||||
    #     # <INPUT TYPE="radio" NAME="name" VALUE="value" CHECKED>
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   radio_button("NAME" => "name", "VALUE" => "value", "ID" => "foo")
 | 
			
		||||
    #     # <INPUT TYPE="radio" NAME="name" VALUE="value" ID="foo">
 | 
			
		||||
    def radio_button(name = "", value = nil, checked = nil)
 | 
			
		||||
| 
						 | 
				
			
			@ -1905,28 +1905,28 @@ class CGI
 | 
			
		|||
    #
 | 
			
		||||
    # This works the same as #checkbox_group().  However, it is not valid
 | 
			
		||||
    # to have more than one radiobutton in a group checked.
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   radio_group("name", "foo", "bar", "baz")
 | 
			
		||||
    #     # <INPUT TYPE="radio" NAME="name" VALUE="foo">foo
 | 
			
		||||
    #     # <INPUT TYPE="radio" NAME="name" VALUE="bar">bar
 | 
			
		||||
    #     # <INPUT TYPE="radio" NAME="name" VALUE="baz">baz
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   radio_group("name", ["foo"], ["bar", true], "baz")
 | 
			
		||||
    #     # <INPUT TYPE="radio" NAME="name" VALUE="foo">foo
 | 
			
		||||
    #     # <INPUT TYPE="radio" CHECKED NAME="name" VALUE="bar">bar
 | 
			
		||||
    #     # <INPUT TYPE="radio" NAME="name" VALUE="baz">baz
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   radio_group("name", ["1", "Foo"], ["2", "Bar", true], "Baz")
 | 
			
		||||
    #     # <INPUT TYPE="radio" NAME="name" VALUE="1">Foo
 | 
			
		||||
    #     # <INPUT TYPE="radio" CHECKED NAME="name" VALUE="2">Bar
 | 
			
		||||
    #     # <INPUT TYPE="radio" NAME="name" VALUE="Baz">Baz
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   radio_group("NAME" => "name",
 | 
			
		||||
    #                 "VALUES" => ["foo", "bar", "baz"])
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   radio_group("NAME" => "name",
 | 
			
		||||
    #                 "VALUES" => [["foo"], ["bar", true], "baz"])
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   radio_group("NAME" => "name",
 | 
			
		||||
    #                 "VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"])
 | 
			
		||||
    def radio_group(name = "", *values)
 | 
			
		||||
| 
						 | 
				
			
			@ -1958,10 +1958,10 @@ class CGI
 | 
			
		|||
    #
 | 
			
		||||
    #   reset
 | 
			
		||||
    #     # <INPUT TYPE="reset">
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   reset("reset")
 | 
			
		||||
    #     # <INPUT TYPE="reset" VALUE="reset">
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   reset("VALUE" => "reset", "ID" => "foo")
 | 
			
		||||
    #     # <INPUT TYPE="reset" VALUE="reset" ID="foo">
 | 
			
		||||
    def reset(value = nil, name = nil)
 | 
			
		||||
| 
						 | 
				
			
			@ -1985,13 +1985,13 @@ class CGI
 | 
			
		|||
    #
 | 
			
		||||
    #   submit
 | 
			
		||||
    #     # <INPUT TYPE="submit">
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   submit("ok")
 | 
			
		||||
    #     # <INPUT TYPE="submit" VALUE="ok">
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   submit("ok", "button1")
 | 
			
		||||
    #     # <INPUT TYPE="submit" VALUE="ok" NAME="button1">
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   submit("VALUE" => "ok", "NAME" => "button1", "ID" => "foo")
 | 
			
		||||
    #     # <INPUT TYPE="submit" VALUE="ok" NAME="button1" ID="foo">
 | 
			
		||||
    def submit(value = nil, name = nil)
 | 
			
		||||
| 
						 | 
				
			
			@ -2014,16 +2014,16 @@ class CGI
 | 
			
		|||
    #
 | 
			
		||||
    #   text_field("name")
 | 
			
		||||
    #     # <INPUT TYPE="text" NAME="name" SIZE="40">
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   text_field("name", "value")
 | 
			
		||||
    #     # <INPUT TYPE="text" NAME="name" VALUE="value" SIZE="40">
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   text_field("name", "value", 80)
 | 
			
		||||
    #     # <INPUT TYPE="text" NAME="name" VALUE="value" SIZE="80">
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   text_field("name", "value", 80, 200)
 | 
			
		||||
    #     # <INPUT TYPE="text" NAME="name" VALUE="value" SIZE="80" MAXLENGTH="200">
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    #   text_field("NAME" => "name", "VALUE" => "value")
 | 
			
		||||
    #     # <INPUT TYPE="text" NAME="name" VALUE="value">
 | 
			
		||||
    def text_field(name = "", value = nil, size = 40, maxlength = nil)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,7 +13,7 @@
 | 
			
		|||
#
 | 
			
		||||
# This file provides the +CGI::Session+ class, which provides session
 | 
			
		||||
# support for CGI scripts.  A session is a sequence of HTTP requests
 | 
			
		||||
# and responses linked together and associated with a single client.  
 | 
			
		||||
# and responses linked together and associated with a single client.
 | 
			
		||||
# Information associated with the session is stored
 | 
			
		||||
# on the server between requests.  A session id is passed between client
 | 
			
		||||
# and server with every request and response, transparently
 | 
			
		||||
| 
						 | 
				
			
			@ -28,7 +28,7 @@ require 'tmpdir'
 | 
			
		|||
 | 
			
		||||
class CGI
 | 
			
		||||
 | 
			
		||||
  # Class representing an HTTP session.  See documentation for the file 
 | 
			
		||||
  # Class representing an HTTP session.  See documentation for the file
 | 
			
		||||
  # cgi/session.rb for an introduction to HTTP sessions.
 | 
			
		||||
  #
 | 
			
		||||
  # == Lifecycle
 | 
			
		||||
| 
						 | 
				
			
			@ -47,7 +47,7 @@ class CGI
 | 
			
		|||
  # == Setting and retrieving session data.
 | 
			
		||||
  #
 | 
			
		||||
  # The Session class associates data with a session as key-value pairs.
 | 
			
		||||
  # This data can be set and retrieved by indexing the Session instance 
 | 
			
		||||
  # This data can be set and retrieved by indexing the Session instance
 | 
			
		||||
  # using '[]', much the same as hashes (although other hash methods
 | 
			
		||||
  # are not supported).
 | 
			
		||||
  #
 | 
			
		||||
| 
						 | 
				
			
			@ -60,21 +60,21 @@ class CGI
 | 
			
		|||
  #
 | 
			
		||||
  # == Storing session state
 | 
			
		||||
  #
 | 
			
		||||
  # The caller can specify what form of storage to use for the session's 
 | 
			
		||||
  # The caller can specify what form of storage to use for the session's
 | 
			
		||||
  # data with the +database_manager+ option to CGI::Session::new.  The
 | 
			
		||||
  # following storage classes are provided as part of the standard library:
 | 
			
		||||
  #
 | 
			
		||||
  # CGI::Session::FileStore:: stores data as plain text in a flat file.  Only 
 | 
			
		||||
  #                           works with String data.  This is the default 
 | 
			
		||||
  # CGI::Session::FileStore:: stores data as plain text in a flat file.  Only
 | 
			
		||||
  #                           works with String data.  This is the default
 | 
			
		||||
  #                           storage type.
 | 
			
		||||
  # CGI::Session::MemoryStore:: stores data in an in-memory hash.  The data 
 | 
			
		||||
  #                             only persists for as long as the current ruby 
 | 
			
		||||
  # CGI::Session::MemoryStore:: stores data in an in-memory hash.  The data
 | 
			
		||||
  #                             only persists for as long as the current ruby
 | 
			
		||||
  #                             interpreter instance does.
 | 
			
		||||
  # CGI::Session::PStore:: stores data in Marshalled format.  Provided by
 | 
			
		||||
  #                        cgi/session/pstore.rb.  Supports data of any type, 
 | 
			
		||||
  #                        cgi/session/pstore.rb.  Supports data of any type,
 | 
			
		||||
  #                        and provides file-locking and transaction support.
 | 
			
		||||
  #
 | 
			
		||||
  # Custom storage types can also be created by defining a class with 
 | 
			
		||||
  # Custom storage types can also be created by defining a class with
 | 
			
		||||
  # the following methods:
 | 
			
		||||
  #
 | 
			
		||||
  #    new(session, options)
 | 
			
		||||
| 
						 | 
				
			
			@ -99,14 +99,14 @@ class CGI
 | 
			
		|||
  # The simplest way to do this is via cookies.  The CGI::Session class
 | 
			
		||||
  # provides transparent support for session id communication via cookies
 | 
			
		||||
  # if the client has cookies enabled.
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  # If the client has cookies disabled, the session id must be included
 | 
			
		||||
  # as a parameter of all requests sent by the client to the server.  The
 | 
			
		||||
  # CGI::Session class in conjunction with the CGI class will transparently
 | 
			
		||||
  # add the session id as a hidden input field to all forms generated
 | 
			
		||||
  # using the CGI#form() HTML generation method.  No built-in support is
 | 
			
		||||
  # provided for other mechanisms, such as URL re-writing.  The caller is
 | 
			
		||||
  # responsible for extracting the session id from the session_id 
 | 
			
		||||
  # responsible for extracting the session id from the session_id
 | 
			
		||||
  # attribute and manually encoding it in URLs and adding it as a hidden
 | 
			
		||||
  # input to HTML forms created by other mechanisms.  Also, session expiry
 | 
			
		||||
  # is not automatically handled.
 | 
			
		||||
| 
						 | 
				
			
			@ -124,10 +124,10 @@ class CGI
 | 
			
		|||
  #   session = CGI::Session.new(cgi,
 | 
			
		||||
  #       'database_manager' => CGI::Session::PStore,  # use PStore
 | 
			
		||||
  #       'session_key' => '_rb_sess_id',              # custom session key
 | 
			
		||||
  #       'session_expires' => Time.now + 30 * 60,     # 30 minute timeout 
 | 
			
		||||
  #       'session_expires' => Time.now + 30 * 60,     # 30 minute timeout
 | 
			
		||||
  #       'prefix' => 'pstore_sid_')                   # PStore option
 | 
			
		||||
  #   if cgi.has_key?('user_name') and cgi['user_name'] != ''
 | 
			
		||||
  #       # coerce to String: cgi[] returns the 
 | 
			
		||||
  #       # coerce to String: cgi[] returns the
 | 
			
		||||
  #       # string-like CGI::QueryExtension::Value
 | 
			
		||||
  #       session['user_name'] = cgi['user_name'].to_s
 | 
			
		||||
  #   elsif !session['user_name']
 | 
			
		||||
| 
						 | 
				
			
			@ -143,11 +143,11 @@ class CGI
 | 
			
		|||
  #   cgi = CGI.new("html4")
 | 
			
		||||
  #
 | 
			
		||||
  #   # We make sure to delete an old session if one exists,
 | 
			
		||||
  #   # not just to free resources, but to prevent the session 
 | 
			
		||||
  #   # not just to free resources, but to prevent the session
 | 
			
		||||
  #   # from being maliciously hijacked later on.
 | 
			
		||||
  #   begin
 | 
			
		||||
  #       session = CGI::Session.new(cgi, 'new_session' => false)      
 | 
			
		||||
  #       session.delete                 
 | 
			
		||||
  #       session = CGI::Session.new(cgi, 'new_session' => false)
 | 
			
		||||
  #       session.delete
 | 
			
		||||
  #   rescue ArgumentError  # if no old session
 | 
			
		||||
  #   end
 | 
			
		||||
  #   session = CGI::Session.new(cgi, 'new_session' => true)
 | 
			
		||||
| 
						 | 
				
			
			@ -172,7 +172,7 @@ class CGI
 | 
			
		|||
    # The session id is an MD5 hash based upon the time,
 | 
			
		||||
    # a random number, and a constant string.  This routine
 | 
			
		||||
    # is used internally for automatically generated
 | 
			
		||||
    # session ids. 
 | 
			
		||||
    # session ids.
 | 
			
		||||
    def create_new_id
 | 
			
		||||
      require 'securerandom'
 | 
			
		||||
      begin
 | 
			
		||||
| 
						 | 
				
			
			@ -205,7 +205,7 @@ class CGI
 | 
			
		|||
    #              it is retrieved from the +session_key+ parameter
 | 
			
		||||
    #              of the request, or automatically generated for
 | 
			
		||||
    #              a new session.
 | 
			
		||||
    # new_session:: if true, force creation of a new session.  If not set, 
 | 
			
		||||
    # new_session:: if true, force creation of a new session.  If not set,
 | 
			
		||||
    #               a new session is only created if none currently
 | 
			
		||||
    #               exists.  If false, a new session is never created,
 | 
			
		||||
    #               and if none currently exists and the +session_id+
 | 
			
		||||
| 
						 | 
				
			
			@ -220,7 +220,7 @@ class CGI
 | 
			
		|||
    # The following options are also recognised, but only apply if the
 | 
			
		||||
    # session id is stored in a cookie.
 | 
			
		||||
    #
 | 
			
		||||
    # session_expires:: the time the current session expires, as a 
 | 
			
		||||
    # session_expires:: the time the current session expires, as a
 | 
			
		||||
    #                   +Time+ object.  If not set, the session will terminate
 | 
			
		||||
    #                   when the user's browser is closed.
 | 
			
		||||
    # session_domain:: the hostname domain for which this session is valid.
 | 
			
		||||
| 
						 | 
				
			
			@ -232,10 +232,10 @@ class CGI
 | 
			
		|||
    # +option+ is also passed on to the session storage class initializer; see
 | 
			
		||||
    # the documentation for each session storage class for the options
 | 
			
		||||
    # they support.
 | 
			
		||||
    #                  
 | 
			
		||||
    #
 | 
			
		||||
    # The retrieved or created session is automatically added to +request+
 | 
			
		||||
    # as a cookie, and also to its +output_hidden+ table, which is used
 | 
			
		||||
    # to add hidden input elements to forms.  
 | 
			
		||||
    # to add hidden input elements to forms.
 | 
			
		||||
    #
 | 
			
		||||
    # *WARNING* the +output_hidden+
 | 
			
		||||
    # fields are surrounded by a <fieldset> tag in HTML 4 generation, which
 | 
			
		||||
| 
						 | 
				
			
			@ -322,11 +322,11 @@ class CGI
 | 
			
		|||
 | 
			
		||||
    # Store session data on the server.  For some session storage types,
 | 
			
		||||
    # this is a no-op.
 | 
			
		||||
    def update  
 | 
			
		||||
    def update
 | 
			
		||||
      @dbman.update
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    # Store session data on the server and close the session storage.  
 | 
			
		||||
    # Store session data on the server and close the session storage.
 | 
			
		||||
    # For some session storage types, this is a no-op.
 | 
			
		||||
    def close
 | 
			
		||||
      @dbman.close
 | 
			
		||||
| 
						 | 
				
			
			@ -358,7 +358,7 @@ class CGI
 | 
			
		|||
      # created.  The session id must only contain alphanumeric
 | 
			
		||||
      # characters; automatically generated session ids observe
 | 
			
		||||
      # this requirement.
 | 
			
		||||
      # 
 | 
			
		||||
      #
 | 
			
		||||
      # +option+ is a hash of options for the initializer.  The
 | 
			
		||||
      # following options are recognised:
 | 
			
		||||
      #
 | 
			
		||||
| 
						 | 
				
			
			@ -450,7 +450,7 @@ class CGI
 | 
			
		|||
    # In-memory session storage class.
 | 
			
		||||
    #
 | 
			
		||||
    # Implements session storage as a global in-memory hash.  Session
 | 
			
		||||
    # data will only persist for as long as the ruby interpreter 
 | 
			
		||||
    # data will only persist for as long as the ruby interpreter
 | 
			
		||||
    # instance does.
 | 
			
		||||
    class MemoryStore
 | 
			
		||||
      GLOBAL_HASH_TABLE = {} #:nodoc:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,7 +2,7 @@
 | 
			
		|||
# cgi/session/pstore.rb - persistent storage of marshalled session data
 | 
			
		||||
#
 | 
			
		||||
# Documentation: William Webber (william@williamwebber.com)
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
# == Overview
 | 
			
		||||
#
 | 
			
		||||
# This file provides the CGI::Session::PStore class, which builds
 | 
			
		||||
| 
						 | 
				
			
			@ -29,7 +29,7 @@ class CGI
 | 
			
		|||
      # created.  The session id must only contain alphanumeric
 | 
			
		||||
      # characters; automatically generated session ids observe
 | 
			
		||||
      # this requirement.
 | 
			
		||||
      # 
 | 
			
		||||
      #
 | 
			
		||||
      # +option+ is a hash of options for the initializer.  The
 | 
			
		||||
      # following options are recognised:
 | 
			
		||||
      #
 | 
			
		||||
| 
						 | 
				
			
			@ -77,7 +77,7 @@ class CGI
 | 
			
		|||
      end
 | 
			
		||||
 | 
			
		||||
      # Save session state to the session's PStore file.
 | 
			
		||||
      def update 
 | 
			
		||||
      def update
 | 
			
		||||
	@p.transaction do
 | 
			
		||||
	    @p['hash'] = @hash
 | 
			
		||||
	end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
#
 | 
			
		||||
#   complex.rb - 
 | 
			
		||||
#   complex.rb -
 | 
			
		||||
#   	$Release Version: 0.5 $
 | 
			
		||||
#   	$Revision: 1.3 $
 | 
			
		||||
#   	$Date: 1998/07/08 10:05:28 $
 | 
			
		||||
| 
						 | 
				
			
			@ -14,7 +14,7 @@
 | 
			
		|||
# Complex numbers can be created in the following manner:
 | 
			
		||||
# - <tt>Complex(a, b)</tt>
 | 
			
		||||
# - <tt>Complex.polar(radius, theta)</tt>
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
# Additionally, note the following:
 | 
			
		||||
# - <tt>Complex::I</tt> (the mathematical constant <i>i</i>)
 | 
			
		||||
# - <tt>Numeric#im</tt> (e.g. <tt>5.im -> 0+5i</tt>)
 | 
			
		||||
| 
						 | 
				
			
			@ -38,14 +38,14 @@ class Numeric
 | 
			
		|||
  def im
 | 
			
		||||
    Complex(0, self)
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  #
 | 
			
		||||
  # The real part of a complex number, i.e. <i>self</i>.
 | 
			
		||||
  #
 | 
			
		||||
  def real
 | 
			
		||||
    self
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  #
 | 
			
		||||
  # The imaginary part of a complex number, i.e. 0.
 | 
			
		||||
  #
 | 
			
		||||
| 
						 | 
				
			
			@ -53,7 +53,7 @@ class Numeric
 | 
			
		|||
    0
 | 
			
		||||
  end
 | 
			
		||||
  alias imag image
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  #
 | 
			
		||||
  # See Complex#arg.
 | 
			
		||||
  #
 | 
			
		||||
| 
						 | 
				
			
			@ -61,14 +61,14 @@ class Numeric
 | 
			
		|||
    Math.atan2!(0, self)
 | 
			
		||||
  end
 | 
			
		||||
  alias angle arg
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  #
 | 
			
		||||
  # See Complex#polar.
 | 
			
		||||
  #
 | 
			
		||||
  def polar
 | 
			
		||||
    return abs, arg
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  #
 | 
			
		||||
  # See Complex#conjugate (short answer: returns <i>self</i>).
 | 
			
		||||
  #
 | 
			
		||||
| 
						 | 
				
			
			@ -145,7 +145,7 @@ class Complex < Numeric
 | 
			
		|||
      x + y
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  #
 | 
			
		||||
  # Subtraction with real or complex number.
 | 
			
		||||
  #
 | 
			
		||||
| 
						 | 
				
			
			@ -161,7 +161,7 @@ class Complex < Numeric
 | 
			
		|||
      x - y
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  #
 | 
			
		||||
  # Multiplication with real or complex number.
 | 
			
		||||
  #
 | 
			
		||||
| 
						 | 
				
			
			@ -177,7 +177,7 @@ class Complex < Numeric
 | 
			
		|||
      x * y
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  #
 | 
			
		||||
  # Division by real or complex number.
 | 
			
		||||
  #
 | 
			
		||||
| 
						 | 
				
			
			@ -191,7 +191,7 @@ class Complex < Numeric
 | 
			
		|||
      x/y
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  def quo(other)
 | 
			
		||||
    Complex(@real.quo(1), @image.quo(1)) / other
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			@ -240,7 +240,7 @@ class Complex < Numeric
 | 
			
		|||
      x**y
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  #
 | 
			
		||||
  # Remainder after division by a real or complex number.
 | 
			
		||||
  #
 | 
			
		||||
| 
						 | 
				
			
			@ -254,7 +254,7 @@ class Complex < Numeric
 | 
			
		|||
      x % y
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
#--
 | 
			
		||||
#    def divmod(other)
 | 
			
		||||
#      if other.kind_of?(Complex)
 | 
			
		||||
| 
						 | 
				
			
			@ -269,7 +269,7 @@ class Complex < Numeric
 | 
			
		|||
#      end
 | 
			
		||||
#    end
 | 
			
		||||
#++
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  #
 | 
			
		||||
  # Absolute value (aka modulus): distance from the zero point on the complex
 | 
			
		||||
  # plane.
 | 
			
		||||
| 
						 | 
				
			
			@ -277,14 +277,14 @@ class Complex < Numeric
 | 
			
		|||
  def abs
 | 
			
		||||
    Math.hypot(@real, @image)
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  #
 | 
			
		||||
  # Square of the absolute value.
 | 
			
		||||
  #
 | 
			
		||||
  def abs2
 | 
			
		||||
    @real*@real + @image*@image
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  #
 | 
			
		||||
  # Argument (angle from (1,0) on the complex plane).
 | 
			
		||||
  #
 | 
			
		||||
| 
						 | 
				
			
			@ -292,14 +292,14 @@ class Complex < Numeric
 | 
			
		|||
    Math.atan2!(@image, @real)
 | 
			
		||||
  end
 | 
			
		||||
  alias angle arg
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  #
 | 
			
		||||
  # Returns the absolute value _and_ the argument.
 | 
			
		||||
  #
 | 
			
		||||
  def polar
 | 
			
		||||
    return abs, arg
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  #
 | 
			
		||||
  # Complex conjugate (<tt>z + z.conjugate = 2 * z.real</tt>).
 | 
			
		||||
  #
 | 
			
		||||
| 
						 | 
				
			
			@ -307,14 +307,14 @@ class Complex < Numeric
 | 
			
		|||
    Complex(@real, -@image)
 | 
			
		||||
  end
 | 
			
		||||
  alias conj conjugate
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  #
 | 
			
		||||
  # Compares the absolute values of the two numbers.
 | 
			
		||||
  #
 | 
			
		||||
  def <=> (other)
 | 
			
		||||
    self.abs <=> other.abs
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  #
 | 
			
		||||
  # Test for numerical equality (<tt>a == a + 0<i>i</i></tt>).
 | 
			
		||||
  #
 | 
			
		||||
| 
						 | 
				
			
			@ -345,7 +345,7 @@ class Complex < Numeric
 | 
			
		|||
  def denominator
 | 
			
		||||
    @real.denominator.lcm(@image.denominator)
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  #
 | 
			
		||||
  # FIXME
 | 
			
		||||
  #
 | 
			
		||||
| 
						 | 
				
			
			@ -354,7 +354,7 @@ class Complex < Numeric
 | 
			
		|||
    Complex(@real.numerator*(cd/@real.denominator),
 | 
			
		||||
	    @image.numerator*(cd/@image.denominator))
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  #
 | 
			
		||||
  # Standard string representation of the complex number.
 | 
			
		||||
  #
 | 
			
		||||
| 
						 | 
				
			
			@ -381,14 +381,14 @@ class Complex < Numeric
 | 
			
		|||
      end
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  #
 | 
			
		||||
  # Returns a hash code for the complex number.
 | 
			
		||||
  #
 | 
			
		||||
  def hash
 | 
			
		||||
    @real.hash ^ @image.hash
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  #
 | 
			
		||||
  # Returns "<tt>Complex(<i>real</i>, <i>image</i>)</tt>".
 | 
			
		||||
  #
 | 
			
		||||
| 
						 | 
				
			
			@ -396,19 +396,19 @@ class Complex < Numeric
 | 
			
		|||
    sprintf("Complex(%s, %s)", @real.inspect, @image.inspect)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  #
 | 
			
		||||
  # +I+ is the imaginary number.  It exists at point (0,1) on the complex plane.
 | 
			
		||||
  #
 | 
			
		||||
  I = Complex(0,1)
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  # The real part of a complex number.
 | 
			
		||||
  attr :real
 | 
			
		||||
 | 
			
		||||
  # The imaginary part of a complex number.
 | 
			
		||||
  attr :image
 | 
			
		||||
  alias imag image
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
class Integer
 | 
			
		||||
| 
						 | 
				
			
			@ -457,7 +457,7 @@ module Math
 | 
			
		|||
  alias atan2! atan2
 | 
			
		||||
  alias acosh! acosh
 | 
			
		||||
  alias asinh! asinh
 | 
			
		||||
  alias atanh! atanh  
 | 
			
		||||
  alias atanh! atanh
 | 
			
		||||
 | 
			
		||||
  # Redefined to handle a Complex argument.
 | 
			
		||||
  def sqrt(z)
 | 
			
		||||
| 
						 | 
				
			
			@ -477,7 +477,7 @@ module Math
 | 
			
		|||
      end
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  # Redefined to handle a Complex argument.
 | 
			
		||||
  def exp(z)
 | 
			
		||||
    if Complex.generic?(z)
 | 
			
		||||
| 
						 | 
				
			
			@ -486,7 +486,7 @@ module Math
 | 
			
		|||
      Complex(exp!(z.real) * cos!(z.image), exp!(z.real) * sin!(z.image))
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  # Redefined to handle a Complex argument.
 | 
			
		||||
  def cos(z)
 | 
			
		||||
    if Complex.generic?(z)
 | 
			
		||||
| 
						 | 
				
			
			@ -496,7 +496,7 @@ module Math
 | 
			
		|||
	      -sin!(z.real)*sinh!(z.image))
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
  # Redefined to handle a Complex argument.
 | 
			
		||||
  def sin(z)
 | 
			
		||||
    if Complex.generic?(z)
 | 
			
		||||
| 
						 | 
				
			
			@ -506,7 +506,7 @@ module Math
 | 
			
		|||
	      cos!(z.real)*sinh!(z.image))
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  # Redefined to handle a Complex argument.
 | 
			
		||||
  def tan(z)
 | 
			
		||||
    if Complex.generic?(z)
 | 
			
		||||
| 
						 | 
				
			
			@ -539,7 +539,7 @@ module Math
 | 
			
		|||
      sinh(z)/cosh(z)
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  # Redefined to handle a Complex argument.
 | 
			
		||||
  def log(z)
 | 
			
		||||
    if Complex.generic?(z) and z >= 0
 | 
			
		||||
| 
						 | 
				
			
			@ -549,7 +549,7 @@ module Math
 | 
			
		|||
      Complex(log!(r.abs), theta)
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  # Redefined to handle a Complex argument.
 | 
			
		||||
  def log10(z)
 | 
			
		||||
    if Complex.generic?(z)
 | 
			
		||||
| 
						 | 
				
			
			@ -649,7 +649,7 @@ module Math
 | 
			
		|||
  module_function :asinh
 | 
			
		||||
  module_function :atanh!
 | 
			
		||||
  module_function :atanh
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
# Documentation comments:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										50
									
								
								lib/csv.rb
									
										
									
									
									
								
							
							
						
						
									
										50
									
								
								lib/csv.rb
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1,13 +1,13 @@
 | 
			
		|||
# CSV -- module for generating/parsing CSV data.
 | 
			
		||||
# Copyright (C) 2000-2004  NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>.
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
# $Id$
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
# This program is copyrighted free software by NAKAMURA, Hiroshi.  You can
 | 
			
		||||
# redistribute it and/or modify it under the same terms of Ruby's license;
 | 
			
		||||
# either the dual license version in 2003, or any later version.
 | 
			
		||||
  
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class CSV
 | 
			
		||||
  class IllegalFormatError < RuntimeError; end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -97,7 +97,7 @@ class CSV
 | 
			
		|||
  def CSV.read(path, length = nil, offset = nil)
 | 
			
		||||
    CSV.parse(IO.read(path, length, offset))
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  def CSV.readlines(path, rs = nil)
 | 
			
		||||
    reader = open_reader(path, 'r', ',', rs)
 | 
			
		||||
    begin
 | 
			
		||||
| 
						 | 
				
			
			@ -181,7 +181,7 @@ class CSV
 | 
			
		|||
    end
 | 
			
		||||
    result_str
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  # Parse a line from string.  Consider using CSV.parse_line instead.
 | 
			
		||||
  # To parse lines in CSV string, see EXAMPLE below.
 | 
			
		||||
  #
 | 
			
		||||
| 
						 | 
				
			
			@ -239,7 +239,7 @@ class CSV
 | 
			
		|||
    end
 | 
			
		||||
    return parsed_cells, idx
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  # Convert a line from cells data to string.  Consider using CSV.generate_line
 | 
			
		||||
  # instead.  To generate multi-row CSV string, see EXAMPLE below.
 | 
			
		||||
  #
 | 
			
		||||
| 
						 | 
				
			
			@ -299,7 +299,7 @@ class CSV
 | 
			
		|||
    end
 | 
			
		||||
    parsed_cells
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  # Private class methods.
 | 
			
		||||
  class << self
 | 
			
		||||
  private
 | 
			
		||||
| 
						 | 
				
			
			@ -334,7 +334,7 @@ class CSV
 | 
			
		|||
        end
 | 
			
		||||
        nil
 | 
			
		||||
      else
 | 
			
		||||
        writer = CSV::Writer.create(file, fs, rs) 
 | 
			
		||||
        writer = CSV::Writer.create(file, fs, rs)
 | 
			
		||||
        writer.close_on_terminate
 | 
			
		||||
        writer
 | 
			
		||||
      end
 | 
			
		||||
| 
						 | 
				
			
			@ -480,7 +480,7 @@ class CSV
 | 
			
		|||
      last_idx = idx
 | 
			
		||||
      return :DT_EOS, idx, cell
 | 
			
		||||
    end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
    def generate_body(cell, out_dev, fs, rs)
 | 
			
		||||
      if cell.nil?
 | 
			
		||||
        # empty
 | 
			
		||||
| 
						 | 
				
			
			@ -498,7 +498,7 @@ class CSV
 | 
			
		|||
        end
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    def generate_separator(type, out_dev, fs, rs)
 | 
			
		||||
      case type
 | 
			
		||||
      when :DT_COLSEP
 | 
			
		||||
| 
						 | 
				
			
			@ -586,7 +586,7 @@ class CSV
 | 
			
		|||
      # Define if needed.
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  class StringReader < Reader
 | 
			
		||||
    def initialize(string, fs = ',', rs = nil)
 | 
			
		||||
| 
						 | 
				
			
			@ -800,7 +800,7 @@ private
 | 
			
		|||
    # returns char at idx if n == nil.
 | 
			
		||||
    # returns a partial string, from idx to (idx + n) if n != nil.  at EOF,
 | 
			
		||||
    # the string size could not equal to arg n.
 | 
			
		||||
    def [](idx, n = nil) 
 | 
			
		||||
    def [](idx, n = nil)
 | 
			
		||||
      if idx < 0
 | 
			
		||||
        return nil
 | 
			
		||||
      end
 | 
			
		||||
| 
						 | 
				
			
			@ -846,7 +846,7 @@ private
 | 
			
		|||
      end
 | 
			
		||||
    end
 | 
			
		||||
    alias get []
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
    # drop a string from the stream.
 | 
			
		||||
    # returns dropped size.  at EOF, dropped size might not equals to arg n.
 | 
			
		||||
    # Once you drop the head of the stream, access to the dropped part via []
 | 
			
		||||
| 
						 | 
				
			
			@ -878,11 +878,11 @@ private
 | 
			
		|||
      end
 | 
			
		||||
      size_dropped
 | 
			
		||||
    end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
    def is_eos?
 | 
			
		||||
      return idx_is_eos?(0)
 | 
			
		||||
    end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
    # WARN: Do not instantiate this class directly.  Define your own class
 | 
			
		||||
    # which derives this class and define 'read' instance method.
 | 
			
		||||
    def initialize
 | 
			
		||||
| 
						 | 
				
			
			@ -893,13 +893,13 @@ private
 | 
			
		|||
      add_buf
 | 
			
		||||
      @cur_buf = @buf_tail_idx
 | 
			
		||||
    end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  protected
 | 
			
		||||
 | 
			
		||||
    def terminate
 | 
			
		||||
      while (rel_buf); end
 | 
			
		||||
    end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
    # protected method 'read' must be defined in derived classes.
 | 
			
		||||
    # CAUTION: Returning a string which size is not equal to 'size' means
 | 
			
		||||
    # EnfOfStream.  When it is not at EOS, you must block the callee, try to
 | 
			
		||||
| 
						 | 
				
			
			@ -907,9 +907,9 @@ private
 | 
			
		|||
    def read(size) # raise EOFError
 | 
			
		||||
      raise NotImplementedError.new('Method read must be defined in a derived class.')
 | 
			
		||||
    end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  private
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
    def buf_size(idx)
 | 
			
		||||
      @buf_list[idx].size
 | 
			
		||||
    end
 | 
			
		||||
| 
						 | 
				
			
			@ -937,7 +937,7 @@ private
 | 
			
		|||
        true
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
    def rel_buf
 | 
			
		||||
      if (@cur_buf < 0)
 | 
			
		||||
        return false
 | 
			
		||||
| 
						 | 
				
			
			@ -951,11 +951,11 @@ private
 | 
			
		|||
        return true
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
    def idx_is_eos?(idx)
 | 
			
		||||
      (@is_eos and ((@cur_buf < 0) or (@cur_buf == @buf_tail_idx)))
 | 
			
		||||
    end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
    BufSize = 1024 * 8
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -974,7 +974,7 @@ private
 | 
			
		|||
      @s = s
 | 
			
		||||
      super()
 | 
			
		||||
    end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
    def close
 | 
			
		||||
      terminate
 | 
			
		||||
    end
 | 
			
		||||
| 
						 | 
				
			
			@ -984,7 +984,7 @@ private
 | 
			
		|||
    def read(size)
 | 
			
		||||
      @s.read(size)
 | 
			
		||||
    end
 | 
			
		||||
 
 | 
			
		||||
 | 
			
		||||
    def terminate
 | 
			
		||||
      super()
 | 
			
		||||
    end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -256,7 +256,7 @@ class Context
 | 
			
		|||
  def debug_command(file, line, id, binding)
 | 
			
		||||
    MUTEX.lock
 | 
			
		||||
    unless defined?($debugger_restart) and $debugger_restart
 | 
			
		||||
      callcc{|c| $debugger_restart = c} 
 | 
			
		||||
      callcc{|c| $debugger_restart = c}
 | 
			
		||||
    end
 | 
			
		||||
    set_last_thread(Thread.current)
 | 
			
		||||
    frame_pos = 0
 | 
			
		||||
| 
						 | 
				
			
			@ -335,7 +335,7 @@ class Context
 | 
			
		|||
	    stdout.print "Breakpoints:\n"
 | 
			
		||||
	    for b in break_points
 | 
			
		||||
	      if b[0] and b[1] == 0
 | 
			
		||||
		stdout.printf "  %d %s:%s\n", n, b[2], b[3] 
 | 
			
		||||
		stdout.printf "  %d %s:%s\n", n, b[2], b[3]
 | 
			
		||||
	      end
 | 
			
		||||
	      n += 1
 | 
			
		||||
	    end
 | 
			
		||||
| 
						 | 
				
			
			@ -751,7 +751,7 @@ EOHELP
 | 
			
		|||
    when 'end'
 | 
			
		||||
      @frames.shift
 | 
			
		||||
 | 
			
		||||
    when 'raise' 
 | 
			
		||||
    when 'raise'
 | 
			
		||||
      excn_handle(file, line, id, binding)
 | 
			
		||||
 | 
			
		||||
    end
 | 
			
		||||
| 
						 | 
				
			
			@ -921,7 +921,7 @@ class << DEBUGGER__
 | 
			
		|||
	@stdout.print "Already stopped.\n"
 | 
			
		||||
      else
 | 
			
		||||
	thread_list(@thread_list[th])
 | 
			
		||||
	context(th).suspend 
 | 
			
		||||
	context(th).suspend
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
    when /^resume\s+(\d+)/
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -37,16 +37,16 @@
 | 
			
		|||
#     def initialize
 | 
			
		||||
#       @source = SimpleDelegator.new([])
 | 
			
		||||
#     end
 | 
			
		||||
#     
 | 
			
		||||
#
 | 
			
		||||
#     def stats( records )
 | 
			
		||||
#       @source.__setobj__(records)
 | 
			
		||||
#       	
 | 
			
		||||
#
 | 
			
		||||
#       "Elements:  #{@source.size}\n" +
 | 
			
		||||
#       " Non-Nil:  #{@source.compact.size}\n" +
 | 
			
		||||
#       "  Unique:  #{@source.uniq.size}\n"
 | 
			
		||||
#     end
 | 
			
		||||
#   end
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#   s = Stats.new
 | 
			
		||||
#   puts s.stats(%w{James Edward Gray II})
 | 
			
		||||
#   puts
 | 
			
		||||
| 
						 | 
				
			
			@ -57,7 +57,7 @@
 | 
			
		|||
#   Elements:  4
 | 
			
		||||
#    Non-Nil:  4
 | 
			
		||||
#     Unique:  4
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
#   Elements:  8
 | 
			
		||||
#    Non-Nil:  7
 | 
			
		||||
#     Unique:  6
 | 
			
		||||
| 
						 | 
				
			
			@ -72,19 +72,19 @@
 | 
			
		|||
#
 | 
			
		||||
#   class Tempfile < DelegateClass(File)
 | 
			
		||||
#     # constant and class member data initialization...
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#     def initialize(basename, tmpdir=Dir::tmpdir)
 | 
			
		||||
#       # build up file path/name in var tmpname...
 | 
			
		||||
#     
 | 
			
		||||
#
 | 
			
		||||
#       @tmpfile = File.open(tmpname, File::RDWR|File::CREAT|File::EXCL, 0600)
 | 
			
		||||
#     
 | 
			
		||||
#
 | 
			
		||||
#       # ...
 | 
			
		||||
#     
 | 
			
		||||
#
 | 
			
		||||
#       super(@tmpfile)
 | 
			
		||||
#     
 | 
			
		||||
#
 | 
			
		||||
#       # below this point, all methods of File are supported...
 | 
			
		||||
#     end
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#     # ...
 | 
			
		||||
#   end
 | 
			
		||||
#
 | 
			
		||||
| 
						 | 
				
			
			@ -97,15 +97,15 @@
 | 
			
		|||
#        super             # pass obj to Delegator constructor, required
 | 
			
		||||
#        @_sd_obj = obj    # store obj for future use
 | 
			
		||||
#      end
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
#      def __getobj__
 | 
			
		||||
#        @_sd_obj          # return object we are delegating to, required
 | 
			
		||||
#      end
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
#      def __setobj__(obj)
 | 
			
		||||
#        @_sd_obj = obj    # change delegation object, a feature we're providing
 | 
			
		||||
#      end
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
#      # ...
 | 
			
		||||
#    end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -159,10 +159,10 @@ class Delegator
 | 
			
		|||
    target.__send__(m, *args, &block)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # 
 | 
			
		||||
  # Checks for a method provided by this the delegate object by fowarding the 
 | 
			
		||||
  #
 | 
			
		||||
  # Checks for a method provided by this the delegate object by fowarding the
 | 
			
		||||
  # call through \_\_getobj\_\_.
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  def respond_to?(m, include_private = false)
 | 
			
		||||
    return true if super
 | 
			
		||||
    return self.__getobj__.respond_to?(m, include_private)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										178
									
								
								lib/drb/drb.rb
									
										
									
									
									
								
							
							
						
						
									
										178
									
								
								lib/drb/drb.rb
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -18,7 +18,7 @@
 | 
			
		|||
#
 | 
			
		||||
# The Ruby standard library contains the core classes of the dRuby package.
 | 
			
		||||
# However, the full package also includes access control lists and the
 | 
			
		||||
# Rinda tuple-space distributed task management system, as well as a 
 | 
			
		||||
# Rinda tuple-space distributed task management system, as well as a
 | 
			
		||||
# large number of samples.  The full dRuby package can be downloaded from
 | 
			
		||||
# the dRuby home page (see *References*).
 | 
			
		||||
#
 | 
			
		||||
| 
						 | 
				
			
			@ -121,7 +121,7 @@ require 'drb/eq'
 | 
			
		|||
# are forwarded to the local object, as described in the discussion of
 | 
			
		||||
# DRbObjects.  This has semantics similar to the normal Ruby
 | 
			
		||||
# pass-by-reference.
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
# The easiest way to signal that we want an otherwise marshallable
 | 
			
		||||
# object to be passed or returned as a DRbObject reference, rather
 | 
			
		||||
# than marshalled and sent as a copy, is to include the
 | 
			
		||||
| 
						 | 
				
			
			@ -135,7 +135,7 @@ require 'drb/eq'
 | 
			
		|||
# passed back to the remote execution context to be collected, before
 | 
			
		||||
# the collected values are finally returned to the local context as
 | 
			
		||||
# the return value of the method invocation.
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
# == Examples of usage
 | 
			
		||||
#
 | 
			
		||||
# For more dRuby samples, see the +samples+ directory in the full
 | 
			
		||||
| 
						 | 
				
			
			@ -148,33 +148,33 @@ require 'drb/eq'
 | 
			
		|||
# starting the server code first.
 | 
			
		||||
#
 | 
			
		||||
# ==== Server code
 | 
			
		||||
#    
 | 
			
		||||
#
 | 
			
		||||
#   require 'drb/drb'
 | 
			
		||||
#     
 | 
			
		||||
#
 | 
			
		||||
#   # The URI for the server to connect to
 | 
			
		||||
#   URI="druby://localhost:8787" 
 | 
			
		||||
#     
 | 
			
		||||
#   URI="druby://localhost:8787"
 | 
			
		||||
#
 | 
			
		||||
#   class TimeServer
 | 
			
		||||
#     
 | 
			
		||||
#
 | 
			
		||||
#     def get_current_time
 | 
			
		||||
#       return Time.now
 | 
			
		||||
#     end
 | 
			
		||||
#     
 | 
			
		||||
#
 | 
			
		||||
#   end
 | 
			
		||||
#     
 | 
			
		||||
#
 | 
			
		||||
#   # The object that handles requests on the server
 | 
			
		||||
#   FRONT_OBJECT=TimeServer.new
 | 
			
		||||
#
 | 
			
		||||
#   $SAFE = 1   # disable eval() and friends
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#   DRb.start_service(URI, FRONT_OBJECT)
 | 
			
		||||
#   # Wait for the drb server thread to finish before exiting.
 | 
			
		||||
#   DRb.thread.join
 | 
			
		||||
#
 | 
			
		||||
# ==== Client code
 | 
			
		||||
#     
 | 
			
		||||
#
 | 
			
		||||
#   require 'drb/drb'
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#   # The URI to connect to
 | 
			
		||||
#   SERVER_URI="druby://localhost:8787"
 | 
			
		||||
#
 | 
			
		||||
| 
						 | 
				
			
			@ -184,43 +184,43 @@ require 'drb/eq'
 | 
			
		|||
#   # as soon as we pass a non-marshallable object as an argument
 | 
			
		||||
#   # to a dRuby call.
 | 
			
		||||
#   DRb.start_service
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#   timeserver = DRbObject.new_with_uri(SERVER_URI)
 | 
			
		||||
#   puts timeserver.get_current_time 
 | 
			
		||||
#   puts timeserver.get_current_time
 | 
			
		||||
#
 | 
			
		||||
# === Remote objects under dRuby
 | 
			
		||||
#
 | 
			
		||||
# This example illustrates returning a reference to an object
 | 
			
		||||
# from a dRuby call.  The Logger instances live in the server
 | 
			
		||||
# process.  References to them are returned to the client process,
 | 
			
		||||
# where methods can be invoked upon them.  These methods are 
 | 
			
		||||
# where methods can be invoked upon them.  These methods are
 | 
			
		||||
# executed in the server process.
 | 
			
		||||
#
 | 
			
		||||
# ==== Server code
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#   require 'drb/drb'
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#   URI="druby://localhost:8787"
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#   class Logger
 | 
			
		||||
#
 | 
			
		||||
#       # Make dRuby send Logger instances as dRuby references,
 | 
			
		||||
#       # not copies.
 | 
			
		||||
#       include DRb::DRbUndumped
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#       def initialize(n, fname)
 | 
			
		||||
#           @name = n
 | 
			
		||||
#           @filename = fname
 | 
			
		||||
#       end
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#       def log(message)
 | 
			
		||||
#           File.open(@filename, "a") do |f|
 | 
			
		||||
#               f.puts("#{Time.now}: #{@name}: #{message}")
 | 
			
		||||
#           end
 | 
			
		||||
#       end
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#   end
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#   # We have a central object for creating and retrieving loggers.
 | 
			
		||||
#   # This retains a local reference to all loggers created.  This
 | 
			
		||||
#   # is so an existing logger can be looked up by name, but also
 | 
			
		||||
| 
						 | 
				
			
			@ -228,12 +228,12 @@ require 'drb/eq'
 | 
			
		|||
#   # reference to an object is not sufficient to prevent it being
 | 
			
		||||
#   # garbage collected!
 | 
			
		||||
#   class LoggerFactory
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#       def initialize(bdir)
 | 
			
		||||
#           @basedir = bdir
 | 
			
		||||
#           @loggers = {}
 | 
			
		||||
#       end
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#       def get_logger(name)
 | 
			
		||||
#           if !@loggers.has_key? name
 | 
			
		||||
#               # make the filename safe, then declare it to be so
 | 
			
		||||
| 
						 | 
				
			
			@ -242,34 +242,34 @@ require 'drb/eq'
 | 
			
		|||
#           end
 | 
			
		||||
#           return @loggers[name]
 | 
			
		||||
#       end
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#   end
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#   FRONT_OBJECT=LoggerFactory.new("/tmp/dlog")
 | 
			
		||||
#
 | 
			
		||||
#   $SAFE = 1   # disable eval() and friends
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#   DRb.start_service(URI, FRONT_OBJECT)
 | 
			
		||||
#   DRb.thread.join
 | 
			
		||||
#
 | 
			
		||||
# ==== Client code
 | 
			
		||||
#
 | 
			
		||||
#   require 'drb/drb'
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#   SERVER_URI="druby://localhost:8787"
 | 
			
		||||
#
 | 
			
		||||
#   DRb.start_service
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#   log_service=DRbObject.new_with_uri(SERVER_URI)
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#   ["loga", "logb", "logc"].each do |logname|
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#       logger=log_service.get_logger(logname)
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#       logger.log("Hello, world!")
 | 
			
		||||
#       logger.log("Goodbye, world!")
 | 
			
		||||
#       logger.log("=== EOT ===")
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#   end
 | 
			
		||||
#
 | 
			
		||||
# == Security
 | 
			
		||||
| 
						 | 
				
			
			@ -288,9 +288,9 @@ require 'drb/eq'
 | 
			
		|||
#    ro.instance_eval("`rm -rf *`")
 | 
			
		||||
#
 | 
			
		||||
# The dangers posed by instance_eval and friends are such that a
 | 
			
		||||
# DRbServer should generally be run with $SAFE set to at least 
 | 
			
		||||
# level 1.  This will disable eval() and related calls on strings 
 | 
			
		||||
# passed across the wire.  The sample usage code given above follows 
 | 
			
		||||
# DRbServer should generally be run with $SAFE set to at least
 | 
			
		||||
# level 1.  This will disable eval() and related calls on strings
 | 
			
		||||
# passed across the wire.  The sample usage code given above follows
 | 
			
		||||
# this practice.
 | 
			
		||||
#
 | 
			
		||||
# A DRbServer can be configured with an access control list to
 | 
			
		||||
| 
						 | 
				
			
			@ -360,7 +360,7 @@ module DRb
 | 
			
		|||
  #
 | 
			
		||||
  # This, the default implementation, uses an object's local ObjectSpace
 | 
			
		||||
  # __id__ as its id.  This means that an object's identification over
 | 
			
		||||
  # drb remains valid only while that object instance remains alive 
 | 
			
		||||
  # drb remains valid only while that object instance remains alive
 | 
			
		||||
  # within the server runtime.
 | 
			
		||||
  #
 | 
			
		||||
  # For alternative mechanisms, see DRb::TimerIdConv in rdb/timeridconv.rb
 | 
			
		||||
| 
						 | 
				
			
			@ -374,7 +374,7 @@ module DRb
 | 
			
		|||
    def to_obj(ref)
 | 
			
		||||
      ObjectSpace._id2ref(ref)
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    # Convert an object into a reference id.
 | 
			
		||||
    #
 | 
			
		||||
    # This implementation returns the object's __id__ in the local
 | 
			
		||||
| 
						 | 
				
			
			@ -390,7 +390,7 @@ module DRb
 | 
			
		|||
  # called over drb, then the object remains in the server space
 | 
			
		||||
  # and a reference to the object is returned, rather than the
 | 
			
		||||
  # object being marshalled and moved into the client space.
 | 
			
		||||
  module DRbUndumped 
 | 
			
		||||
  module DRbUndumped
 | 
			
		||||
    def _dump(dummy)  # :nodoc:
 | 
			
		||||
      raise TypeError, 'can\'t dump'
 | 
			
		||||
    end
 | 
			
		||||
| 
						 | 
				
			
			@ -424,7 +424,7 @@ module DRb
 | 
			
		|||
    def self._load(s)  # :nodoc:
 | 
			
		||||
      Marshal::load(s)
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    def _dump(lv) # :nodoc:
 | 
			
		||||
      Marshal::dump(@unknown)
 | 
			
		||||
    end
 | 
			
		||||
| 
						 | 
				
			
			@ -456,11 +456,11 @@ module DRb
 | 
			
		|||
  # +name+ attribute.  The marshalled object is held in the +buf+
 | 
			
		||||
  # attribute.
 | 
			
		||||
  class DRbUnknown
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    # Create a new DRbUnknown object.
 | 
			
		||||
    #
 | 
			
		||||
    # +buf+ is a string containing a marshalled object that could not
 | 
			
		||||
    # be unmarshalled.  +err+ is the error message that was raised 
 | 
			
		||||
    # be unmarshalled.  +err+ is the error message that was raised
 | 
			
		||||
    # when the unmarshalling failed.  It is used to determine the
 | 
			
		||||
    # name of the unmarshalled object.
 | 
			
		||||
    def initialize(err, buf)
 | 
			
		||||
| 
						 | 
				
			
			@ -499,7 +499,7 @@ module DRb
 | 
			
		|||
    # Attempt to load the wrapped marshalled object again.
 | 
			
		||||
    #
 | 
			
		||||
    # If the class of the object is now known locally, the object
 | 
			
		||||
    # will be unmarshalled and returned.  Otherwise, a new 
 | 
			
		||||
    # will be unmarshalled and returned.  Otherwise, a new
 | 
			
		||||
    # but identical DRbUnknown object will be returned.
 | 
			
		||||
    def reload
 | 
			
		||||
      self.class._load(@buf)
 | 
			
		||||
| 
						 | 
				
			
			@ -513,7 +513,7 @@ module DRb
 | 
			
		|||
 | 
			
		||||
  class DRbArray
 | 
			
		||||
    def initialize(ary)
 | 
			
		||||
      @ary = ary.collect { |obj| 
 | 
			
		||||
      @ary = ary.collect { |obj|
 | 
			
		||||
	if obj.kind_of? DRbUndumped
 | 
			
		||||
	  DRbObject.new(obj)
 | 
			
		||||
	else
 | 
			
		||||
| 
						 | 
				
			
			@ -607,7 +607,7 @@ module DRb
 | 
			
		|||
    rescue
 | 
			
		||||
      raise(DRbConnError, $!.message, $!.backtrace)
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    def recv_request(stream) # :nodoc:
 | 
			
		||||
      ref = load(stream)
 | 
			
		||||
      ro = DRb.to_obj(ref)
 | 
			
		||||
| 
						 | 
				
			
			@ -656,10 +656,10 @@ module DRb
 | 
			
		|||
  #                              using configuration +config+.  Return a
 | 
			
		||||
  #                              protocol instance for this listener.
 | 
			
		||||
  #   [uri_option(uri, config)] Take a URI, possibly containing an option
 | 
			
		||||
  #                             component (e.g. a trailing '?param=val'), 
 | 
			
		||||
  #                             component (e.g. a trailing '?param=val'),
 | 
			
		||||
  #                             and return a [uri, option] tuple.
 | 
			
		||||
  #
 | 
			
		||||
  # All of these methods should raise a DRbBadScheme error if the URI 
 | 
			
		||||
  # All of these methods should raise a DRbBadScheme error if the URI
 | 
			
		||||
  # does not identify the protocol they support (e.g. "druby:" for
 | 
			
		||||
  # the standard Ruby protocol).  This is how the DRbProtocol module,
 | 
			
		||||
  # given a URI, determines which protocol implementation serves that
 | 
			
		||||
| 
						 | 
				
			
			@ -675,14 +675,14 @@ module DRb
 | 
			
		|||
  #
 | 
			
		||||
  # The protocol instance returned by #open must have the following methods:
 | 
			
		||||
  #
 | 
			
		||||
  # [send_request (ref, msg_id, arg, b)] 
 | 
			
		||||
  # [send_request (ref, msg_id, arg, b)]
 | 
			
		||||
  #      Send a request to +ref+ with the given message id and arguments.
 | 
			
		||||
  #      This is most easily implemented by calling DRbMessage.send_request,
 | 
			
		||||
  #      providing a stream that sits on top of the current protocol.
 | 
			
		||||
  # [recv_reply]
 | 
			
		||||
  #      Receive a reply from the server and return it as a [success-boolean,
 | 
			
		||||
  #      reply-value] pair.  This is most easily implemented by calling
 | 
			
		||||
  #      DRb.recv_reply, providing a stream that sits on top of the 
 | 
			
		||||
  #      DRb.recv_reply, providing a stream that sits on top of the
 | 
			
		||||
  #      current protocol.
 | 
			
		||||
  # [alive?]
 | 
			
		||||
  #      Is this connection still alive?
 | 
			
		||||
| 
						 | 
				
			
			@ -725,7 +725,7 @@ module DRb
 | 
			
		|||
    # URI by raising a DRbBadScheme error.  If no protocol recognises the
 | 
			
		||||
    # URI, then a DRbBadURI error is raised.  If a protocol accepts the
 | 
			
		||||
    # URI, but an error occurs in opening it, a DRbConnError is raised.
 | 
			
		||||
    def open(uri, config, first=true) 
 | 
			
		||||
    def open(uri, config, first=true)
 | 
			
		||||
      @protocol.each do |prot|
 | 
			
		||||
	begin
 | 
			
		||||
	  return prot.open(uri, config)
 | 
			
		||||
| 
						 | 
				
			
			@ -744,14 +744,14 @@ module DRb
 | 
			
		|||
    end
 | 
			
		||||
    module_function :open
 | 
			
		||||
 | 
			
		||||
    # Open a server listening for connections at +uri+ with 
 | 
			
		||||
    # Open a server listening for connections at +uri+ with
 | 
			
		||||
    # configuration +config+.
 | 
			
		||||
    #
 | 
			
		||||
    # The DRbProtocol module asks each registered protocol in turn to
 | 
			
		||||
    # try to open a server at the URI.  Each protocol signals that it does 
 | 
			
		||||
    # not handle that URI by raising a DRbBadScheme error.  If no protocol 
 | 
			
		||||
    # recognises the URI, then a DRbBadURI error is raised.  If a protocol 
 | 
			
		||||
    # accepts the URI, but an error occurs in opening it, the underlying 
 | 
			
		||||
    # try to open a server at the URI.  Each protocol signals that it does
 | 
			
		||||
    # not handle that URI by raising a DRbBadScheme error.  If no protocol
 | 
			
		||||
    # recognises the URI, then a DRbBadURI error is raised.  If a protocol
 | 
			
		||||
    # accepts the URI, but an error occurs in opening it, the underlying
 | 
			
		||||
    # error is passed on to the caller.
 | 
			
		||||
    def open_server(uri, config, first=true)
 | 
			
		||||
      @protocol.each do |prot|
 | 
			
		||||
| 
						 | 
				
			
			@ -773,7 +773,7 @@ module DRb
 | 
			
		|||
    # The DRbProtocol module asks each registered protocol in turn to
 | 
			
		||||
    # try to parse the URI.  Each protocol signals that it does not handle that
 | 
			
		||||
    # URI by raising a DRbBadScheme error.  If no protocol recognises the
 | 
			
		||||
    # URI, then a DRbBadURI error is raised.  
 | 
			
		||||
    # URI, then a DRbBadURI error is raised.
 | 
			
		||||
    def uri_option(uri, config, first=true)
 | 
			
		||||
      @protocol.each do |prot|
 | 
			
		||||
	begin
 | 
			
		||||
| 
						 | 
				
			
			@ -837,9 +837,9 @@ module DRb
 | 
			
		|||
    end
 | 
			
		||||
 | 
			
		||||
    def self.open_server_inaddr_any(host, port)
 | 
			
		||||
      infos = Socket::getaddrinfo(host, nil, 
 | 
			
		||||
      infos = Socket::getaddrinfo(host, nil,
 | 
			
		||||
                                  Socket::AF_UNSPEC,
 | 
			
		||||
                                  Socket::SOCK_STREAM, 
 | 
			
		||||
                                  Socket::SOCK_STREAM,
 | 
			
		||||
                                  0,
 | 
			
		||||
                                  Socket::AI_PASSIVE)
 | 
			
		||||
      families = Hash[*infos.collect { |af, *_| af }.uniq.zip([]).flatten]
 | 
			
		||||
| 
						 | 
				
			
			@ -848,7 +848,7 @@ module DRb
 | 
			
		|||
      return TCPServer.open(port)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    # Open a server listening for connections at +uri+ using 
 | 
			
		||||
    # Open a server listening for connections at +uri+ using
 | 
			
		||||
    # configuration +config+.
 | 
			
		||||
    def self.open_server(uri, config)
 | 
			
		||||
      uri = 'druby://:0' unless uri
 | 
			
		||||
| 
						 | 
				
			
			@ -894,7 +894,7 @@ module DRb
 | 
			
		|||
    def peeraddr
 | 
			
		||||
      @socket.peeraddr
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    # Get the socket.
 | 
			
		||||
    def stream; @socket; end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -902,7 +902,7 @@ module DRb
 | 
			
		|||
    def send_request(ref, msg_id, arg, b)
 | 
			
		||||
      @msg.send_request(stream, ref, msg_id, arg, b)
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    # On the server side, receive a request from the client.
 | 
			
		||||
    def recv_request
 | 
			
		||||
      @msg.recv_request(stream)
 | 
			
		||||
| 
						 | 
				
			
			@ -932,14 +932,14 @@ module DRb
 | 
			
		|||
	@socket = nil
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
    # On the server side, for an instance returned by #open_server, 
 | 
			
		||||
 | 
			
		||||
    # On the server side, for an instance returned by #open_server,
 | 
			
		||||
    # accept a client connection and return a new instance to handle
 | 
			
		||||
    # the server's side of this client-server session.
 | 
			
		||||
    def accept
 | 
			
		||||
      while true
 | 
			
		||||
	s = @socket.accept
 | 
			
		||||
	break if (@acl ? @acl.allow_socket?(s) : true) 
 | 
			
		||||
	break if (@acl ? @acl.allow_socket?(s) : true)
 | 
			
		||||
	s.close
 | 
			
		||||
      end
 | 
			
		||||
      if @config[:tcp_original_host].to_s.size == 0
 | 
			
		||||
| 
						 | 
				
			
			@ -976,16 +976,16 @@ module DRb
 | 
			
		|||
    end
 | 
			
		||||
    attr :option
 | 
			
		||||
    def to_s; @option; end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    def ==(other)
 | 
			
		||||
      return false unless DRbURIOption === other
 | 
			
		||||
      @option == other.option
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    def hash
 | 
			
		||||
      @option.hash
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    alias eql? ==
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1002,7 +1002,7 @@ module DRb
 | 
			
		|||
    # created to act as a stub for the remote referenced object.
 | 
			
		||||
    def self._load(s)
 | 
			
		||||
      uri, ref = Marshal.load(s)
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      if DRb.here?(uri)
 | 
			
		||||
	obj = DRb.to_obj(ref)
 | 
			
		||||
        if ((! obj.tainted?) && Thread.current[:drb_untaint])
 | 
			
		||||
| 
						 | 
				
			
			@ -1052,7 +1052,7 @@ module DRb
 | 
			
		|||
    end
 | 
			
		||||
 | 
			
		||||
    # Get the URI of the remote object.
 | 
			
		||||
    def __drburi 
 | 
			
		||||
    def __drburi
 | 
			
		||||
      @uri
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1080,7 +1080,7 @@ module DRb
 | 
			
		|||
      if DRb.here?(@uri)
 | 
			
		||||
	obj = DRb.to_obj(@ref)
 | 
			
		||||
	DRb.current_server.check_insecure_method(obj, msg_id)
 | 
			
		||||
	return obj.__send__(msg_id, *a, &b) 
 | 
			
		||||
	return obj.__send__(msg_id, *a, &b)
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      succ, result = self.class.with_friend(@uri) do
 | 
			
		||||
| 
						 | 
				
			
			@ -1103,7 +1103,7 @@ module DRb
 | 
			
		|||
    def self.with_friend(uri)
 | 
			
		||||
      friend = DRb.fetch_server(uri)
 | 
			
		||||
      return yield() unless friend
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      save = Thread.current['DRb']
 | 
			
		||||
      Thread.current['DRb'] = { 'server' => friend }
 | 
			
		||||
      return yield
 | 
			
		||||
| 
						 | 
				
			
			@ -1115,7 +1115,7 @@ module DRb
 | 
			
		|||
      prefix = "(#{uri}) "
 | 
			
		||||
      bt = []
 | 
			
		||||
      result.backtrace.each do |x|
 | 
			
		||||
        break if /`__send__'$/ =~ x 
 | 
			
		||||
        break if /`__send__'$/ =~ x
 | 
			
		||||
        if /^\(druby:\/\// =~ x
 | 
			
		||||
          bt.push(x)
 | 
			
		||||
        else
 | 
			
		||||
| 
						 | 
				
			
			@ -1266,14 +1266,14 @@ module DRb
 | 
			
		|||
    def self.verbose=(on)
 | 
			
		||||
      @@verbose = on
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    # Get the default value of the :verbose option.
 | 
			
		||||
    def self.verbose
 | 
			
		||||
      @@verbose
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def self.make_config(hash={})  # :nodoc:
 | 
			
		||||
      default_config = { 
 | 
			
		||||
      default_config = {
 | 
			
		||||
	:idconv => @@idconv,
 | 
			
		||||
	:verbose => @@verbose,
 | 
			
		||||
	:tcp_acl => @@acl,
 | 
			
		||||
| 
						 | 
				
			
			@ -1363,7 +1363,7 @@ module DRb
 | 
			
		|||
    attr_reader :thread
 | 
			
		||||
 | 
			
		||||
    # The front object of the DRbServer.
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    # This object receives remote method calls made on the server's
 | 
			
		||||
    # URI alone, with an object id.
 | 
			
		||||
    attr_reader :front
 | 
			
		||||
| 
						 | 
				
			
			@ -1456,7 +1456,7 @@ module DRb
 | 
			
		|||
    def any_to_s(obj)
 | 
			
		||||
      obj.to_s + ":#{obj.class}"
 | 
			
		||||
    rescue
 | 
			
		||||
      sprintf("#<%s:0x%lx>", obj.class, obj.__id__)      
 | 
			
		||||
      sprintf("#<%s:0x%lx>", obj.class, obj.__id__)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    # Check that a method is callable via dRuby.
 | 
			
		||||
| 
						 | 
				
			
			@ -1464,14 +1464,14 @@ module DRb
 | 
			
		|||
    # +obj+ is the object we want to invoke the method on. +msg_id+ is the
 | 
			
		||||
    # method name, as a Symbol.
 | 
			
		||||
    #
 | 
			
		||||
    # If the method is an insecure method (see #insecure_method?) a 
 | 
			
		||||
    # If the method is an insecure method (see #insecure_method?) a
 | 
			
		||||
    # SecurityError is thrown.  If the method is private or undefined,
 | 
			
		||||
    # a NameError is thrown.
 | 
			
		||||
    def check_insecure_method(obj, msg_id)
 | 
			
		||||
      return true if Proc === obj && msg_id == :__drb_yield
 | 
			
		||||
      raise(ArgumentError, "#{any_to_s(msg_id)} is not a symbol") unless Symbol == msg_id.class
 | 
			
		||||
      raise(SecurityError, "insecure method `#{msg_id}'") if insecure_method?(msg_id)
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      if obj.private_methods.include?(msg_id.to_s)
 | 
			
		||||
	desc = any_to_s(obj)
 | 
			
		||||
        raise NoMethodError, "private method `#{msg_id}' called for #{desc}"
 | 
			
		||||
| 
						 | 
				
			
			@ -1483,7 +1483,7 @@ module DRb
 | 
			
		|||
      end
 | 
			
		||||
    end
 | 
			
		||||
    public :check_insecure_method
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    class InvokeMethod  # :nodoc:
 | 
			
		||||
      def initialize(drb_server, client)
 | 
			
		||||
	@drb_server = drb_server
 | 
			
		||||
| 
						 | 
				
			
			@ -1505,7 +1505,7 @@ module DRb
 | 
			
		|||
              perform_with_block
 | 
			
		||||
            }.value
 | 
			
		||||
          else
 | 
			
		||||
            @result = Thread.new { 
 | 
			
		||||
            @result = Thread.new {
 | 
			
		||||
              Thread.current['DRb'] = info
 | 
			
		||||
              $SAFE = @safe_level
 | 
			
		||||
              perform_without_block
 | 
			
		||||
| 
						 | 
				
			
			@ -1520,7 +1520,7 @@ module DRb
 | 
			
		|||
        end
 | 
			
		||||
	@succ = true
 | 
			
		||||
	if @msg_id == :to_ary && @result.class == Array
 | 
			
		||||
	  @result = DRbArray.new(@result) 
 | 
			
		||||
	  @result = DRbArray.new(@result)
 | 
			
		||||
	end
 | 
			
		||||
	return @succ, @result
 | 
			
		||||
      rescue StandardError, ScriptError, Interrupt
 | 
			
		||||
| 
						 | 
				
			
			@ -1536,7 +1536,7 @@ module DRb
 | 
			
		|||
        @argv = argv
 | 
			
		||||
        @block = block
 | 
			
		||||
      end
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      def check_insecure_method
 | 
			
		||||
        @drb_server.check_insecure_method(@obj, @msg_id)
 | 
			
		||||
      end
 | 
			
		||||
| 
						 | 
				
			
			@ -1545,7 +1545,7 @@ module DRb
 | 
			
		|||
	init_with_client
 | 
			
		||||
	check_insecure_method
 | 
			
		||||
      end
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      def perform_without_block
 | 
			
		||||
	if Proc === @obj && @msg_id == :__drb_yield
 | 
			
		||||
          if @argv.size == 1
 | 
			
		||||
| 
						 | 
				
			
			@ -1633,7 +1633,7 @@ module DRb
 | 
			
		|||
 | 
			
		||||
  # The primary local dRuby server.
 | 
			
		||||
  #
 | 
			
		||||
  # This is the server created by the #start_service call.  
 | 
			
		||||
  # This is the server created by the #start_service call.
 | 
			
		||||
  attr_accessor :primary_server
 | 
			
		||||
  module_function :primary_server=, :primary_server
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1648,8 +1648,8 @@ module DRb
 | 
			
		|||
  # If the above rule fails to find a server, a DRbServerNotFound
 | 
			
		||||
  # error is raised.
 | 
			
		||||
  def current_server
 | 
			
		||||
    drb = Thread.current['DRb'] 
 | 
			
		||||
    server = (drb && drb['server']) ? drb['server'] : @primary_server 
 | 
			
		||||
    drb = Thread.current['DRb']
 | 
			
		||||
    server = (drb && drb['server']) ? drb['server'] : @primary_server
 | 
			
		||||
    raise DRbServerNotFound unless server
 | 
			
		||||
    return server
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			@ -1695,7 +1695,7 @@ module DRb
 | 
			
		|||
    DRbServer.make_config
 | 
			
		||||
  end
 | 
			
		||||
  module_function :config
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  # Get the front object of the current server.
 | 
			
		||||
  #
 | 
			
		||||
  # This raises a DRbServerNotFound error if there is no current server.
 | 
			
		||||
| 
						 | 
				
			
			@ -1766,7 +1766,7 @@ module DRb
 | 
			
		|||
    @server.delete(server.uri)
 | 
			
		||||
  end
 | 
			
		||||
  module_function :remove_server
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  def fetch_server(uri)
 | 
			
		||||
    @server[uri]
 | 
			
		||||
  end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,6 @@
 | 
			
		|||
=begin
 | 
			
		||||
 external service
 | 
			
		||||
 	Copyright (c) 2000,2002 Masatoshi SEKI 
 | 
			
		||||
 	Copyright (c) 2000,2002 Masatoshi SEKI
 | 
			
		||||
=end
 | 
			
		||||
 | 
			
		||||
require 'drb/drb'
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,6 @@
 | 
			
		|||
=begin
 | 
			
		||||
 external service manager
 | 
			
		||||
 	Copyright (c) 2000 Masatoshi SEKI 
 | 
			
		||||
 	Copyright (c) 2000 Masatoshi SEKI
 | 
			
		||||
=end
 | 
			
		||||
 | 
			
		||||
require 'drb/drb'
 | 
			
		||||
| 
						 | 
				
			
			@ -21,7 +21,7 @@ module DRb
 | 
			
		|||
    def self.command=(cmd)
 | 
			
		||||
      @@command = cmd
 | 
			
		||||
    end
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
    def initialize
 | 
			
		||||
      super()
 | 
			
		||||
      @cond = new_cond
 | 
			
		||||
| 
						 | 
				
			
			@ -51,7 +51,7 @@ module DRb
 | 
			
		|||
      end
 | 
			
		||||
      self
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    def unregist(name)
 | 
			
		||||
      synchronize do
 | 
			
		||||
	@servers.delete(name)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,7 +9,7 @@ module DRb
 | 
			
		|||
	end
 | 
			
		||||
        block_value = @block.call(*x)
 | 
			
		||||
      end
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      def perform_with_block
 | 
			
		||||
        @obj.__send__(@msg_id, *@argv) do |*x|
 | 
			
		||||
          jump_error = nil
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,7 +15,7 @@ module DRb
 | 
			
		|||
	:SSLClientCA          => nil,
 | 
			
		||||
	:SSLCACertificatePath => nil,
 | 
			
		||||
	:SSLCACertificateFile => nil,
 | 
			
		||||
	:SSLVerifyMode        => ::OpenSSL::SSL::VERIFY_NONE, 
 | 
			
		||||
	:SSLVerifyMode        => ::OpenSSL::SSL::VERIFY_NONE,
 | 
			
		||||
	:SSLVerifyDepth       => nil,
 | 
			
		||||
	:SSLVerifyCallback    => nil,   # custom verification
 | 
			
		||||
        :SSLCertificateStore  => nil,
 | 
			
		||||
| 
						 | 
				
			
			@ -31,7 +31,7 @@ module DRb
 | 
			
		|||
        @ssl_ctx = nil
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      def [](key); 
 | 
			
		||||
      def [](key);
 | 
			
		||||
	@config[key] || DEFAULT[key]
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -41,14 +41,14 @@ module DRb
 | 
			
		|||
	ssl.connect
 | 
			
		||||
	ssl
 | 
			
		||||
      end
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      def accept(tcp)
 | 
			
		||||
	ssl = OpenSSL::SSL::SSLSocket.new(tcp, @ssl_ctx)
 | 
			
		||||
	ssl.sync = true
 | 
			
		||||
	ssl.accept
 | 
			
		||||
	ssl
 | 
			
		||||
      end
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      def setup_certificate
 | 
			
		||||
        if @cert && @pkey
 | 
			
		||||
          return
 | 
			
		||||
| 
						 | 
				
			
			@ -77,7 +77,7 @@ module DRb
 | 
			
		|||
	cert.not_before = Time.now
 | 
			
		||||
	cert.not_after = Time.now + (365*24*60*60)
 | 
			
		||||
	cert.public_key = rsa.public_key
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
	ef = OpenSSL::X509::ExtensionFactory.new(nil,cert)
 | 
			
		||||
	cert.extensions = [
 | 
			
		||||
	  ef.create_extension("basicConstraints","CA:FALSE"),
 | 
			
		||||
| 
						 | 
				
			
			@ -89,7 +89,7 @@ module DRb
 | 
			
		|||
	  cert.add_extension(ef.create_extension("nsComment", comment))
 | 
			
		||||
	end
 | 
			
		||||
	cert.sign(rsa, OpenSSL::Digest::SHA1.new)
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
	@cert = cert
 | 
			
		||||
        @pkey = rsa
 | 
			
		||||
      end
 | 
			
		||||
| 
						 | 
				
			
			@ -143,7 +143,7 @@ module DRb
 | 
			
		|||
      end
 | 
			
		||||
      port = soc.addr[1] if port == 0
 | 
			
		||||
      @uri = "drbssl://#{host}:#{port}"
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      ssl_conf = SSLConfig.new(config)
 | 
			
		||||
      ssl_conf.setup_certificate
 | 
			
		||||
      ssl_conf.setup_ssl_context
 | 
			
		||||
| 
						 | 
				
			
			@ -159,7 +159,7 @@ module DRb
 | 
			
		|||
      @ssl = is_established ? soc : nil
 | 
			
		||||
      super(uri, soc.to_io, config)
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    def stream; @ssl; end
 | 
			
		||||
 | 
			
		||||
    def close
 | 
			
		||||
| 
						 | 
				
			
			@ -169,12 +169,12 @@ module DRb
 | 
			
		|||
      end
 | 
			
		||||
      super
 | 
			
		||||
    end
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
    def accept
 | 
			
		||||
      begin
 | 
			
		||||
      while true
 | 
			
		||||
	soc = @socket.accept
 | 
			
		||||
	break if (@acl ? @acl.allow_socket?(soc) : true) 
 | 
			
		||||
	break if (@acl ? @acl.allow_socket?(soc) : true)
 | 
			
		||||
	soc.close
 | 
			
		||||
      end
 | 
			
		||||
      ssl = @config.accept(soc)
 | 
			
		||||
| 
						 | 
				
			
			@ -185,6 +185,6 @@ module DRb
 | 
			
		|||
      end
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  DRbProtocol.add_protocol(DRbSSLSocket)
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,7 +19,7 @@ module DRb
 | 
			
		|||
      end
 | 
			
		||||
 | 
			
		||||
      def add(obj)
 | 
			
		||||
	synchronize do 
 | 
			
		||||
	synchronize do
 | 
			
		||||
	  key = obj.__id__
 | 
			
		||||
	  @curr[key] = obj
 | 
			
		||||
	  return key
 | 
			
		||||
| 
						 | 
				
			
			@ -27,7 +27,7 @@ module DRb
 | 
			
		|||
      end
 | 
			
		||||
 | 
			
		||||
      def fetch(key, dv=@sentinel)
 | 
			
		||||
	synchronize do 
 | 
			
		||||
	synchronize do
 | 
			
		||||
	  obj = peek(key)
 | 
			
		||||
	  if obj == @sentinel
 | 
			
		||||
	    return dv unless dv == @sentinel
 | 
			
		||||
| 
						 | 
				
			
			@ -39,7 +39,7 @@ module DRb
 | 
			
		|||
      end
 | 
			
		||||
 | 
			
		||||
      def include?(key)
 | 
			
		||||
	synchronize do 
 | 
			
		||||
	synchronize do
 | 
			
		||||
	  obj = peek(key)
 | 
			
		||||
	  return false if obj == @sentinel
 | 
			
		||||
	  true
 | 
			
		||||
| 
						 | 
				
			
			@ -47,7 +47,7 @@ module DRb
 | 
			
		|||
      end
 | 
			
		||||
 | 
			
		||||
      def peek(key)
 | 
			
		||||
	synchronize do 
 | 
			
		||||
	synchronize do
 | 
			
		||||
	  return @curr.fetch(key, @renew.fetch(key, @gc.fetch(key, @sentinel)))
 | 
			
		||||
	end
 | 
			
		||||
      end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,7 +8,7 @@ module DRb
 | 
			
		|||
 | 
			
		||||
  class DRbUNIXSocket < DRbTCPSocket
 | 
			
		||||
    def self.parse_uri(uri)
 | 
			
		||||
      if /^drbunix:(.*?)(\?(.*))?$/ =~ uri 
 | 
			
		||||
      if /^drbunix:(.*?)(\?(.*))?$/ =~ uri
 | 
			
		||||
	filename = $1
 | 
			
		||||
	option = $3
 | 
			
		||||
	[filename, option]
 | 
			
		||||
| 
						 | 
				
			
			@ -59,7 +59,7 @@ module DRb
 | 
			
		|||
      @server_mode = server_mode
 | 
			
		||||
      @acl = nil
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    # import from tempfile.rb
 | 
			
		||||
    Max_try = 10
 | 
			
		||||
    private
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -59,7 +59,7 @@ module Exception2MessageMapper
 | 
			
		|||
    super
 | 
			
		||||
    cl.bind(self) unless cl == E2MM
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  # backward compatibility
 | 
			
		||||
  def E2MM.extend_to(b)
 | 
			
		||||
    c = eval("self", b)
 | 
			
		||||
| 
						 | 
				
			
			@ -91,7 +91,7 @@ module Exception2MessageMapper
 | 
			
		|||
  # backward compatibility
 | 
			
		||||
  alias fail! fail
 | 
			
		||||
  def fail(err = nil, *rest)
 | 
			
		||||
    begin 
 | 
			
		||||
    begin
 | 
			
		||||
      E2MM.Fail(self, err, *rest)
 | 
			
		||||
    rescue E2MM::ErrNotRegisteredException
 | 
			
		||||
      super
 | 
			
		||||
| 
						 | 
				
			
			@ -101,7 +101,7 @@ module Exception2MessageMapper
 | 
			
		|||
    public :fail
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  # def_e2message(c, m)
 | 
			
		||||
  #	    c:  exception
 | 
			
		||||
  #	    m:  message_form
 | 
			
		||||
| 
						 | 
				
			
			@ -110,7 +110,7 @@ module Exception2MessageMapper
 | 
			
		|||
  def def_e2message(c, m)
 | 
			
		||||
    E2MM.def_e2message(self, c, m)
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  # def_exception(n, m, s)
 | 
			
		||||
  #	    n:  exception_name
 | 
			
		||||
  #	    m:  message_form
 | 
			
		||||
| 
						 | 
				
			
			@ -137,7 +137,7 @@ module Exception2MessageMapper
 | 
			
		|||
    E2MM.instance_eval{@MessageMap[[k, c]] = m}
 | 
			
		||||
    c
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  # E2MM.def_exception(k, n, m, s)
 | 
			
		||||
  #	    k:  class to define exception under.
 | 
			
		||||
  #	    n:  exception_name
 | 
			
		||||
| 
						 | 
				
			
			@ -187,8 +187,8 @@ module Exception2MessageMapper
 | 
			
		|||
    alias message e2mm_message
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  E2MM.def_exception(E2MM, 
 | 
			
		||||
		     :ErrNotRegisteredException, 
 | 
			
		||||
  E2MM.def_exception(E2MM,
 | 
			
		||||
		     :ErrNotRegisteredException,
 | 
			
		||||
		     "not registerd exception(%s)")
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										128
									
								
								lib/erb.rb
									
										
									
									
									
								
							
							
						
						
									
										128
									
								
								lib/erb.rb
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -20,7 +20,7 @@
 | 
			
		|||
# purposes of generating document information details and/or flow control.
 | 
			
		||||
#
 | 
			
		||||
# A very simple example is this:
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
#   require 'erb'
 | 
			
		||||
#
 | 
			
		||||
#   x = 42
 | 
			
		||||
| 
						 | 
				
			
			@ -68,39 +68,39 @@
 | 
			
		|||
# <tt>%q{...}</tt> to avoid trouble with the backslash.
 | 
			
		||||
#
 | 
			
		||||
#   require "erb"
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#   # Create template.
 | 
			
		||||
#   template = %q{
 | 
			
		||||
#     From:  James Edward Gray II <james@grayproductions.net>
 | 
			
		||||
#     To:  <%= to %>
 | 
			
		||||
#     Subject:  Addressing Needs
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#     <%= to[/\w+/] %>:
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#     Just wanted to send a quick note assuring that your needs are being
 | 
			
		||||
#     addressed.
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#     I want you to know that my team will keep working on the issues,
 | 
			
		||||
#     especially:
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#     <%# ignore numerous minor requests -- focus on priorities %>
 | 
			
		||||
#     % priorities.each do |priority|
 | 
			
		||||
#       * <%= priority %>
 | 
			
		||||
#     % end
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#     Thanks for your patience.
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#     James Edward Gray II
 | 
			
		||||
#   }.gsub(/^  /, '')
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#   message = ERB.new(template, 0, "%<>")
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#   # Set up template data.
 | 
			
		||||
#   to = "Community Spokesman <spokesman@ruby_community.org>"
 | 
			
		||||
#   priorities = [ "Run Ruby Quiz",
 | 
			
		||||
#                  "Document Modules",
 | 
			
		||||
#                  "Answer Questions on Ruby Talk" ]
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#   # Produce result.
 | 
			
		||||
#   email = message.result
 | 
			
		||||
#   puts email
 | 
			
		||||
| 
						 | 
				
			
			@ -110,19 +110,19 @@
 | 
			
		|||
#   From:  James Edward Gray II <james@grayproductions.net>
 | 
			
		||||
#   To:  Community Spokesman <spokesman@ruby_community.org>
 | 
			
		||||
#   Subject:  Addressing Needs
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#   Community:
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#   Just wanted to send a quick note assuring that your needs are being addressed.
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#   I want you to know that my team will keep working on the issues, especially:
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#       * Run Ruby Quiz
 | 
			
		||||
#       * Document Modules
 | 
			
		||||
#       * Answer Questions on Ruby Talk
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#   Thanks for your patience.
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#   James Edward Gray II
 | 
			
		||||
#
 | 
			
		||||
# === Ruby in HTML
 | 
			
		||||
| 
						 | 
				
			
			@ -132,7 +132,7 @@
 | 
			
		|||
# variables in the Product object can be resolved.
 | 
			
		||||
#
 | 
			
		||||
#   require "erb"
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#   # Build template data class.
 | 
			
		||||
#   class Product
 | 
			
		||||
#     def initialize( code, name, desc, cost )
 | 
			
		||||
| 
						 | 
				
			
			@ -140,37 +140,37 @@
 | 
			
		|||
#       @name = name
 | 
			
		||||
#       @desc = desc
 | 
			
		||||
#       @cost = cost
 | 
			
		||||
#        	
 | 
			
		||||
#
 | 
			
		||||
#       @features = [ ]
 | 
			
		||||
#     end
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#     def add_feature( feature )
 | 
			
		||||
#       @features << feature
 | 
			
		||||
#     end
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#     # Support templating of member data.
 | 
			
		||||
#     def get_binding
 | 
			
		||||
#       binding
 | 
			
		||||
#     end
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#     # ...
 | 
			
		||||
#   end
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#   # Create template.
 | 
			
		||||
#   template = %{
 | 
			
		||||
#     <html>
 | 
			
		||||
#       <head><title>Ruby Toys -- <%= @name %></title></head>
 | 
			
		||||
#       <body>
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#         <h1><%= @name %> (<%= @code %>)</h1>
 | 
			
		||||
#         <p><%= @desc %></p>
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#         <ul>
 | 
			
		||||
#           <% @features.each do |f| %>
 | 
			
		||||
#             <li><b><%= f %></b></li>
 | 
			
		||||
#           <% end %>
 | 
			
		||||
#         </ul>
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#         <p>
 | 
			
		||||
#           <% if @cost < 10 %>
 | 
			
		||||
#             <b>Only <%= @cost %>!!!</b>
 | 
			
		||||
| 
						 | 
				
			
			@ -178,13 +178,13 @@
 | 
			
		|||
#              Call for a price, today!
 | 
			
		||||
#           <% end %>
 | 
			
		||||
#         </p>
 | 
			
		||||
#    
 | 
			
		||||
#
 | 
			
		||||
#       </body>
 | 
			
		||||
#     </html>
 | 
			
		||||
#   }.gsub(/^  /, '')
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#   rhtml = ERB.new(template)
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#   # Set up template data.
 | 
			
		||||
#   toy = Product.new( "TZ-1002",
 | 
			
		||||
#                      "Rubysapien",
 | 
			
		||||
| 
						 | 
				
			
			@ -195,7 +195,7 @@
 | 
			
		|||
#   toy.add_feature("Karate-Chop Action!!!")
 | 
			
		||||
#   toy.add_feature("Matz signature on left leg.")
 | 
			
		||||
#   toy.add_feature("Gem studded eyes... Rubies, of course!")
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#   # Produce result.
 | 
			
		||||
#   rhtml.run(toy.get_binding)
 | 
			
		||||
#
 | 
			
		||||
| 
						 | 
				
			
			@ -204,10 +204,10 @@
 | 
			
		|||
#    <html>
 | 
			
		||||
#      <head><title>Ruby Toys -- Rubysapien</title></head>
 | 
			
		||||
#      <body>
 | 
			
		||||
#    
 | 
			
		||||
#
 | 
			
		||||
#        <h1>Rubysapien (TZ-1002)</h1>
 | 
			
		||||
#        <p>Geek's Best Friend!  Responds to Ruby commands...</p>
 | 
			
		||||
#    
 | 
			
		||||
#
 | 
			
		||||
#        <ul>
 | 
			
		||||
#            <li><b>Listens for verbal commands in the Ruby language!</b></li>
 | 
			
		||||
#            <li><b>Ignores Perl, Java, and all C variants.</b></li>
 | 
			
		||||
| 
						 | 
				
			
			@ -215,15 +215,15 @@
 | 
			
		|||
#            <li><b>Matz signature on left leg.</b></li>
 | 
			
		||||
#            <li><b>Gem studded eyes... Rubies, of course!</b></li>
 | 
			
		||||
#        </ul>
 | 
			
		||||
#    
 | 
			
		||||
#
 | 
			
		||||
#        <p>
 | 
			
		||||
#             Call for a price, today!
 | 
			
		||||
#        </p>
 | 
			
		||||
#    
 | 
			
		||||
#
 | 
			
		||||
#      </body>
 | 
			
		||||
#    </html>
 | 
			
		||||
#
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
# == Notes
 | 
			
		||||
#
 | 
			
		||||
# There are a variety of templating solutions available in various Ruby projects:
 | 
			
		||||
| 
						 | 
				
			
			@ -300,7 +300,7 @@ class ERB
 | 
			
		|||
	end
 | 
			
		||||
      end
 | 
			
		||||
      attr_accessor :stag
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      def scan(&block)
 | 
			
		||||
	@stag = nil
 | 
			
		||||
	if @percent
 | 
			
		||||
| 
						 | 
				
			
			@ -407,7 +407,7 @@ class ERB
 | 
			
		|||
	end
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    Scanner.regist_scanner(SimpleScanner, nil, false)
 | 
			
		||||
 | 
			
		||||
    begin
 | 
			
		||||
| 
						 | 
				
			
			@ -466,13 +466,13 @@ class ERB
 | 
			
		|||
      def push(cmd)
 | 
			
		||||
	@line << cmd
 | 
			
		||||
      end
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      def cr
 | 
			
		||||
	@script << (@line.join('; '))
 | 
			
		||||
	@line = []
 | 
			
		||||
	@script << "\n"
 | 
			
		||||
      end
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      def close
 | 
			
		||||
	return unless @line
 | 
			
		||||
	@compiler.post_cmd.each do |x|
 | 
			
		||||
| 
						 | 
				
			
			@ -498,7 +498,7 @@ class ERB
 | 
			
		|||
      content = ''
 | 
			
		||||
      scanner = make_scanner(s)
 | 
			
		||||
      scanner.scan do |token|
 | 
			
		||||
        next if token.nil? 
 | 
			
		||||
        next if token.nil?
 | 
			
		||||
        next if token == ''
 | 
			
		||||
	if scanner.stag.nil?
 | 
			
		||||
	  case token
 | 
			
		||||
| 
						 | 
				
			
			@ -598,19 +598,19 @@ end
 | 
			
		|||
class ERB
 | 
			
		||||
  #
 | 
			
		||||
  # Constructs a new ERB object with the template specified in _str_.
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  # An ERB object works by building a chunk of Ruby code that will output
 | 
			
		||||
  # the completed template when run. If _safe_level_ is set to a non-nil value,
 | 
			
		||||
  # ERB code will be run in a separate thread with <b>$SAFE</b> set to the
 | 
			
		||||
  # provided level.
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  # If _trim_mode_ is passed a String containing one or more of the following
 | 
			
		||||
  # modifiers, ERB will adjust its code generation as listed:
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  # 	%  enables Ruby code processing for lines beginning with %
 | 
			
		||||
  # 	<> omit newline for lines starting with <% and ending in %>
 | 
			
		||||
  # 	>  omit newline for lines ending in %>
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  # _eoutvar_ can be used to set the name of the variable ERB will build up
 | 
			
		||||
  # its output in.  This is useful when you need to run multiple ERB
 | 
			
		||||
  # templates through the same binding and/or when you want to control where
 | 
			
		||||
| 
						 | 
				
			
			@ -619,20 +619,20 @@ class ERB
 | 
			
		|||
  # === Example
 | 
			
		||||
  #
 | 
			
		||||
  #  require "erb"
 | 
			
		||||
  #  
 | 
			
		||||
  #
 | 
			
		||||
  #  # build data class
 | 
			
		||||
  #  class Listings
 | 
			
		||||
  #    PRODUCT = { :name => "Chicken Fried Steak",
 | 
			
		||||
  #                :desc => "A well messages pattie, breaded and fried.",
 | 
			
		||||
  #                :cost => 9.95 }
 | 
			
		||||
  #  
 | 
			
		||||
  #
 | 
			
		||||
  #    attr_reader :product, :price
 | 
			
		||||
  #    
 | 
			
		||||
  #
 | 
			
		||||
  #    def initialize( product = "", price = "" )
 | 
			
		||||
  #      @product = product
 | 
			
		||||
  #      @price = price
 | 
			
		||||
  #    end
 | 
			
		||||
  #    
 | 
			
		||||
  #
 | 
			
		||||
  #    def build
 | 
			
		||||
  #      b = binding
 | 
			
		||||
  #      # create and run templates, filling member data variables
 | 
			
		||||
| 
						 | 
				
			
			@ -646,21 +646,21 @@ class ERB
 | 
			
		|||
  #      END_PRICE
 | 
			
		||||
  #    end
 | 
			
		||||
  #  end
 | 
			
		||||
  #  
 | 
			
		||||
  #
 | 
			
		||||
  #  # setup template data
 | 
			
		||||
  #  listings = Listings.new
 | 
			
		||||
  #  listings.build
 | 
			
		||||
  #  
 | 
			
		||||
  #
 | 
			
		||||
  #  puts listings.product + "\n" + listings.price
 | 
			
		||||
  #
 | 
			
		||||
  # _Generates_
 | 
			
		||||
  #
 | 
			
		||||
  #  Chicken Fried Steak
 | 
			
		||||
  #  A well messages pattie, breaded and fried.
 | 
			
		||||
  #  
 | 
			
		||||
  #
 | 
			
		||||
  #  Chicken Fried Steak -- 9.95
 | 
			
		||||
  #  A well messages pattie, breaded and fried.
 | 
			
		||||
  #  
 | 
			
		||||
  #
 | 
			
		||||
  def initialize(str, safe_level=nil, trim_mode=nil, eoutvar='_erbout')
 | 
			
		||||
    @safe_level = safe_level
 | 
			
		||||
    compiler = ERB::Compiler.new(trim_mode)
 | 
			
		||||
| 
						 | 
				
			
			@ -687,7 +687,7 @@ class ERB
 | 
			
		|||
 | 
			
		||||
    cmd = []
 | 
			
		||||
    cmd.push "#{eoutvar} = ''"
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    compiler.pre_cmd = cmd
 | 
			
		||||
 | 
			
		||||
    cmd = []
 | 
			
		||||
| 
						 | 
				
			
			@ -705,13 +705,13 @@ class ERB
 | 
			
		|||
  # Executes the generated ERB code to produce a completed template, returning
 | 
			
		||||
  # the results of that code.  (See ERB#new for details on how this process can
 | 
			
		||||
  # be affected by _safe_level_.)
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  # _b_ accepts a Binding or Proc object which is used to set the context of
 | 
			
		||||
  # code evaluation.
 | 
			
		||||
  #
 | 
			
		||||
  def result(b=TOPLEVEL_BINDING)
 | 
			
		||||
    if @safe_level
 | 
			
		||||
      proc { 
 | 
			
		||||
      proc {
 | 
			
		||||
	$SAFE = @safe_level
 | 
			
		||||
	eval(@src, b, (@filename || '(erb)'), 1)
 | 
			
		||||
      }.call
 | 
			
		||||
| 
						 | 
				
			
			@ -775,14 +775,14 @@ class ERB
 | 
			
		|||
    public
 | 
			
		||||
    #
 | 
			
		||||
    # A utility method for escaping HTML tag characters in _s_.
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    # 	require "erb"
 | 
			
		||||
    # 	include ERB::Util
 | 
			
		||||
    # 	
 | 
			
		||||
    #
 | 
			
		||||
    # 	puts html_escape("is a > 0 & a < 10?")
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    # _Generates_
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    # 	is a > 0 & a < 10?
 | 
			
		||||
    #
 | 
			
		||||
    def html_escape(s)
 | 
			
		||||
| 
						 | 
				
			
			@ -791,17 +791,17 @@ class ERB
 | 
			
		|||
    alias h html_escape
 | 
			
		||||
    module_function :h
 | 
			
		||||
    module_function :html_escape
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    #
 | 
			
		||||
    # A utility method for encoding the String _s_ as a URL.
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    # 	require "erb"
 | 
			
		||||
    # 	include ERB::Util
 | 
			
		||||
    # 	
 | 
			
		||||
    #
 | 
			
		||||
    # 	puts url_encode("Programming Ruby:  The Pragmatic Programmer's Guide")
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    # _Generates_
 | 
			
		||||
    # 
 | 
			
		||||
    #
 | 
			
		||||
    # 	Programming%20Ruby%3A%20%20The%20Pragmatic%20Programmer%27s%20Guide
 | 
			
		||||
    #
 | 
			
		||||
    def url_encode(s)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										172
									
								
								lib/fileutils.rb
									
										
									
									
									
								
							
							
						
						
									
										172
									
								
								lib/fileutils.rb
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1,17 +1,17 @@
 | 
			
		|||
# 
 | 
			
		||||
#
 | 
			
		||||
# = fileutils.rb
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
# Copyright (c) 2000-2006 Minero Aoki
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
# This program is free software.
 | 
			
		||||
# You can distribute/modify this program under the same terms of ruby.
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
# == module FileUtils
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
# Namespace for several file utility methods for copying, moving, removing, etc.
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
# === Module Functions
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
#   cd(dir, options)
 | 
			
		||||
#   cd(dir, options) {|dir| .... }
 | 
			
		||||
#   pwd()
 | 
			
		||||
| 
						 | 
				
			
			@ -64,23 +64,23 @@
 | 
			
		|||
#   uptodate?(file, cmp_list)
 | 
			
		||||
#
 | 
			
		||||
# == module FileUtils::Verbose
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
# This module has all methods of FileUtils module, but it outputs messages
 | 
			
		||||
# before acting.  This equates to passing the <tt>:verbose</tt> flag to methods
 | 
			
		||||
# in FileUtils.
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
# == module FileUtils::NoWrite
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
# This module has all methods of FileUtils module, but never changes
 | 
			
		||||
# files/directories.  This equates to passing the <tt>:noop</tt> flag to methods
 | 
			
		||||
# in FileUtils.
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
# == module FileUtils::DryRun
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
# This module has all methods of FileUtils module, but never changes
 | 
			
		||||
# files/directories.  This equates to passing the <tt>:noop</tt> and
 | 
			
		||||
# <tt>:verbose</tt> flags to methods in FileUtils.
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
module FileUtils
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -107,14 +107,14 @@ module FileUtils
 | 
			
		|||
 | 
			
		||||
  #
 | 
			
		||||
  # Options: verbose
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  # Changes the current directory to the directory +dir+.
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  # If this method is called with block, resumes to the old
 | 
			
		||||
  # working directory after the block execution finished.
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  #   FileUtils.cd('/', :verbose => true)   # chdir and report it
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  def cd(dir, options = {}, &block) # :yield: dir
 | 
			
		||||
    fu_check_options options, OPT_TABLE['cd']
 | 
			
		||||
    fu_output_message "cd #{dir}" if options[:verbose]
 | 
			
		||||
| 
						 | 
				
			
			@ -131,13 +131,13 @@ module FileUtils
 | 
			
		|||
 | 
			
		||||
  #
 | 
			
		||||
  # Options: (none)
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  # Returns true if +newer+ is newer than all +old_list+.
 | 
			
		||||
  # Non-existent files are older than any file.
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  #   FileUtils.uptodate?('hello.o', %w(hello.c hello.h)) or \
 | 
			
		||||
  #       system 'make hello.o'
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  def uptodate?(new, old_list, options = nil)
 | 
			
		||||
    raise ArgumentError, 'uptodate? does not accept any option' if options
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -154,14 +154,14 @@ module FileUtils
 | 
			
		|||
 | 
			
		||||
  #
 | 
			
		||||
  # Options: mode noop verbose
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  # Creates one or more directories.
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  #   FileUtils.mkdir 'test'
 | 
			
		||||
  #   FileUtils.mkdir %w( tmp data )
 | 
			
		||||
  #   FileUtils.mkdir 'notexist', :noop => true  # Does not really create.
 | 
			
		||||
  #   FileUtils.mkdir 'tmp', :mode => 0700
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  def mkdir(list, options = {})
 | 
			
		||||
    fu_check_options options, OPT_TABLE['mkdir']
 | 
			
		||||
    list = fu_list(list)
 | 
			
		||||
| 
						 | 
				
			
			@ -178,12 +178,12 @@ module FileUtils
 | 
			
		|||
 | 
			
		||||
  #
 | 
			
		||||
  # Options: mode noop verbose
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  # Creates a directory and all its parent directories.
 | 
			
		||||
  # For example,
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  #   FileUtils.mkdir_p '/usr/local/lib/ruby'
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  # causes to make following directories, if it does not exist.
 | 
			
		||||
  #     * /usr
 | 
			
		||||
  #     * /usr/local
 | 
			
		||||
| 
						 | 
				
			
			@ -191,7 +191,7 @@ module FileUtils
 | 
			
		|||
  #     * /usr/local/lib/ruby
 | 
			
		||||
  #
 | 
			
		||||
  # You can pass several directories at a time in a list.
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  def mkdir_p(list, options = {})
 | 
			
		||||
    fu_check_options options, OPT_TABLE['mkdir_p']
 | 
			
		||||
    list = fu_list(list)
 | 
			
		||||
| 
						 | 
				
			
			@ -247,14 +247,14 @@ module FileUtils
 | 
			
		|||
 | 
			
		||||
  #
 | 
			
		||||
  # Options: noop, verbose
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  # Removes one or more directories.
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  #   FileUtils.rmdir 'somedir'
 | 
			
		||||
  #   FileUtils.rmdir %w(somedir anydir otherdir)
 | 
			
		||||
  #   # Does not really remove directory; outputs message.
 | 
			
		||||
  #   FileUtils.rmdir 'somedir', :verbose => true, :noop => true
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  def rmdir(list, options = {})
 | 
			
		||||
    fu_check_options options, OPT_TABLE['rmdir']
 | 
			
		||||
    list = fu_list(list)
 | 
			
		||||
| 
						 | 
				
			
			@ -277,19 +277,19 @@ module FileUtils
 | 
			
		|||
  # If +new+ already exists and it is a directory, creates a link +new/old+.
 | 
			
		||||
  # If +new+ already exists and it is not a directory, raises Errno::EEXIST.
 | 
			
		||||
  # But if :force option is set, overwrite +new+.
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  #   FileUtils.ln 'gcc', 'cc', :verbose => true
 | 
			
		||||
  #   FileUtils.ln '/usr/bin/emacs21', '/usr/bin/emacs'
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  # <b><tt>ln(list, destdir, options = {})</tt></b>
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  # Creates several hard links in a directory, with each one pointing to the
 | 
			
		||||
  # item in +list+.  If +destdir+ is not a directory, raises Errno::ENOTDIR.
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  #   include FileUtils
 | 
			
		||||
  #   cd '/sbin'
 | 
			
		||||
  #   FileUtils.ln %w(cp mv mkdir), '/bin'   # Now /sbin/cp and /bin/cp are linked.
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  def ln(src, dest, options = {})
 | 
			
		||||
    fu_check_options options, OPT_TABLE['ln']
 | 
			
		||||
    fu_output_message "ln#{options[:force] ? ' -f' : ''} #{[src,dest].flatten.join ' '}" if options[:verbose]
 | 
			
		||||
| 
						 | 
				
			
			@ -311,24 +311,24 @@ module FileUtils
 | 
			
		|||
  # Options: force noop verbose
 | 
			
		||||
  #
 | 
			
		||||
  # <b><tt>ln_s(old, new, options = {})</tt></b>
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  # Creates a symbolic link +new+ which points to +old+.  If +new+ already
 | 
			
		||||
  # exists and it is a directory, creates a symbolic link +new/old+.  If +new+
 | 
			
		||||
  # already exists and it is not a directory, raises Errno::EEXIST.  But if
 | 
			
		||||
  # :force option is set, overwrite +new+.
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  #   FileUtils.ln_s '/usr/bin/ruby', '/usr/local/bin/ruby'
 | 
			
		||||
  #   FileUtils.ln_s 'verylongsourcefilename.c', 'c', :force => true
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  # <b><tt>ln_s(list, destdir, options = {})</tt></b>
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  # Creates several symbolic links in a directory, with each one pointing to the
 | 
			
		||||
  # item in +list+.  If +destdir+ is not a directory, raises Errno::ENOTDIR.
 | 
			
		||||
  #
 | 
			
		||||
  # If +destdir+ is not a directory, raises Errno::ENOTDIR.
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  #   FileUtils.ln_s Dir.glob('bin/*.rb'), '/home/aamine/bin'
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  def ln_s(src, dest, options = {})
 | 
			
		||||
    fu_check_options options, OPT_TABLE['ln_s']
 | 
			
		||||
    fu_output_message "ln -s#{options[:force] ? 'f' : ''} #{[src,dest].flatten.join ' '}" if options[:verbose]
 | 
			
		||||
| 
						 | 
				
			
			@ -348,10 +348,10 @@ module FileUtils
 | 
			
		|||
 | 
			
		||||
  #
 | 
			
		||||
  # Options: noop verbose
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  # Same as
 | 
			
		||||
  #   #ln_s(src, dest, :force)
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  def ln_sf(src, dest, options = {})
 | 
			
		||||
    fu_check_options options, OPT_TABLE['ln_sf']
 | 
			
		||||
    options = options.dup
 | 
			
		||||
| 
						 | 
				
			
			@ -374,7 +374,7 @@ module FileUtils
 | 
			
		|||
  #   FileUtils.cp %w(cgi.rb complex.rb date.rb), '/usr/lib/ruby/1.6'
 | 
			
		||||
  #   FileUtils.cp %w(cgi.rb complex.rb date.rb), '/usr/lib/ruby/1.6', :verbose => true
 | 
			
		||||
  #   FileUtils.cp 'symlink', 'dest'   # copy content, "dest" is not a symlink
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  def cp(src, dest, options = {})
 | 
			
		||||
    fu_check_options options, OPT_TABLE['cp']
 | 
			
		||||
    fu_output_message "cp#{options[:preserve] ? ' -p' : ''} #{[src,dest].flatten.join ' '}" if options[:verbose]
 | 
			
		||||
| 
						 | 
				
			
			@ -393,17 +393,17 @@ module FileUtils
 | 
			
		|||
 | 
			
		||||
  #
 | 
			
		||||
  # Options: preserve noop verbose dereference_root remove_destination
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  # Copies +src+ to +dest+. If +src+ is a directory, this method copies
 | 
			
		||||
  # all its contents recursively. If +dest+ is a directory, copies
 | 
			
		||||
  # +src+ to +dest/src+.
 | 
			
		||||
  #
 | 
			
		||||
  # +src+ can be a list of files.
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  #   # Installing ruby library "mylib" under the site_ruby
 | 
			
		||||
  #   FileUtils.rm_r site_ruby + '/mylib', :force
 | 
			
		||||
  #   FileUtils.cp_r 'lib/', site_ruby + '/mylib'
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  #   # Examples of copying several files to target directory.
 | 
			
		||||
  #   FileUtils.cp_r %w(mail.rb field.rb debug/), site_ruby + '/tmail'
 | 
			
		||||
  #   FileUtils.cp_r Dir.glob('*.rb'), '/home/aamine/lib/ruby', :noop => true, :verbose => true
 | 
			
		||||
| 
						 | 
				
			
			@ -413,7 +413,7 @@ module FileUtils
 | 
			
		|||
  #   # use following code.
 | 
			
		||||
  #   FileUtils.cp_r 'src/.', 'dest'     # cp_r('src', 'dest') makes src/dest,
 | 
			
		||||
  #                                      # but this doesn't.
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  def cp_r(src, dest, options = {})
 | 
			
		||||
    fu_check_options options, OPT_TABLE['cp_r']
 | 
			
		||||
    fu_output_message "cp -r#{options[:preserve] ? 'p' : ''}#{options[:remove_destination] ? ' --remove-destination' : ''} #{[src,dest].flatten.join ' '}" if options[:verbose]
 | 
			
		||||
| 
						 | 
				
			
			@ -477,17 +477,17 @@ module FileUtils
 | 
			
		|||
 | 
			
		||||
  #
 | 
			
		||||
  # Options: force noop verbose
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  # Moves file(s) +src+ to +dest+.  If +file+ and +dest+ exist on the different
 | 
			
		||||
  # disk partition, the copied file is created on the +dest+ and the original
 | 
			
		||||
  # file removed from +src+.
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  #   FileUtils.mv 'badname.rb', 'goodname.rb'
 | 
			
		||||
  #   FileUtils.mv 'stuff.rb', '/notexist/lib/ruby', :force => true  # no error
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  #   FileUtils.mv %w(junk.txt dust.txt), '/home/aamine/.trash/'
 | 
			
		||||
  #   FileUtils.mv Dir.glob('test*.rb'), 'test', :noop => true, :verbose => true
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  def mv(src, dest, options = {})
 | 
			
		||||
    fu_check_options options, OPT_TABLE['mv']
 | 
			
		||||
    fu_output_message "mv#{options[:force] ? ' -f' : ''} #{[src,dest].flatten.join ' '}" if options[:verbose]
 | 
			
		||||
| 
						 | 
				
			
			@ -532,14 +532,14 @@ module FileUtils
 | 
			
		|||
 | 
			
		||||
  #
 | 
			
		||||
  # Options: force noop verbose
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  # Remove file(s) specified in +list+.  This method cannot remove directories.
 | 
			
		||||
  # All StandardErrors are ignored when the :force option is set.
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  #   FileUtils.rm %w( junk.txt dust.txt )
 | 
			
		||||
  #   FileUtils.rm Dir.glob('*.so')
 | 
			
		||||
  #   FileUtils.rm 'NotExistFile', :force => true   # never raises exception
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  def rm(list, options = {})
 | 
			
		||||
    fu_check_options options, OPT_TABLE['rm']
 | 
			
		||||
    list = fu_list(list)
 | 
			
		||||
| 
						 | 
				
			
			@ -560,7 +560,7 @@ module FileUtils
 | 
			
		|||
 | 
			
		||||
  #
 | 
			
		||||
  # Options: noop verbose
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  # Equivalent to
 | 
			
		||||
  #
 | 
			
		||||
  #   #rm(list, :force => true)
 | 
			
		||||
| 
						 | 
				
			
			@ -581,11 +581,11 @@ module FileUtils
 | 
			
		|||
 | 
			
		||||
  #
 | 
			
		||||
  # Options: force noop verbose secure
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  # remove files +list+[0] +list+[1]... If +list+[n] is a directory,
 | 
			
		||||
  # removes its all contents recursively. This method ignores
 | 
			
		||||
  # StandardError when :force option is set.
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  #   FileUtils.rm_r Dir.glob('/tmp/*')
 | 
			
		||||
  #   FileUtils.rm_r '/', :force => true          #  :-)
 | 
			
		||||
  #
 | 
			
		||||
| 
						 | 
				
			
			@ -599,7 +599,7 @@ module FileUtils
 | 
			
		|||
  #
 | 
			
		||||
  # NOTE: This method calls #remove_entry_secure if :secure option is set.
 | 
			
		||||
  # See also #remove_entry_secure.
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  def rm_r(list, options = {})
 | 
			
		||||
    fu_check_options options, OPT_TABLE['rm_r']
 | 
			
		||||
    # options[:secure] = true unless options.key?(:secure)
 | 
			
		||||
| 
						 | 
				
			
			@ -620,14 +620,14 @@ module FileUtils
 | 
			
		|||
 | 
			
		||||
  #
 | 
			
		||||
  # Options: noop verbose secure
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  # Equivalent to
 | 
			
		||||
  #
 | 
			
		||||
  #   #rm_r(list, :force => true)
 | 
			
		||||
  #
 | 
			
		||||
  # WARNING: This method causes local vulnerability.
 | 
			
		||||
  # Read the documentation of #rm_r first.
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  def rm_rf(list, options = {})
 | 
			
		||||
    fu_check_options options, OPT_TABLE['rm_rf']
 | 
			
		||||
    options = options.dup
 | 
			
		||||
| 
						 | 
				
			
			@ -786,7 +786,7 @@ module FileUtils
 | 
			
		|||
 | 
			
		||||
  #
 | 
			
		||||
  # Returns true if the contents of a file A and a file B are identical.
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  #   FileUtils.compare_file('somefile', 'somefile')  #=> true
 | 
			
		||||
  #   FileUtils.compare_file('/bin/cp', '/bin/mv')    #=> maybe false
 | 
			
		||||
  #
 | 
			
		||||
| 
						 | 
				
			
			@ -826,14 +826,14 @@ module FileUtils
 | 
			
		|||
 | 
			
		||||
  #
 | 
			
		||||
  # Options: mode preserve noop verbose
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  # If +src+ is not same as +dest+, copies it and changes the permission
 | 
			
		||||
  # mode to +mode+.  If +dest+ is a directory, destination is +dest+/+src+.
 | 
			
		||||
  # This method removes destination before copy.
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  #   FileUtils.install 'ruby', '/usr/local/bin/ruby', :mode => 0755, :verbose => true
 | 
			
		||||
  #   FileUtils.install 'lib.rb', '/usr/local/lib/ruby/site_ruby', :verbose => true
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  def install(src, dest, options = {})
 | 
			
		||||
    fu_check_options options, OPT_TABLE['install']
 | 
			
		||||
    fu_output_message "install -c#{options[:preserve] && ' -p'}#{options[:mode] ? (' -m 0%o' % options[:mode]) : ''} #{[src,dest].flatten.join ' '}" if options[:verbose]
 | 
			
		||||
| 
						 | 
				
			
			@ -854,14 +854,14 @@ module FileUtils
 | 
			
		|||
 | 
			
		||||
  #
 | 
			
		||||
  # Options: noop verbose
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  # Changes permission bits on the named files (in +list+) to the bit pattern
 | 
			
		||||
  # represented by +mode+.
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  #   FileUtils.chmod 0755, 'somecommand'
 | 
			
		||||
  #   FileUtils.chmod 0644, %w(my.rb your.rb his.rb her.rb)
 | 
			
		||||
  #   FileUtils.chmod 0755, '/usr/bin/ruby', :verbose => true
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  def chmod(mode, list, options = {})
 | 
			
		||||
    fu_check_options options, OPT_TABLE['chmod']
 | 
			
		||||
    list = fu_list(list)
 | 
			
		||||
| 
						 | 
				
			
			@ -877,12 +877,12 @@ module FileUtils
 | 
			
		|||
 | 
			
		||||
  #
 | 
			
		||||
  # Options: noop verbose force
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  # Changes permission bits on the named files (in +list+)
 | 
			
		||||
  # to the bit pattern represented by +mode+.
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  #   FileUtils.chmod_R 0700, "/tmp/app.#{$$}"
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  def chmod_R(mode, list, options = {})
 | 
			
		||||
    fu_check_options options, OPT_TABLE['chmod_R']
 | 
			
		||||
    list = fu_list(list)
 | 
			
		||||
| 
						 | 
				
			
			@ -906,16 +906,16 @@ module FileUtils
 | 
			
		|||
 | 
			
		||||
  #
 | 
			
		||||
  # Options: noop verbose
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  # Changes owner and group on the named files (in +list+)
 | 
			
		||||
  # to the user +user+ and the group +group+.  +user+ and +group+
 | 
			
		||||
  # may be an ID (Integer/String) or a name (String).
 | 
			
		||||
  # If +user+ or +group+ is nil, this method does not change
 | 
			
		||||
  # the attribute.
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  #   FileUtils.chown 'root', 'staff', '/usr/local/bin/ruby'
 | 
			
		||||
  #   FileUtils.chown nil, 'bin', Dir.glob('/usr/bin/*'), :verbose => true
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  def chown(user, group, list, options = {})
 | 
			
		||||
    fu_check_options options, OPT_TABLE['chown']
 | 
			
		||||
    list = fu_list(list)
 | 
			
		||||
| 
						 | 
				
			
			@ -935,16 +935,16 @@ module FileUtils
 | 
			
		|||
 | 
			
		||||
  #
 | 
			
		||||
  # Options: noop verbose force
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  # Changes owner and group on the named files (in +list+)
 | 
			
		||||
  # to the user +user+ and the group +group+ recursively.
 | 
			
		||||
  # +user+ and +group+ may be an ID (Integer/String) or
 | 
			
		||||
  # a name (String).  If +user+ or +group+ is nil, this
 | 
			
		||||
  # method does not change the attribute.
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  #   FileUtils.chown_R 'www', 'www', '/var/www/htdocs'
 | 
			
		||||
  #   FileUtils.chown_R 'cvs', 'cvs', '/var/cvs', :verbose => true
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  def chown_R(user, group, list, options = {})
 | 
			
		||||
    fu_check_options options, OPT_TABLE['chown_R']
 | 
			
		||||
    list = fu_list(list)
 | 
			
		||||
| 
						 | 
				
			
			@ -1015,13 +1015,13 @@ module FileUtils
 | 
			
		|||
 | 
			
		||||
  #
 | 
			
		||||
  # Options: noop verbose
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  # Updates modification time (mtime) and access time (atime) of file(s) in
 | 
			
		||||
  # +list+.  Files are created if they don't exist.
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  #   FileUtils.touch 'timestamp'
 | 
			
		||||
  #   FileUtils.touch Dir.glob('*.c');  system 'make'
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  def touch(list, options = {})
 | 
			
		||||
    fu_check_options options, OPT_TABLE['touch']
 | 
			
		||||
    list = fu_list(list)
 | 
			
		||||
| 
						 | 
				
			
			@ -1520,11 +1520,11 @@ module FileUtils
 | 
			
		|||
  METHODS = singleton_methods() - %w( private_module_function
 | 
			
		||||
      commands options have_option? options_of collect_method )
 | 
			
		||||
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  # This module has all methods of FileUtils module, but it outputs messages
 | 
			
		||||
  # before acting.  This equates to passing the <tt>:verbose</tt> flag to
 | 
			
		||||
  # methods in FileUtils.
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  module Verbose
 | 
			
		||||
    include FileUtils
 | 
			
		||||
    @fileutils_output  = $stderr
 | 
			
		||||
| 
						 | 
				
			
			@ -1545,11 +1545,11 @@ module FileUtils
 | 
			
		|||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  # This module has all methods of FileUtils module, but never changes
 | 
			
		||||
  # files/directories.  This equates to passing the <tt>:noop</tt> flag
 | 
			
		||||
  # to methods in FileUtils.
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  module NoWrite
 | 
			
		||||
    include FileUtils
 | 
			
		||||
    @fileutils_output  = $stderr
 | 
			
		||||
| 
						 | 
				
			
			@ -1570,12 +1570,12 @@ module FileUtils
 | 
			
		|||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  # This module has all methods of FileUtils module, but never changes
 | 
			
		||||
  # files/directories, with printing message before acting.
 | 
			
		||||
  # This equates to passing the <tt>:noop</tt> and <tt>:verbose</tt> flag
 | 
			
		||||
  # to methods in FileUtils.
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  module DryRun
 | 
			
		||||
    include FileUtils
 | 
			
		||||
    @fileutils_output  = $stderr
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
#--
 | 
			
		||||
#   finalizer.rb - 
 | 
			
		||||
#   finalizer.rb -
 | 
			
		||||
#   	$Release Version: 0.3$
 | 
			
		||||
#   	$Revision: 1.4 $
 | 
			
		||||
#   	$Date: 1998/02/27 05:34:33 $
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -33,28 +33,28 @@
 | 
			
		|||
#
 | 
			
		||||
#   class Queue
 | 
			
		||||
#     extend Forwardable
 | 
			
		||||
#     
 | 
			
		||||
#
 | 
			
		||||
#     def initialize
 | 
			
		||||
#       @q = [ ]    # prepare delegate object
 | 
			
		||||
#     end
 | 
			
		||||
#     
 | 
			
		||||
#
 | 
			
		||||
#     # setup preferred interface, enq() and deq()...
 | 
			
		||||
#     def_delegator :@q, :push, :enq
 | 
			
		||||
#     def_delegator :@q, :shift, :deq
 | 
			
		||||
#     
 | 
			
		||||
#
 | 
			
		||||
#     # support some general Array methods that fit Queues well
 | 
			
		||||
#     def_delegators :@q, :clear, :first, :push, :shift, :size
 | 
			
		||||
#   end
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
#   q = Queue.new
 | 
			
		||||
#   q.enq 1, 2, 3, 4, 5
 | 
			
		||||
#   q.push 6
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
#   q.shift    # => 1
 | 
			
		||||
#   while q.size > 0
 | 
			
		||||
#     puts q.deq
 | 
			
		||||
#   end
 | 
			
		||||
# 
 | 
			
		||||
#
 | 
			
		||||
#   q.enq "Ruby", "Perl", "Python"
 | 
			
		||||
#   puts q.first
 | 
			
		||||
#   q.clear
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,4 @@
 | 
			
		|||
# 
 | 
			
		||||
#
 | 
			
		||||
# = ftools.rb: Extra tools for the File class
 | 
			
		||||
#
 | 
			
		||||
# Author:: WATANABE, Hirofumi
 | 
			
		||||
| 
						 | 
				
			
			@ -16,7 +16,7 @@
 | 
			
		|||
# creating a directory path.  See the File class for details.
 | 
			
		||||
#
 | 
			
		||||
# FileUtils contains all or nearly all the same functionality and more, and
 | 
			
		||||
# is a recommended option over ftools 
 | 
			
		||||
# is a recommended option over ftools
 | 
			
		||||
#
 | 
			
		||||
# When you
 | 
			
		||||
#
 | 
			
		||||
| 
						 | 
				
			
			@ -39,7 +39,7 @@ class << File
 | 
			
		|||
  # If +to+ is a valid directory, +from+ will be appended to +to+, adding
 | 
			
		||||
  # and escaping backslashes as necessary. Otherwise, +to+ will be returned.
 | 
			
		||||
  # Useful for appending +from+ to +to+ only if the filename was not specified
 | 
			
		||||
  # in +to+. 
 | 
			
		||||
  # in +to+.
 | 
			
		||||
  #
 | 
			
		||||
  def catname(from, to)
 | 
			
		||||
    if directory? to
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -55,7 +55,7 @@
 | 
			
		|||
#   while g.next?
 | 
			
		||||
#     puts g.next
 | 
			
		||||
#   end
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
class Generator
 | 
			
		||||
  include Enumerable
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -189,7 +189,7 @@ class Enumerator
 | 
			
		|||
    return g.next unless g.end?
 | 
			
		||||
 | 
			
		||||
    g.rewind
 | 
			
		||||
    raise StopIteration, 'iteration reached at end' 
 | 
			
		||||
    raise StopIteration, 'iteration reached at end'
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # :nodoc:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,10 +12,10 @@
 | 
			
		|||
# found at http://www.sra.co.jp/people/m-kasahr/ruby/getoptlong/
 | 
			
		||||
 | 
			
		||||
# The GetoptLong class allows you to parse command line options similarly to
 | 
			
		||||
# the GNU getopt_long() C library call. Note, however, that GetoptLong is a 
 | 
			
		||||
# the GNU getopt_long() C library call. Note, however, that GetoptLong is a
 | 
			
		||||
# pure Ruby implementation.
 | 
			
		||||
#
 | 
			
		||||
# GetoptLong allows for POSIX-style options like <tt>--file</tt> as well 
 | 
			
		||||
# GetoptLong allows for POSIX-style options like <tt>--file</tt> as well
 | 
			
		||||
# as single letter options like <tt>-f</tt>
 | 
			
		||||
#
 | 
			
		||||
# The empty option <tt>--</tt> (two minus symbols) is used to end option
 | 
			
		||||
| 
						 | 
				
			
			@ -42,16 +42,16 @@
 | 
			
		|||
#     #    greet user by name, if name not supplied default is John
 | 
			
		||||
#     #
 | 
			
		||||
#     # DIR: The directory in which to issue the greeting.
 | 
			
		||||
#     
 | 
			
		||||
#
 | 
			
		||||
#     require 'getoptlong'
 | 
			
		||||
#     require 'rdoc/usage'
 | 
			
		||||
#     
 | 
			
		||||
#
 | 
			
		||||
#     opts = GetoptLong.new(
 | 
			
		||||
#       [ '--help', '-h', GetoptLong::NO_ARGUMENT ],
 | 
			
		||||
#       [ '--repeat', '-n', GetoptLong::REQUIRED_ARGUMENT ],
 | 
			
		||||
#       [ '--name', GetoptLong::OPTIONAL_ARGUMENT ]
 | 
			
		||||
#     )
 | 
			
		||||
#     
 | 
			
		||||
#
 | 
			
		||||
#     dir = nil
 | 
			
		||||
#     name = nil
 | 
			
		||||
#     repetitions = 1
 | 
			
		||||
| 
						 | 
				
			
			@ -69,14 +69,14 @@
 | 
			
		|||
#           end
 | 
			
		||||
#       end
 | 
			
		||||
#     end
 | 
			
		||||
#     
 | 
			
		||||
#
 | 
			
		||||
#     if ARGV.length != 1
 | 
			
		||||
#       puts "Missing dir argument (try --help)"
 | 
			
		||||
#       exit 0
 | 
			
		||||
#     end
 | 
			
		||||
#     
 | 
			
		||||
#
 | 
			
		||||
#     dir = ARGV.shift
 | 
			
		||||
#     
 | 
			
		||||
#
 | 
			
		||||
#     Dir.chdir(dir)
 | 
			
		||||
#     for i in (1..repetitions)
 | 
			
		||||
#       print "Hello"
 | 
			
		||||
| 
						 | 
				
			
			@ -120,7 +120,7 @@ class GetoptLong
 | 
			
		|||
  # Set up option processing.
 | 
			
		||||
  #
 | 
			
		||||
  # The options to support are passed to new() as an array of arrays.
 | 
			
		||||
  # Each sub-array contains any number of String option names which carry 
 | 
			
		||||
  # Each sub-array contains any number of String option names which carry
 | 
			
		||||
  # the same meaning, and one of the following flags:
 | 
			
		||||
  #
 | 
			
		||||
  # GetoptLong::NO_ARGUMENT :: Option does not take an argument.
 | 
			
		||||
| 
						 | 
				
			
			@ -200,23 +200,23 @@ class GetoptLong
 | 
			
		|||
  # the processing of options as follows:
 | 
			
		||||
  #
 | 
			
		||||
  # <b>REQUIRE_ORDER</b> :
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  # Options are required to occur before non-options.
 | 
			
		||||
  #
 | 
			
		||||
  # Processing of options ends as soon as a word is encountered that has not
 | 
			
		||||
  # been preceded by an appropriate option flag.
 | 
			
		||||
  #
 | 
			
		||||
  # For example, if -a and -b are options which do not take arguments,
 | 
			
		||||
  # parsing command line arguments of '-a one -b two' would result in 
 | 
			
		||||
  # 'one', '-b', 'two' being left in ARGV, and only ('-a', '') being 
 | 
			
		||||
  # parsing command line arguments of '-a one -b two' would result in
 | 
			
		||||
  # 'one', '-b', 'two' being left in ARGV, and only ('-a', '') being
 | 
			
		||||
  # processed as an option/arg pair.
 | 
			
		||||
  #
 | 
			
		||||
  # This is the default ordering, if the environment variable
 | 
			
		||||
  # POSIXLY_CORRECT is set. (This is for compatibility with GNU getopt_long.)
 | 
			
		||||
  #
 | 
			
		||||
  # <b>PERMUTE</b> :
 | 
			
		||||
  #  
 | 
			
		||||
  # Options can occur anywhere in the command line parsed. This is the 
 | 
			
		||||
  #
 | 
			
		||||
  # Options can occur anywhere in the command line parsed. This is the
 | 
			
		||||
  # default behavior.
 | 
			
		||||
  #
 | 
			
		||||
  # Every sequence of words which can be interpreted as an option (with or
 | 
			
		||||
| 
						 | 
				
			
			@ -233,7 +233,7 @@ class GetoptLong
 | 
			
		|||
  #
 | 
			
		||||
  # <b>RETURN_IN_ORDER</b> :
 | 
			
		||||
  #
 | 
			
		||||
  # All words on the command line are processed as options. Words not 
 | 
			
		||||
  # All words on the command line are processed as options. Words not
 | 
			
		||||
  # preceded by a short or long option flag are passed as arguments
 | 
			
		||||
  # with an option of '' (empty string).
 | 
			
		||||
  #
 | 
			
		||||
| 
						 | 
				
			
			@ -279,7 +279,7 @@ class GetoptLong
 | 
			
		|||
    # The method is failed if option processing has already started.
 | 
			
		||||
    #
 | 
			
		||||
    if @status != STATUS_YET
 | 
			
		||||
      raise RuntimeError, 
 | 
			
		||||
      raise RuntimeError,
 | 
			
		||||
	"invoke set_options, but option processing has already started"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -331,7 +331,7 @@ class GetoptLong
 | 
			
		|||
	end
 | 
			
		||||
 | 
			
		||||
	#
 | 
			
		||||
	# Register the option (`i') to the `@canonical_names' and 
 | 
			
		||||
	# Register the option (`i') to the `@canonical_names' and
 | 
			
		||||
	# `@canonical_names' Hashes.
 | 
			
		||||
	#
 | 
			
		||||
	if canonical_name == nil
 | 
			
		||||
| 
						 | 
				
			
			@ -463,7 +463,7 @@ class GetoptLong
 | 
			
		|||
	return nil
 | 
			
		||||
      end
 | 
			
		||||
      argument = ARGV.shift
 | 
			
		||||
    elsif @ordering == REQUIRE_ORDER 
 | 
			
		||||
    elsif @ordering == REQUIRE_ORDER
 | 
			
		||||
      if (ARGV[0] !~ /^-./)
 | 
			
		||||
	terminate
 | 
			
		||||
	return nil
 | 
			
		||||
| 
						 | 
				
			
			@ -600,7 +600,7 @@ class GetoptLong
 | 
			
		|||
  #
 | 
			
		||||
  # The block is called repeatedly with two arguments:
 | 
			
		||||
  # The first is the option name.
 | 
			
		||||
  # The second is the argument which followed it (if any). 
 | 
			
		||||
  # The second is the argument which followed it (if any).
 | 
			
		||||
  # Example: ('--opt', 'value')
 | 
			
		||||
  #
 | 
			
		||||
  # The option name is always converted to the first (preferred)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
#
 | 
			
		||||
#               getopts.rb - 
 | 
			
		||||
#               getopts.rb -
 | 
			
		||||
#                       $Release Version: $
 | 
			
		||||
#                       $Revision$
 | 
			
		||||
#                       $Date$
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,7 +13,7 @@ require "thread"
 | 
			
		|||
 | 
			
		||||
#
 | 
			
		||||
# GServer implements a generic server, featuring thread pool management,
 | 
			
		||||
# simple logging, and multi-server management.  See HttpServer in 
 | 
			
		||||
# simple logging, and multi-server management.  See HttpServer in
 | 
			
		||||
# <tt>xmlrpc/httpserver.rb</tt> in the Ruby standard library for an example of
 | 
			
		||||
# GServer in action.
 | 
			
		||||
#
 | 
			
		||||
| 
						 | 
				
			
			@ -34,7 +34,7 @@ require "thread"
 | 
			
		|||
#
 | 
			
		||||
#   #
 | 
			
		||||
#   # A server that returns the time in seconds since 1970.
 | 
			
		||||
#   # 
 | 
			
		||||
#   #
 | 
			
		||||
#   class TimeServer < GServer
 | 
			
		||||
#     def initialize(port=10001, *args)
 | 
			
		||||
#       super(port, *args)
 | 
			
		||||
| 
						 | 
				
			
			@ -47,17 +47,17 @@ require "thread"
 | 
			
		|||
#   # Run the server with logging enabled (it's a separate thread).
 | 
			
		||||
#   server = TimeServer.new
 | 
			
		||||
#   server.audit = true                  # Turn logging on.
 | 
			
		||||
#   server.start 
 | 
			
		||||
#   server.start
 | 
			
		||||
#
 | 
			
		||||
#   # *** Now point your browser to http://localhost:10001 to see it working ***
 | 
			
		||||
#
 | 
			
		||||
#   # See if it's still running. 
 | 
			
		||||
#   # See if it's still running.
 | 
			
		||||
#   GServer.in_service?(10001)           # -> true
 | 
			
		||||
#   server.stopped?                      # -> false
 | 
			
		||||
#
 | 
			
		||||
#   # Shut the server down gracefully.
 | 
			
		||||
#   server.shutdown
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#   # Alternatively, stop it immediately.
 | 
			
		||||
#   GServer.stop(10001)
 | 
			
		||||
#   # or, of course, "server.stop".
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -66,19 +66,19 @@ end
 | 
			
		|||
# == Example
 | 
			
		||||
#
 | 
			
		||||
#   require 'ipaddr'
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#   ipaddr1 = IPAddr.new "3ffe:505:2::1"
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#   p ipaddr1			#=> #<IPAddr: IPv6:3ffe:0505:0002:0000:0000:0000:0000:0001/ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff>
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#   p ipaddr1.to_s		#=> "3ffe:505:2::1"
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#   ipaddr2 = ipaddr1.mask(48)	#=> #<IPAddr: IPv6:3ffe:0505:0002:0000:0000:0000:0000:0000/ffff:ffff:ffff:0000:0000:0000:0000:0000>
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#   p ipaddr2.to_s		#=> "3ffe:505:2::"
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#   ipaddr3 = IPAddr.new "192.168.2.0/24"
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#   p ipaddr3			#=> #<IPAddr: IPv4:192.168.2.0/255.255.255.0>
 | 
			
		||||
 | 
			
		||||
class IPAddr
 | 
			
		||||
| 
						 | 
				
			
			@ -425,7 +425,7 @@ class IPAddr
 | 
			
		|||
  # Creates a new ipaddr object either from a human readable IP
 | 
			
		||||
  # address representation in string, or from a packed in_addr value
 | 
			
		||||
  # followed by an address family.
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  # In the former case, the following are the valid formats that will
 | 
			
		||||
  # be recognized: "address", "address/prefixlen" and "address/mask",
 | 
			
		||||
  # where IPv6 address may be enclosed in square brackets (`[' and
 | 
			
		||||
| 
						 | 
				
			
			@ -433,7 +433,7 @@ class IPAddr
 | 
			
		|||
  # IP address.  Although the address family is determined
 | 
			
		||||
  # automatically from a specified string, you can specify one
 | 
			
		||||
  # explicitly by the optional second argument.
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  # Otherwise an IP address is generated from a packed in_addr value
 | 
			
		||||
  # and an address family.
 | 
			
		||||
  #
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										14
									
								
								lib/irb.rb
									
										
									
									
									
								
							
							
						
						
									
										14
									
								
								lib/irb.rb
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -93,7 +93,7 @@ module IRB
 | 
			
		|||
  end
 | 
			
		||||
 | 
			
		||||
  #
 | 
			
		||||
  # irb interpriter main routine 
 | 
			
		||||
  # irb interpriter main routine
 | 
			
		||||
  #
 | 
			
		||||
  class Irb
 | 
			
		||||
    def initialize(workspace = nil, input_method = nil, output_method = nil)
 | 
			
		||||
| 
						 | 
				
			
			@ -134,7 +134,7 @@ module IRB
 | 
			
		|||
	  end
 | 
			
		||||
	end
 | 
			
		||||
      end
 | 
			
		||||
       
 | 
			
		||||
 | 
			
		||||
      @scanner.set_input(@context.io) do
 | 
			
		||||
	signal_status(:IN_INPUT) do
 | 
			
		||||
	  if l = @context.io.gets
 | 
			
		||||
| 
						 | 
				
			
			@ -166,11 +166,11 @@ module IRB
 | 
			
		|||
	  if exc
 | 
			
		||||
	    print exc.class, ": ", exc, "\n"
 | 
			
		||||
	    if exc.backtrace[0] =~ /irb(2)?(\/.*|-.*|\.rb)?:/ && exc.class.to_s !~ /^IRB/
 | 
			
		||||
	      irb_bug = true 
 | 
			
		||||
	      irb_bug = true
 | 
			
		||||
	    else
 | 
			
		||||
	      irb_bug = false
 | 
			
		||||
	    end
 | 
			
		||||
	    
 | 
			
		||||
 | 
			
		||||
	    messages = []
 | 
			
		||||
	    lasts = []
 | 
			
		||||
	    levels = 0
 | 
			
		||||
| 
						 | 
				
			
			@ -182,7 +182,7 @@ module IRB
 | 
			
		|||
		else
 | 
			
		||||
		  lasts.push "\tfrom "+m
 | 
			
		||||
		  if lasts.size > @context.back_trace_limit
 | 
			
		||||
		    lasts.shift 
 | 
			
		||||
		    lasts.shift
 | 
			
		||||
		    levels += 1
 | 
			
		||||
		  end
 | 
			
		||||
		end
 | 
			
		||||
| 
						 | 
				
			
			@ -287,13 +287,13 @@ module IRB
 | 
			
		|||
	when "l"
 | 
			
		||||
	  ltype
 | 
			
		||||
	when "i"
 | 
			
		||||
	  if $1 
 | 
			
		||||
	  if $1
 | 
			
		||||
	    format("%" + $1 + "d", indent)
 | 
			
		||||
	  else
 | 
			
		||||
	    indent.to_s
 | 
			
		||||
	  end
 | 
			
		||||
	when "n"
 | 
			
		||||
	  if $1 
 | 
			
		||||
	  if $1
 | 
			
		||||
	    format("%" + $1 + "d", line_no)
 | 
			
		||||
	  else
 | 
			
		||||
	    line_no.to_s
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
#
 | 
			
		||||
#   change-ws.rb - 
 | 
			
		||||
#   change-ws.rb -
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
| 
						 | 
				
			
			@ -7,7 +7,7 @@
 | 
			
		|||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
require "irb/cmd/nop.rb"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
#
 | 
			
		||||
#   fork.rb - 
 | 
			
		||||
#   fork.rb -
 | 
			
		||||
#   	$Release Version: 0.9.5 $
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
| 
						 | 
				
			
			@ -7,7 +7,7 @@
 | 
			
		|||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
@RCS_ID='-$Id$-'
 | 
			
		||||
| 
						 | 
				
			
			@ -18,7 +18,7 @@ module IRB
 | 
			
		|||
    class Fork<Nop
 | 
			
		||||
      def execute(&block)
 | 
			
		||||
	pid = send ExtendCommand.irb_original_method_name("fork")
 | 
			
		||||
	unless pid 
 | 
			
		||||
	unless pid
 | 
			
		||||
	  class<<self
 | 
			
		||||
	    alias_method :exit, ExtendCommand.irb_original_method_name('exit')
 | 
			
		||||
	  end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,7 +6,7 @@
 | 
			
		|||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
require 'rdoc/ri/ri_driver'
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
#
 | 
			
		||||
#   load.rb - 
 | 
			
		||||
#   load.rb -
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
| 
						 | 
				
			
			@ -7,7 +7,7 @@
 | 
			
		|||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
require "irb/cmd/nop.rb"
 | 
			
		||||
| 
						 | 
				
			
			@ -26,7 +26,7 @@ module IRB
 | 
			
		|||
 | 
			
		||||
    class Require<Nop
 | 
			
		||||
      include IrbLoader
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      def execute(file_name)
 | 
			
		||||
#	return ruby_require(file_name) unless IRB.conf[:USE_LOADER]
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -45,7 +45,7 @@ module IRB
 | 
			
		|||
	when /\.(so|o|sl)$/
 | 
			
		||||
	  return ruby_require(file_name)
 | 
			
		||||
	end
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
	begin
 | 
			
		||||
	  irb_load(f = file_name + ".rb")
 | 
			
		||||
	  $".push f
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
#
 | 
			
		||||
#   nop.rb - 
 | 
			
		||||
#   nop.rb -
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
| 
						 | 
				
			
			@ -7,12 +7,12 @@
 | 
			
		|||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
module IRB
 | 
			
		||||
  module ExtendCommand
 | 
			
		||||
    class Nop
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      @RCS_ID='-$Id$-'
 | 
			
		||||
 | 
			
		||||
      def self.execute(conf, *opts)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
#
 | 
			
		||||
#   change-ws.rb - 
 | 
			
		||||
#   change-ws.rb -
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
| 
						 | 
				
			
			@ -7,7 +7,7 @@
 | 
			
		|||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
require "irb/cmd/nop.rb"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,6 @@
 | 
			
		|||
#!/usr/local/bin/ruby
 | 
			
		||||
#
 | 
			
		||||
#   multi.rb - 
 | 
			
		||||
#   multi.rb -
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
| 
						 | 
				
			
			@ -8,7 +8,7 @@
 | 
			
		|||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
require "irb/cmd/nop.rb"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
#
 | 
			
		||||
#   irb/completor.rb - 
 | 
			
		||||
#   irb/completor.rb -
 | 
			
		||||
#   	$Release Version: 0.9$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
| 
						 | 
				
			
			@ -16,16 +16,16 @@ module IRB
 | 
			
		|||
 | 
			
		||||
    ReservedWords = [
 | 
			
		||||
      "BEGIN", "END",
 | 
			
		||||
      "alias", "and", 
 | 
			
		||||
      "begin", "break", 
 | 
			
		||||
      "alias", "and",
 | 
			
		||||
      "begin", "break",
 | 
			
		||||
      "case", "class",
 | 
			
		||||
      "def", "defined", "do",
 | 
			
		||||
      "else", "elsif", "end", "ensure",
 | 
			
		||||
      "false", "for", 
 | 
			
		||||
      "if", "in", 
 | 
			
		||||
      "module", 
 | 
			
		||||
      "false", "for",
 | 
			
		||||
      "if", "in",
 | 
			
		||||
      "module",
 | 
			
		||||
      "next", "nil", "not",
 | 
			
		||||
      "or", 
 | 
			
		||||
      "or",
 | 
			
		||||
      "redo", "rescue", "retry", "return",
 | 
			
		||||
      "self", "super",
 | 
			
		||||
      "then", "true",
 | 
			
		||||
| 
						 | 
				
			
			@ -33,10 +33,10 @@ module IRB
 | 
			
		|||
      "when", "while",
 | 
			
		||||
      "yield",
 | 
			
		||||
    ]
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
    CompletionProc = proc { |input|
 | 
			
		||||
      bind = IRB.conf[:MAIN_CONTEXT].workspace.binding
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
#      puts "input: #{input}"
 | 
			
		||||
 | 
			
		||||
      case input
 | 
			
		||||
| 
						 | 
				
			
			@ -63,7 +63,7 @@ module IRB
 | 
			
		|||
 | 
			
		||||
	candidates = Proc.instance_methods(true) | Hash.instance_methods(true)
 | 
			
		||||
	select_message(receiver, message, candidates)
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
      when /^(:[^:.]*)$/
 | 
			
		||||
 	# Symbol
 | 
			
		||||
	if Symbol.respond_to?(:all_symbols)
 | 
			
		||||
| 
						 | 
				
			
			@ -135,7 +135,7 @@ module IRB
 | 
			
		|||
	gv = eval("global_variables", bind)
 | 
			
		||||
	lv = eval("local_variables", bind)
 | 
			
		||||
	cv = eval("self.class.constants", bind)
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
	if (gv | lv | cv).include?(receiver)
 | 
			
		||||
	  # foo.func and foo is local var.
 | 
			
		||||
	  candidates = eval("#{receiver}.methods", bind)
 | 
			
		||||
| 
						 | 
				
			
			@ -155,7 +155,7 @@ module IRB
 | 
			
		|||
	    rescue Exception
 | 
			
		||||
	      name = ""
 | 
			
		||||
	    end
 | 
			
		||||
	    next if name != "IRB::Context" and 
 | 
			
		||||
	    next if name != "IRB::Context" and
 | 
			
		||||
	      /^(IRB|SLex|RubyLex|RubyToken)/ =~ name
 | 
			
		||||
	    candidates.concat m.instance_methods(false)
 | 
			
		||||
	  }
 | 
			
		||||
| 
						 | 
				
			
			@ -175,7 +175,7 @@ module IRB
 | 
			
		|||
 | 
			
		||||
      else
 | 
			
		||||
	candidates = eval("methods | private_methods | local_variables | self.class.constants", bind)
 | 
			
		||||
			  
 | 
			
		||||
 | 
			
		||||
	(candidates|ReservedWords).grep(/^#{Regexp.quote(input)}/)
 | 
			
		||||
      end
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,7 +7,7 @@
 | 
			
		|||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
require "irb/workspace"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -46,7 +46,7 @@ module IRB
 | 
			
		|||
      @ignore_eof = IRB.conf[:IGNORE_EOF]
 | 
			
		||||
 | 
			
		||||
      @back_trace_limit = IRB.conf[:BACK_TRACE_LIMIT]
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      self.prompt_mode = IRB.conf[:PROMPT_MODE]
 | 
			
		||||
 | 
			
		||||
      if IRB.conf[:SINGLE_IRB] or !defined?(JobManager)
 | 
			
		||||
| 
						 | 
				
			
			@ -91,7 +91,7 @@ module IRB
 | 
			
		|||
	@output_method = StdioOutputMethod.new
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      @verbose = IRB.conf[:VERBOSE] 
 | 
			
		||||
      @verbose = IRB.conf[:VERBOSE]
 | 
			
		||||
      @echo = IRB.conf[:ECHO]
 | 
			
		||||
      if @echo.nil?
 | 
			
		||||
	@echo = true
 | 
			
		||||
| 
						 | 
				
			
			@ -107,7 +107,7 @@ module IRB
 | 
			
		|||
    attr_accessor :workspace
 | 
			
		||||
    attr_reader :thread
 | 
			
		||||
    attr_accessor :io
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    attr_accessor :irb
 | 
			
		||||
    attr_accessor :ap_name
 | 
			
		||||
    attr_accessor :rc
 | 
			
		||||
| 
						 | 
				
			
			@ -142,7 +142,7 @@ module IRB
 | 
			
		|||
 | 
			
		||||
    def verbose?
 | 
			
		||||
      if @verbose.nil?
 | 
			
		||||
	if defined?(ReadlineInputMethod) && @io.kind_of?(ReadlineInputMethod) 
 | 
			
		||||
	if defined?(ReadlineInputMethod) && @io.kind_of?(ReadlineInputMethod)
 | 
			
		||||
	  false
 | 
			
		||||
	elsif !STDIN.tty? or @io.kind_of?(FileInputMethod)
 | 
			
		||||
	  true
 | 
			
		||||
| 
						 | 
				
			
			@ -180,7 +180,7 @@ module IRB
 | 
			
		|||
	@auto_indent_mode = IRB.conf[:AUTO_INDENT]
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    def inspect?
 | 
			
		||||
      @inspect_mode.nil? or @inspect_mode
 | 
			
		||||
    end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
#
 | 
			
		||||
#   irb/ext/cb.rb - 
 | 
			
		||||
#   irb/ext/cb.rb -
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
| 
						 | 
				
			
			@ -7,7 +7,7 @@
 | 
			
		|||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
module IRB
 | 
			
		||||
| 
						 | 
				
			
			@ -23,12 +23,12 @@ module IRB
 | 
			
		|||
 | 
			
		||||
    def change_workspace(*_main)
 | 
			
		||||
      if _main.empty?
 | 
			
		||||
	@workspace = home_workspace 
 | 
			
		||||
	@workspace = home_workspace
 | 
			
		||||
	return main
 | 
			
		||||
      end
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      @workspace = WorkSpace.new(_main[0])
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      if !(class<<main;ancestors;end).include?(ExtendCommandBundle)
 | 
			
		||||
	main.extend ExtendCommandBundle
 | 
			
		||||
      end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
#
 | 
			
		||||
#   history.rb - 
 | 
			
		||||
#   history.rb -
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
| 
						 | 
				
			
			@ -7,7 +7,7 @@
 | 
			
		|||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
module IRB
 | 
			
		||||
| 
						 | 
				
			
			@ -57,7 +57,7 @@ module IRB
 | 
			
		|||
    end
 | 
			
		||||
 | 
			
		||||
    def size(size)
 | 
			
		||||
      if size != 0 && size < @size 
 | 
			
		||||
      if size != 0 && size < @size
 | 
			
		||||
	@contents = @contents[@size - size .. @size]
 | 
			
		||||
      end
 | 
			
		||||
      @size = size
 | 
			
		||||
| 
						 | 
				
			
			@ -79,7 +79,7 @@ module IRB
 | 
			
		|||
      @contents.push [no, val]
 | 
			
		||||
      @contents.shift if @size != 0 && @contents.size > @size
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    alias real_inspect inspect
 | 
			
		||||
 | 
			
		||||
    def inspect
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
#
 | 
			
		||||
#   loader.rb - 
 | 
			
		||||
#   loader.rb -
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
| 
						 | 
				
			
			@ -7,7 +7,7 @@
 | 
			
		|||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -45,7 +45,7 @@ module IRB
 | 
			
		|||
      irb.suspend_name(path, File.basename(path)) do
 | 
			
		||||
	irb.suspend_input_method(FileInputMethod.new(path)) do
 | 
			
		||||
	  |back_io|
 | 
			
		||||
	  irb.signal_status(:IN_LOAD) do 
 | 
			
		||||
	  irb.signal_status(:IN_LOAD) do
 | 
			
		||||
	    if back_io.kind_of?(FileInputMethod)
 | 
			
		||||
	      irb.eval_input
 | 
			
		||||
	    else
 | 
			
		||||
| 
						 | 
				
			
			@ -62,7 +62,7 @@ module IRB
 | 
			
		|||
 | 
			
		||||
    def load_file(path, priv = nil)
 | 
			
		||||
      irb.suspend_name(path, File.basename(path)) do
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
	if priv
 | 
			
		||||
	  ws = WorkSpace.new(Module.new)
 | 
			
		||||
	else
 | 
			
		||||
| 
						 | 
				
			
			@ -71,7 +71,7 @@ module IRB
 | 
			
		|||
	irb.suspend_workspace(ws) do
 | 
			
		||||
	  irb.suspend_input_method(FileInputMethod.new(path)) do
 | 
			
		||||
	    |back_io|
 | 
			
		||||
	    irb.signal_status(:IN_LOAD) do 
 | 
			
		||||
	    irb.signal_status(:IN_LOAD) do
 | 
			
		||||
#	      p irb.conf
 | 
			
		||||
	      if back_io.kind_of?(FileInputMethod)
 | 
			
		||||
		irb.eval_input
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
#
 | 
			
		||||
#   math-mode.rb - 
 | 
			
		||||
#   math-mode.rb -
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
| 
						 | 
				
			
			@ -7,7 +7,7 @@
 | 
			
		|||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
require "mathn"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,7 +7,7 @@
 | 
			
		|||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
IRB.fail CantShiftToMultiIrbMode unless defined?(Thread)
 | 
			
		||||
require "thread"
 | 
			
		||||
| 
						 | 
				
			
			@ -67,7 +67,7 @@ module IRB
 | 
			
		|||
	IRB.fail IrbAlreadyDead unless th.alive?
 | 
			
		||||
	th.exit
 | 
			
		||||
      end
 | 
			
		||||
    end    
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def search(key)
 | 
			
		||||
      job = case key
 | 
			
		||||
| 
						 | 
				
			
			@ -124,8 +124,8 @@ module IRB
 | 
			
		|||
	  t_status = "exited"
 | 
			
		||||
	end
 | 
			
		||||
	ary.push format("#%d->%s on %s (%s: %s)",
 | 
			
		||||
			i, 
 | 
			
		||||
			irb.context.irb_name, 
 | 
			
		||||
			i,
 | 
			
		||||
			irb.context.irb_name,
 | 
			
		||||
			irb.context.main,
 | 
			
		||||
			th,
 | 
			
		||||
			t_status)
 | 
			
		||||
| 
						 | 
				
			
			@ -144,14 +144,14 @@ module IRB
 | 
			
		|||
    IRB.JobManager.irb(Thread.current).context
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # invoke multi-irb 
 | 
			
		||||
  # invoke multi-irb
 | 
			
		||||
  def IRB.irb(file = nil, *main)
 | 
			
		||||
    workspace = WorkSpace.new(*main)
 | 
			
		||||
    parent_thread = Thread.current
 | 
			
		||||
    Thread.start do
 | 
			
		||||
      begin
 | 
			
		||||
	irb = Irb.new(workspace, file)
 | 
			
		||||
      rescue 
 | 
			
		||||
      rescue
 | 
			
		||||
	print "Subirb can't start with context(self): ", workspace.main.inspect, "\n"
 | 
			
		||||
	print "return to main irb\n"
 | 
			
		||||
	Thread.pass
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,6 @@
 | 
			
		|||
#!/usr/local/bin/ruby
 | 
			
		||||
#
 | 
			
		||||
#   save-history.rb - 
 | 
			
		||||
#   save-history.rb -
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
| 
						 | 
				
			
			@ -8,7 +8,7 @@
 | 
			
		|||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
require "readline"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
#
 | 
			
		||||
#   irb/lib/tracer.rb - 
 | 
			
		||||
#   irb/lib/tracer.rb -
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
| 
						 | 
				
			
			@ -7,7 +7,7 @@
 | 
			
		|||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
require "tracer"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -44,7 +44,7 @@ module IRB
 | 
			
		|||
    alias __evaluate__ evaluate
 | 
			
		||||
    def evaluate(context, statements, file = nil, line = nil)
 | 
			
		||||
      if context.use_tracer? && file != nil && line != nil
 | 
			
		||||
	Tracer.on 
 | 
			
		||||
	Tracer.on
 | 
			
		||||
	begin
 | 
			
		||||
	  __evaluate__(context, statements, file, line)
 | 
			
		||||
	ensure
 | 
			
		||||
| 
						 | 
				
			
			@ -58,4 +58,4 @@ module IRB
 | 
			
		|||
 | 
			
		||||
  IRB.initialize_tracer
 | 
			
		||||
end
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
#
 | 
			
		||||
#   use-loader.rb - 
 | 
			
		||||
#   use-loader.rb -
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
| 
						 | 
				
			
			@ -7,7 +7,7 @@
 | 
			
		|||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
require "irb/cmd/load"
 | 
			
		||||
| 
						 | 
				
			
			@ -31,7 +31,7 @@ module IRB
 | 
			
		|||
  class Context
 | 
			
		||||
 | 
			
		||||
    IRB.conf[:USE_LOADER] = false
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    def use_loader
 | 
			
		||||
      IRB.conf[:USE_LOADER]
 | 
			
		||||
    end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
#
 | 
			
		||||
#   push-ws.rb - 
 | 
			
		||||
#   push-ws.rb -
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
| 
						 | 
				
			
			@ -7,7 +7,7 @@
 | 
			
		|||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
module IRB
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
#
 | 
			
		||||
#   irb/extend-command.rb - irb extend command 
 | 
			
		||||
#   irb/extend-command.rb - irb extend command
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
| 
						 | 
				
			
			@ -7,7 +7,7 @@
 | 
			
		|||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
module IRB
 | 
			
		||||
  #
 | 
			
		||||
| 
						 | 
				
			
			@ -90,15 +90,15 @@ module IRB
 | 
			
		|||
 | 
			
		||||
      [:irb_load, :Load, "irb/cmd/load"],
 | 
			
		||||
      [:irb_require, :Require, "irb/cmd/load"],
 | 
			
		||||
      [:irb_source, :Source, "irb/cmd/load", 
 | 
			
		||||
      [:irb_source, :Source, "irb/cmd/load",
 | 
			
		||||
	[:source, NO_OVERRIDE]],
 | 
			
		||||
 | 
			
		||||
      [:irb, :IrbCommand, "irb/cmd/subirb"],
 | 
			
		||||
      [:irb_jobs, :Jobs, "irb/cmd/subirb", 
 | 
			
		||||
      [:irb_jobs, :Jobs, "irb/cmd/subirb",
 | 
			
		||||
	[:jobs, NO_OVERRIDE]],
 | 
			
		||||
      [:irb_fg, :Foreground, "irb/cmd/subirb", 
 | 
			
		||||
      [:irb_fg, :Foreground, "irb/cmd/subirb",
 | 
			
		||||
	[:fg, NO_OVERRIDE]],
 | 
			
		||||
      [:irb_kill, :Kill, "irb/cmd/subirb", 
 | 
			
		||||
      [:irb_kill, :Kill, "irb/cmd/subirb",
 | 
			
		||||
	[:kill, OVERRIDE_PRIVATE_ONLY]],
 | 
			
		||||
 | 
			
		||||
      [:irb_help, :Help, "irb/cmd/help",
 | 
			
		||||
| 
						 | 
				
			
			@ -162,9 +162,9 @@ module IRB
 | 
			
		|||
	  (override == NO_OVERRIDE) &&  !respond_to?(to, true)
 | 
			
		||||
	target = self
 | 
			
		||||
	(class<<self;self;end).instance_eval{
 | 
			
		||||
	  if target.respond_to?(to, true) && 
 | 
			
		||||
	  if target.respond_to?(to, true) &&
 | 
			
		||||
	      !target.respond_to?(EXCB.irb_original_method_name(to), true)
 | 
			
		||||
	    alias_method(EXCB.irb_original_method_name(to), to) 
 | 
			
		||||
	    alias_method(EXCB.irb_original_method_name(to), to)
 | 
			
		||||
	  end
 | 
			
		||||
	  alias_method to, from
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
#
 | 
			
		||||
#   frame.rb - 
 | 
			
		||||
#   frame.rb -
 | 
			
		||||
#   	$Release Version: 0.9$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
| 
						 | 
				
			
			@ -7,7 +7,7 @@
 | 
			
		|||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
require "e2mmap"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,7 +7,7 @@
 | 
			
		|||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
module IRB
 | 
			
		||||
| 
						 | 
				
			
			@ -23,7 +23,7 @@ module IRB
 | 
			
		|||
	next
 | 
			
		||||
      end
 | 
			
		||||
      space_line = false
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      l.sub!(/#.*$/, "")
 | 
			
		||||
      next if /^\s*$/ =~ l
 | 
			
		||||
      lc.puts l
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,7 +7,7 @@
 | 
			
		|||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
module IRB
 | 
			
		||||
| 
						 | 
				
			
			@ -21,7 +21,7 @@ module IRB
 | 
			
		|||
    IRB.load_modules
 | 
			
		||||
 | 
			
		||||
    unless @CONF[:PROMPT][@CONF[:PROMPT_MODE]]
 | 
			
		||||
      IRB.fail(UndefinedPromptMode, @CONF[:PROMPT_MODE]) 
 | 
			
		||||
      IRB.fail(UndefinedPromptMode, @CONF[:PROMPT_MODE])
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -113,9 +113,9 @@ module IRB
 | 
			
		|||
 | 
			
		||||
#    @CONF[:LC_MESSAGES] = "en"
 | 
			
		||||
    @CONF[:LC_MESSAGES] = Locale.new
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @CONF[:AT_EXIT] = []
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @CONF[:DEBUG_LEVEL] = 1
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -238,7 +238,7 @@ module IRB
 | 
			
		|||
      yield proc{|rc|  rc == "rc" ? irbrc : irbrc+rc}
 | 
			
		||||
    end
 | 
			
		||||
    if home = ENV["HOME"]
 | 
			
		||||
      yield proc{|rc| home+"/.irb#{rc}"} 
 | 
			
		||||
      yield proc{|rc| home+"/.irb#{rc}"}
 | 
			
		||||
    end
 | 
			
		||||
    home = Dir.pwd
 | 
			
		||||
    yield proc{|rc| home+"/.irb#{rc}"}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,10 +7,10 @@
 | 
			
		|||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
module IRB
 | 
			
		||||
  # 
 | 
			
		||||
  #
 | 
			
		||||
  # InputMethod
 | 
			
		||||
  #	StdioInputMethod
 | 
			
		||||
  #	FileInputMethod
 | 
			
		||||
| 
						 | 
				
			
			@ -26,7 +26,7 @@ module IRB
 | 
			
		|||
    attr_reader :file_name
 | 
			
		||||
 | 
			
		||||
    attr_accessor :prompt
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    def gets
 | 
			
		||||
      IRB.fail NotImplementedError, "gets"
 | 
			
		||||
    end
 | 
			
		||||
| 
						 | 
				
			
			@ -36,7 +36,7 @@ module IRB
 | 
			
		|||
      false
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  class StdioInputMethod < InputMethod
 | 
			
		||||
    def initialize
 | 
			
		||||
      super
 | 
			
		||||
| 
						 | 
				
			
			@ -61,7 +61,7 @@ module IRB
 | 
			
		|||
      @line[line_no]
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  class FileInputMethod < InputMethod
 | 
			
		||||
    def initialize(file)
 | 
			
		||||
      super
 | 
			
		||||
| 
						 | 
				
			
			@ -84,7 +84,7 @@ module IRB
 | 
			
		|||
  begin
 | 
			
		||||
    require "readline"
 | 
			
		||||
    class ReadlineInputMethod < InputMethod
 | 
			
		||||
      include Readline 
 | 
			
		||||
      include Readline
 | 
			
		||||
      def initialize
 | 
			
		||||
	super
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
#
 | 
			
		||||
#   irb/lc/error.rb - 
 | 
			
		||||
#   irb/lc/error.rb -
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
| 
						 | 
				
			
			@ -7,7 +7,7 @@
 | 
			
		|||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
require "e2mmap"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
#
 | 
			
		||||
#   irb/lc/ja/error.rb - 
 | 
			
		||||
#   irb/lc/ja/error.rb -
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
| 
						 | 
				
			
			@ -7,7 +7,7 @@
 | 
			
		|||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
require "e2mmap"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,7 +7,7 @@
 | 
			
		|||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
autoload :Kconv, "kconv"
 | 
			
		||||
| 
						 | 
				
			
			@ -20,7 +20,7 @@ module IRB
 | 
			
		|||
    LOCALE_DIR = "/lc/"
 | 
			
		||||
 | 
			
		||||
    def initialize(locale = nil)
 | 
			
		||||
      @lang = locale || ENV["IRB_LANG"] || ENV["LC_MESSAGES"] || ENV["LC_ALL"] || ENV["LANG"] || "C" 
 | 
			
		||||
      @lang = locale || ENV["IRB_LANG"] || ENV["LC_MESSAGES"] || ENV["LC_ALL"] || ENV["LANG"] || "C"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    attr_reader :lang
 | 
			
		||||
| 
						 | 
				
			
			@ -101,7 +101,7 @@ module IRB
 | 
			
		|||
    end
 | 
			
		||||
 | 
			
		||||
    alias toplevel_load load
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    def load(file, priv=nil)
 | 
			
		||||
      dir = File.dirname(file)
 | 
			
		||||
      dir = "" if dir == "."
 | 
			
		||||
| 
						 | 
				
			
			@ -115,7 +115,7 @@ module IRB
 | 
			
		|||
	  lc_path = search_file(dir, base)
 | 
			
		||||
	  return real_load(lc_path, priv) if lc_path
 | 
			
		||||
	end
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
	for path in $:
 | 
			
		||||
	  lc_path = search_file(path + "/" + dir, base)
 | 
			
		||||
	  return real_load(lc_path, priv) if lc_path
 | 
			
		||||
| 
						 | 
				
			
			@ -124,7 +124,7 @@ module IRB
 | 
			
		|||
	@lang = back if back
 | 
			
		||||
      end
 | 
			
		||||
      raise LoadError, "No such file to load -- #{file}"
 | 
			
		||||
    end 
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    def real_load(path, priv)
 | 
			
		||||
      src = self.String(File.read(path))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
#
 | 
			
		||||
#   notifier.rb - output methods used by irb 
 | 
			
		||||
#   notifier.rb - output methods used by irb
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
| 
						 | 
				
			
			@ -7,7 +7,7 @@
 | 
			
		|||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
require "e2mmap"
 | 
			
		||||
| 
						 | 
				
			
			@ -16,16 +16,16 @@ require "irb/output-method"
 | 
			
		|||
module IRB
 | 
			
		||||
  module Notifier
 | 
			
		||||
    extend Exception2MessageMapper
 | 
			
		||||
    def_exception :ErrUndefinedNotifier, 
 | 
			
		||||
    def_exception :ErrUndefinedNotifier,
 | 
			
		||||
      "undefined notifier level: %d is specified"
 | 
			
		||||
    def_exception :ErrUnrecognizedLevel, 
 | 
			
		||||
    def_exception :ErrUnrecognizedLevel,
 | 
			
		||||
      "unrecognized notifier level: %s is specified"
 | 
			
		||||
 | 
			
		||||
    def def_notifier(prefix = "", output_method = StdioOutputMethod.new)
 | 
			
		||||
      CompositeNotifier.new(prefix, output_method)
 | 
			
		||||
    end
 | 
			
		||||
    module_function :def_notifier
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
    class AbstractNotifier
 | 
			
		||||
      def initialize(prefix, base_notifier)
 | 
			
		||||
	@prefix = prefix
 | 
			
		||||
| 
						 | 
				
			
			@ -113,7 +113,7 @@ module IRB
 | 
			
		|||
 | 
			
		||||
      def initialize(base, level, prefix)
 | 
			
		||||
	super(prefix, base)
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
	@level = level
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -122,7 +122,7 @@ module IRB
 | 
			
		|||
      def <=>(other)
 | 
			
		||||
	@level <=> other.level
 | 
			
		||||
      end
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      def notify?
 | 
			
		||||
	@base_notifier.level >= self
 | 
			
		||||
      end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
#
 | 
			
		||||
#   output-method.rb - output methods used by irb 
 | 
			
		||||
#   output-method.rb - output methods used by irb
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
| 
						 | 
				
			
			@ -7,7 +7,7 @@
 | 
			
		|||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
require "e2mmap"
 | 
			
		||||
| 
						 | 
				
			
			@ -40,7 +40,7 @@ module IRB
 | 
			
		|||
    # <最小フィールド幅> (\*|\*[1-9][0-9]*\$|[1-9][0-9]*)
 | 
			
		||||
    # <精度>.(\*|\*[1-9][0-9]*\$|[1-9][0-9]*|)?
 | 
			
		||||
    # #<長さ修正文字>(hh|h|l|ll|L|q|j|z|t)
 | 
			
		||||
    # <恃垂饯赖矢机>[diouxXeEfgGcsb%] 
 | 
			
		||||
    # <恃垂饯赖矢机>[diouxXeEfgGcsb%]
 | 
			
		||||
    def parse_printf_format(format, opts)
 | 
			
		||||
      return format, opts if $1.size % 2 == 1
 | 
			
		||||
    end
 | 
			
		||||
| 
						 | 
				
			
			@ -52,7 +52,7 @@ module IRB
 | 
			
		|||
	puts [f, p, pp, pos, new_pos, c].join("!")
 | 
			
		||||
	pos = new_pos if new_pos
 | 
			
		||||
	if c == "I"
 | 
			
		||||
	  inspects.push pos.to_i 
 | 
			
		||||
	  inspects.push pos.to_i
 | 
			
		||||
	  (f||"")+(p||"")+(pp||"")+(pos||"")+"s"
 | 
			
		||||
	else
 | 
			
		||||
	  $&
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,7 +7,7 @@
 | 
			
		|||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
require "e2mmap"
 | 
			
		||||
| 
						 | 
				
			
			@ -21,12 +21,12 @@ class RubyLex
 | 
			
		|||
  def_exception(:AlreadyDefinedToken, "Already defined token(%s)")
 | 
			
		||||
  def_exception(:TkReading2TokenNoKey, "key nothing(key='%s')")
 | 
			
		||||
  def_exception(:TkSymbol2TokenNoKey, "key nothing(key='%s')")
 | 
			
		||||
  def_exception(:TkReading2TokenDuplicateError, 
 | 
			
		||||
  def_exception(:TkReading2TokenDuplicateError,
 | 
			
		||||
		"key duplicate(token_n='%s', key='%s')")
 | 
			
		||||
  def_exception(:SyntaxError, "%s")
 | 
			
		||||
 | 
			
		||||
  def_exception(:TerminateLineInput, "Terminate Line Input")
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  include RubyToken
 | 
			
		||||
 | 
			
		||||
  class << self
 | 
			
		||||
| 
						 | 
				
			
			@ -54,7 +54,7 @@ class RubyLex
 | 
			
		|||
    @lex_state = EXPR_BEG
 | 
			
		||||
    @space_seen = false
 | 
			
		||||
    @here_header = false
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @continue = false
 | 
			
		||||
    @line = ""
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -92,7 +92,7 @@ class RubyLex
 | 
			
		|||
    else
 | 
			
		||||
      @base_char_no += @readed.size
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    readed = @readed.join("")
 | 
			
		||||
    @readed = []
 | 
			
		||||
    readed
 | 
			
		||||
| 
						 | 
				
			
			@ -111,7 +111,7 @@ class RubyLex
 | 
			
		|||
    end
 | 
			
		||||
    @seek += 1
 | 
			
		||||
    if c == "\n"
 | 
			
		||||
      @line_no += 1 
 | 
			
		||||
      @line_no += 1
 | 
			
		||||
      @char_no = 0
 | 
			
		||||
    else
 | 
			
		||||
      @char_no += 1
 | 
			
		||||
| 
						 | 
				
			
			@ -148,10 +148,10 @@ class RubyLex
 | 
			
		|||
      c2 = @here_readed.pop
 | 
			
		||||
    end
 | 
			
		||||
    c = c2 unless c
 | 
			
		||||
    @rests.unshift c #c = 
 | 
			
		||||
    @rests.unshift c #c =
 | 
			
		||||
      @seek -= 1
 | 
			
		||||
    if c == "\n"
 | 
			
		||||
      @line_no -= 1 
 | 
			
		||||
      @line_no -= 1
 | 
			
		||||
      if idx = @readed.reverse.index("\n")
 | 
			
		||||
	@char_no = @readed.size - idx
 | 
			
		||||
      else
 | 
			
		||||
| 
						 | 
				
			
			@ -216,14 +216,14 @@ class RubyLex
 | 
			
		|||
    @lex_state = EXPR_BEG
 | 
			
		||||
    @space_seen = false
 | 
			
		||||
    @here_header = false
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @continue = false
 | 
			
		||||
    prompt
 | 
			
		||||
 | 
			
		||||
    @line = ""
 | 
			
		||||
    @exp_line_no = @line_no
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  def each_top_level_statement
 | 
			
		||||
    initialize_input
 | 
			
		||||
    catch(:TERM_INPUT) do
 | 
			
		||||
| 
						 | 
				
			
			@ -297,7 +297,7 @@ class RubyLex
 | 
			
		|||
    #      Tracer.off
 | 
			
		||||
    tk
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  ENINDENT_CLAUSE = [
 | 
			
		||||
    "case", "class", "def", "do", "for", "if",
 | 
			
		||||
    "module", "unless", "until", "while", "begin" #, "when"
 | 
			
		||||
| 
						 | 
				
			
			@ -314,7 +314,7 @@ class RubyLex
 | 
			
		|||
    "W" => "]",
 | 
			
		||||
    "s" => ":"
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  PERCENT_PAREN = {
 | 
			
		||||
    "{" => "}",
 | 
			
		||||
    "[" => "]",
 | 
			
		||||
| 
						 | 
				
			
			@ -354,7 +354,7 @@ class RubyLex
 | 
			
		|||
    end
 | 
			
		||||
 | 
			
		||||
    @OP.def_rule("=begin",
 | 
			
		||||
		 proc{|op, io| @prev_char_no == 0 && peek(0) =~ /\s/}) do 
 | 
			
		||||
		 proc{|op, io| @prev_char_no == 0 && peek(0) =~ /\s/}) do
 | 
			
		||||
      |op, io|
 | 
			
		||||
      @ltype = "="
 | 
			
		||||
      until getc == "\n"; end
 | 
			
		||||
| 
						 | 
				
			
			@ -374,8 +374,8 @@ class RubyLex
 | 
			
		|||
      else
 | 
			
		||||
	@continue = false
 | 
			
		||||
	@lex_state = EXPR_BEG
 | 
			
		||||
	until (@indent_stack.empty? || 
 | 
			
		||||
	       [TkLPAREN, TkLBRACK, TkLBRACE, 
 | 
			
		||||
	until (@indent_stack.empty? ||
 | 
			
		||||
	       [TkLPAREN, TkLBRACK, TkLBRACE,
 | 
			
		||||
		 TkfLPAREN, TkfLBRACK, TkfLBRACE].include?(@indent_stack.last))
 | 
			
		||||
	  @indent_stack.pop
 | 
			
		||||
	end
 | 
			
		||||
| 
						 | 
				
			
			@ -385,9 +385,9 @@ class RubyLex
 | 
			
		|||
      Token(TkNL)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    @OP.def_rules("*", "**",	
 | 
			
		||||
		  "=", "==", "===", 
 | 
			
		||||
		  "=~", "<=>",	
 | 
			
		||||
    @OP.def_rules("*", "**",
 | 
			
		||||
		  "=", "==", "===",
 | 
			
		||||
		  "=~", "<=>",
 | 
			
		||||
		  "<", "<=",
 | 
			
		||||
		  ">", ">=", ">>") do
 | 
			
		||||
      |op, io|
 | 
			
		||||
| 
						 | 
				
			
			@ -455,7 +455,7 @@ class RubyLex
 | 
			
		|||
	  @lex_state = EXPR_BEG;
 | 
			
		||||
	  Token(TkQUESTION)
 | 
			
		||||
	else
 | 
			
		||||
	  if (ch == '\\') 
 | 
			
		||||
	  if (ch == '\\')
 | 
			
		||||
	    read_escape
 | 
			
		||||
	  end
 | 
			
		||||
	  @lex_state = EXPR_END
 | 
			
		||||
| 
						 | 
				
			
			@ -469,8 +469,8 @@ class RubyLex
 | 
			
		|||
      @lex_state = EXPR_BEG
 | 
			
		||||
      Token(op)
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
    @OP.def_rules("+=", "-=", "*=", "**=", 
 | 
			
		||||
 | 
			
		||||
    @OP.def_rules("+=", "-=", "*=", "**=",
 | 
			
		||||
		  "&=", "|=", "^=", "<<=", ">>=", "||=", "&&=") do
 | 
			
		||||
      |op, io|
 | 
			
		||||
      @lex_state = EXPR_BEG
 | 
			
		||||
| 
						 | 
				
			
			@ -529,7 +529,7 @@ class RubyLex
 | 
			
		|||
 | 
			
		||||
    lex_int2
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  def lex_int2
 | 
			
		||||
    @OP.def_rules("]", "}", ")") do
 | 
			
		||||
      |op, io|
 | 
			
		||||
| 
						 | 
				
			
			@ -572,7 +572,7 @@ class RubyLex
 | 
			
		|||
	Token(TkOPASGN, "/") #/)
 | 
			
		||||
      elsif @lex_state == EXPR_ARG and @space_seen and peek(0) !~ /\s/
 | 
			
		||||
	identify_string(op)
 | 
			
		||||
      else 
 | 
			
		||||
      else
 | 
			
		||||
	@lex_state = EXPR_BEG
 | 
			
		||||
	Token("/") #/)
 | 
			
		||||
      end
 | 
			
		||||
| 
						 | 
				
			
			@ -588,7 +588,7 @@ class RubyLex
 | 
			
		|||
    # 	@lex_state = EXPR_BEG
 | 
			
		||||
    # 	Token(OP_ASGN, :^)
 | 
			
		||||
    #       end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @OP.def_rules(",") do
 | 
			
		||||
      |op, io|
 | 
			
		||||
      @lex_state = EXPR_BEG
 | 
			
		||||
| 
						 | 
				
			
			@ -598,8 +598,8 @@ class RubyLex
 | 
			
		|||
    @OP.def_rules(";") do
 | 
			
		||||
      |op, io|
 | 
			
		||||
      @lex_state = EXPR_BEG
 | 
			
		||||
      until (@indent_stack.empty? || 
 | 
			
		||||
	     [TkLPAREN, TkLBRACK, TkLBRACE, 
 | 
			
		||||
      until (@indent_stack.empty? ||
 | 
			
		||||
	     [TkLPAREN, TkLBRACK, TkLBRACE,
 | 
			
		||||
	       TkfLPAREN, TkfLBRACK, TkfLBRACE].include?(@indent_stack.last))
 | 
			
		||||
	@indent_stack.pop
 | 
			
		||||
      end
 | 
			
		||||
| 
						 | 
				
			
			@ -617,7 +617,7 @@ class RubyLex
 | 
			
		|||
      @lex_state = EXPR_BEG
 | 
			
		||||
      Token("~")
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @OP.def_rule("(") do
 | 
			
		||||
      |op, io|
 | 
			
		||||
      @indent += 1
 | 
			
		||||
| 
						 | 
				
			
			@ -718,7 +718,7 @@ class RubyLex
 | 
			
		|||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    #       @OP.def_rule("def", proc{|op, io| /\s/ =~ io.peek(0)}) do 
 | 
			
		||||
    #       @OP.def_rule("def", proc{|op, io| /\s/ =~ io.peek(0)}) do
 | 
			
		||||
    # 	|op, io|
 | 
			
		||||
    # 	@indent += 1
 | 
			
		||||
    # 	@lex_state = EXPR_FNAME
 | 
			
		||||
| 
						 | 
				
			
			@ -739,13 +739,13 @@ class RubyLex
 | 
			
		|||
      printf "MATCH: end %s: %s\n", op, io.inspect if RubyLex.debug?
 | 
			
		||||
      t
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    p @OP if RubyLex.debug?
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  def identify_gvar
 | 
			
		||||
    @lex_state = EXPR_END
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    case ch = getc
 | 
			
		||||
    when /[~_*$?!@\/\\;,=:<>".]/   #"
 | 
			
		||||
      Token(TkGVAR, "$" + ch)
 | 
			
		||||
| 
						 | 
				
			
			@ -761,12 +761,12 @@ class RubyLex
 | 
			
		|||
      ungetc
 | 
			
		||||
      ungetc
 | 
			
		||||
      identify_identifier
 | 
			
		||||
    else 
 | 
			
		||||
    else
 | 
			
		||||
      ungetc
 | 
			
		||||
      Token("$")
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  def identify_identifier
 | 
			
		||||
    token = ""
 | 
			
		||||
    if peek(0) =~ /[$@]/
 | 
			
		||||
| 
						 | 
				
			
			@ -781,7 +781,7 @@ class RubyLex
 | 
			
		|||
      token.concat ch
 | 
			
		||||
    end
 | 
			
		||||
    ungetc
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    if (ch == "!" || ch == "?") && token[0,1] =~ /\w/ && peek(0) != "="
 | 
			
		||||
      token.concat getc
 | 
			
		||||
    end
 | 
			
		||||
| 
						 | 
				
			
			@ -799,7 +799,7 @@ class RubyLex
 | 
			
		|||
      @lex_state = EXPR_END
 | 
			
		||||
      return Token(TkIVAR, token)
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    if @lex_state != EXPR_DOT
 | 
			
		||||
      print token, "\n" if RubyLex.debug?
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -927,7 +927,7 @@ class RubyLex
 | 
			
		|||
    @lex_state = EXPR_END
 | 
			
		||||
    Token(Ltype2Token[lt])
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  def identify_quotation
 | 
			
		||||
    ch = getc
 | 
			
		||||
    if lt = PERCENT_LTYPE[ch]
 | 
			
		||||
| 
						 | 
				
			
			@ -968,10 +968,10 @@ class RubyLex
 | 
			
		|||
	match = /[0-7_]/
 | 
			
		||||
      when /[89]/
 | 
			
		||||
	RubyLex.fail SyntaxError, "Illegal octal digit"
 | 
			
		||||
      else 
 | 
			
		||||
      else
 | 
			
		||||
	return Token(TkINTEGER)
 | 
			
		||||
      end
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      len0 = true
 | 
			
		||||
      non_digit = false
 | 
			
		||||
      while ch = getc
 | 
			
		||||
| 
						 | 
				
			
			@ -999,7 +999,7 @@ class RubyLex
 | 
			
		|||
      end
 | 
			
		||||
      return Token(TkINTEGER)
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    type = TkINTEGER
 | 
			
		||||
    allow_point = true
 | 
			
		||||
    allow_e = true
 | 
			
		||||
| 
						 | 
				
			
			@ -1042,7 +1042,7 @@ class RubyLex
 | 
			
		|||
    end
 | 
			
		||||
    Token(type)
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  def identify_string(ltype, quoted = ltype)
 | 
			
		||||
    @ltype = ltype
 | 
			
		||||
    @quoted = quoted
 | 
			
		||||
| 
						 | 
				
			
			@ -1063,7 +1063,7 @@ class RubyLex
 | 
			
		|||
	elsif ch == '\\' #'
 | 
			
		||||
	  read_escape
 | 
			
		||||
	end
 | 
			
		||||
	if PERCENT_PAREN.values.include?(@quoted) 
 | 
			
		||||
	if PERCENT_PAREN.values.include?(@quoted)
 | 
			
		||||
	  if PERCENT_PAREN[ch] == @quoted
 | 
			
		||||
	    nest += 1
 | 
			
		||||
	  elsif ch == @quoted
 | 
			
		||||
| 
						 | 
				
			
			@ -1087,7 +1087,7 @@ class RubyLex
 | 
			
		|||
      @lex_state = EXPR_END
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  def identify_comment
 | 
			
		||||
    @ltype = "#"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1103,7 +1103,7 @@ class RubyLex
 | 
			
		|||
    end
 | 
			
		||||
    return Token(TkCOMMENT)
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  def read_escape
 | 
			
		||||
    case ch = getc
 | 
			
		||||
    when "\n", "\r", "\f"
 | 
			
		||||
| 
						 | 
				
			
			@ -1120,7 +1120,7 @@ class RubyLex
 | 
			
		|||
	  break
 | 
			
		||||
	end
 | 
			
		||||
      end
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
    when "x"
 | 
			
		||||
      2.times do
 | 
			
		||||
	case ch = getc
 | 
			
		||||
| 
						 | 
				
			
			@ -1149,7 +1149,7 @@ class RubyLex
 | 
			
		|||
	read_escape
 | 
			
		||||
      end
 | 
			
		||||
    else
 | 
			
		||||
      # other characters 
 | 
			
		||||
      # other characters
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
#
 | 
			
		||||
#   irb/ruby-token.rb - ruby tokens 
 | 
			
		||||
#   irb/ruby-token.rb - ruby tokens
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
| 
						 | 
				
			
			@ -7,7 +7,7 @@
 | 
			
		|||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
module RubyToken
 | 
			
		||||
  EXPR_BEG = :EXPR_BEG
 | 
			
		||||
| 
						 | 
				
			
			@ -22,7 +22,7 @@ module RubyToken
 | 
			
		|||
  if !defined?(Symbol)
 | 
			
		||||
    Symbol = Integer
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
  class Token
 | 
			
		||||
    def initialize(seek, line_no, char_no)
 | 
			
		||||
      @seek = seek
 | 
			
		||||
| 
						 | 
				
			
			@ -87,7 +87,7 @@ module RubyToken
 | 
			
		|||
      if (tk = TkReading2Token[token]).nil?
 | 
			
		||||
	IRB.fail TkReading2TokenNoKey, token
 | 
			
		||||
      end
 | 
			
		||||
      tk = Token(tk[0], value) 
 | 
			
		||||
      tk = Token(tk[0], value)
 | 
			
		||||
      if tk.kind_of?(TkOp)
 | 
			
		||||
	tk.name = token
 | 
			
		||||
      end
 | 
			
		||||
| 
						 | 
				
			
			@ -96,8 +96,8 @@ module RubyToken
 | 
			
		|||
      if (tk = TkSymbol2Token[token]).nil?
 | 
			
		||||
	IRB.fail TkSymbol2TokenNoKey, token
 | 
			
		||||
      end
 | 
			
		||||
      return Token(tk[0], value) 
 | 
			
		||||
    else 
 | 
			
		||||
      return Token(tk[0], value)
 | 
			
		||||
    else
 | 
			
		||||
      if (token.ancestors & [TkId, TkVal, TkOPASGN, TkUnknownChar]).empty?
 | 
			
		||||
	token.new(@prev_seek, @prev_line_no, @prev_char_no)
 | 
			
		||||
      else
 | 
			
		||||
| 
						 | 
				
			
			@ -197,7 +197,7 @@ module RubyToken
 | 
			
		|||
    [:TkASSOC,      TkOp,   "=>"],
 | 
			
		||||
    [:TkQUESTION,   TkOp,   "?"],	 #?
 | 
			
		||||
    [:TkCOLON,      TkOp,   ":"],        #:
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    [:TkfLPAREN],         # func( #
 | 
			
		||||
    [:TkfLBRACK],         # func[ #
 | 
			
		||||
    [:TkfLBRACE],         # func{ #
 | 
			
		||||
| 
						 | 
				
			
			@ -253,7 +253,7 @@ module RubyToken
 | 
			
		|||
      IRB.fail AlreadyDefinedToken, token_n
 | 
			
		||||
    end
 | 
			
		||||
    token_c = eval("class #{token_n} < #{super_token}; end; #{token_n}")
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    if reading
 | 
			
		||||
      if TkReading2Token[reading]
 | 
			
		||||
	IRB.fail TkReading2TokenDuplicateError, token_n, reading
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,7 +7,7 @@
 | 
			
		|||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
require "e2mmap"
 | 
			
		||||
| 
						 | 
				
			
			@ -25,20 +25,20 @@ module IRB
 | 
			
		|||
    D_WARN = DOUT::def_notifier(1, "Warn: ")
 | 
			
		||||
    D_DEBUG = DOUT::def_notifier(2, "Debug: ")
 | 
			
		||||
    D_DETAIL = DOUT::def_notifier(4, "Detail: ")
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    DOUT.level = Notifier::D_NOMSG
 | 
			
		||||
 | 
			
		||||
    def initialize
 | 
			
		||||
      @head = Node.new("")
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    def def_rule(token, preproc = nil, postproc = nil, &block)
 | 
			
		||||
      D_DETAIL.pp token
 | 
			
		||||
 | 
			
		||||
      postproc = block if block_given?
 | 
			
		||||
      node = create(token, preproc, postproc)
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    def def_rules(*tokens, &block)
 | 
			
		||||
      if block_given?
 | 
			
		||||
	p = block
 | 
			
		||||
| 
						 | 
				
			
			@ -47,18 +47,18 @@ module IRB
 | 
			
		|||
	def_rule(token, nil, p)
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    def preproc(token, proc)
 | 
			
		||||
      node = search(token)
 | 
			
		||||
      node.preproc=proc
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
    #$BMW%A%'%C%/(B? 
 | 
			
		||||
 | 
			
		||||
    #$BMW%A%'%C%/(B?
 | 
			
		||||
    def postproc(token)
 | 
			
		||||
      node = search(token, proc)
 | 
			
		||||
      node.postproc=proc
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    def search(token)
 | 
			
		||||
      @head.search(token.split(//))
 | 
			
		||||
    end
 | 
			
		||||
| 
						 | 
				
			
			@ -66,7 +66,7 @@ module IRB
 | 
			
		|||
    def create(token, preproc = nil, postproc = nil)
 | 
			
		||||
      @head.create_subnode(token.split(//), preproc, postproc)
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    def match(token)
 | 
			
		||||
      case token
 | 
			
		||||
      when Array
 | 
			
		||||
| 
						 | 
				
			
			@ -79,14 +79,14 @@ module IRB
 | 
			
		|||
      D_DETAIL.exec_if{D_DEATIL.printf "match end: %s:%s\n", ret, token.inspect}
 | 
			
		||||
      ret
 | 
			
		||||
    end
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    def inspect
 | 
			
		||||
      format("<SLex: @head = %s>", @head.inspect)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    #----------------------------------------------------------------------
 | 
			
		||||
    #
 | 
			
		||||
    #   class Node - 
 | 
			
		||||
    #   class Node -
 | 
			
		||||
    #
 | 
			
		||||
    #----------------------------------------------------------------------
 | 
			
		||||
    class Node
 | 
			
		||||
| 
						 | 
				
			
			@ -100,7 +100,7 @@ module IRB
 | 
			
		|||
 | 
			
		||||
      attr_accessor :preproc
 | 
			
		||||
      attr_accessor :postproc
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      def search(chrs, opt = nil)
 | 
			
		||||
	return self if chrs.empty?
 | 
			
		||||
	ch = chrs.shift
 | 
			
		||||
| 
						 | 
				
			
			@ -115,7 +115,7 @@ module IRB
 | 
			
		|||
	  end
 | 
			
		||||
	end
 | 
			
		||||
      end
 | 
			
		||||
      
 | 
			
		||||
 | 
			
		||||
      def create_subnode(chrs, preproc = nil, postproc = nil)
 | 
			
		||||
	if chrs.empty?
 | 
			
		||||
	  if @postproc
 | 
			
		||||
| 
						 | 
				
			
			@ -128,7 +128,7 @@ module IRB
 | 
			
		|||
	  end
 | 
			
		||||
	  return self
 | 
			
		||||
	end
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
	ch = chrs.shift
 | 
			
		||||
	if node = @Tree[ch]
 | 
			
		||||
	  if chrs.empty?
 | 
			
		||||
| 
						 | 
				
			
			@ -162,7 +162,7 @@ module IRB
 | 
			
		|||
      # chrs: String
 | 
			
		||||
      #       character array
 | 
			
		||||
      #       io must have getc()/ungetc(); and ungetc() must be
 | 
			
		||||
      #       able to be called arbitrary number of times. 
 | 
			
		||||
      #       able to be called arbitrary number of times.
 | 
			
		||||
      #
 | 
			
		||||
      def match(chrs, op = "")
 | 
			
		||||
	D_DETAIL.print "match>: ", chrs, "op:", op, "\n"
 | 
			
		||||
| 
						 | 
				
			
			@ -257,14 +257,14 @@ if $0 == __FILE__
 | 
			
		|||
    print "1: ", tr.inspect, "\n"
 | 
			
		||||
    tr.def_rule("==") {print "==\n"}
 | 
			
		||||
    print "2: ", tr.inspect, "\n"
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    print "case 1:\n"
 | 
			
		||||
    print tr.match("="), "\n"
 | 
			
		||||
    print "case 2:\n"
 | 
			
		||||
    print tr.match("=="), "\n"
 | 
			
		||||
    print "case 3:\n"
 | 
			
		||||
    print tr.match("=>"), "\n"
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
  when "2"
 | 
			
		||||
    tr = SLex.new
 | 
			
		||||
    print "0: ", tr.inspect, "\n"
 | 
			
		||||
| 
						 | 
				
			
			@ -272,7 +272,7 @@ if $0 == __FILE__
 | 
			
		|||
    print "1: ", tr.inspect, "\n"
 | 
			
		||||
    tr.def_rule("==", proc{false}) {print "==\n"}
 | 
			
		||||
    print "2: ", tr.inspect, "\n"
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    print "case 1:\n"
 | 
			
		||||
    print tr.match("="), "\n"
 | 
			
		||||
    print "case 2:\n"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,7 +7,7 @@
 | 
			
		|||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
module IRB
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
#
 | 
			
		||||
#   irb/workspace-binding.rb - 
 | 
			
		||||
#   irb/workspace-binding.rb -
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
| 
						 | 
				
			
			@ -7,7 +7,7 @@
 | 
			
		|||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
module IRB
 | 
			
		||||
  class WorkSpace
 | 
			
		||||
| 
						 | 
				
			
			@ -22,7 +22,7 @@ module IRB
 | 
			
		|||
	case IRB.conf[:CONTEXT_MODE]
 | 
			
		||||
	when 0	# binding in proc on TOPLEVEL_BINDING
 | 
			
		||||
	  @binding = eval("proc{binding}.call",
 | 
			
		||||
		      TOPLEVEL_BINDING, 
 | 
			
		||||
		      TOPLEVEL_BINDING,
 | 
			
		||||
		      __FILE__,
 | 
			
		||||
		      __LINE__)
 | 
			
		||||
	when 1	# binding in loaded file
 | 
			
		||||
| 
						 | 
				
			
			@ -38,7 +38,7 @@ EOF
 | 
			
		|||
	when 2	# binding in loaded file(thread use)
 | 
			
		||||
	  unless defined? BINDING_QUEUE
 | 
			
		||||
	    require "thread"
 | 
			
		||||
	    
 | 
			
		||||
 | 
			
		||||
	    IRB.const_set("BINDING_QUEUE", SizedQueue.new(1))
 | 
			
		||||
	    Thread.abort_on_exception = true
 | 
			
		||||
	    Thread.start do
 | 
			
		||||
| 
						 | 
				
			
			@ -50,7 +50,7 @@ EOF
 | 
			
		|||
 | 
			
		||||
	when 3	# binging in function on TOPLEVEL_BINDING(default)
 | 
			
		||||
	  @binding = eval("def irb_binding; binding; end; irb_binding",
 | 
			
		||||
		      TOPLEVEL_BINDING, 
 | 
			
		||||
		      TOPLEVEL_BINDING,
 | 
			
		||||
		      __FILE__,
 | 
			
		||||
		      __LINE__ - 3)
 | 
			
		||||
	end
 | 
			
		||||
| 
						 | 
				
			
			@ -64,7 +64,7 @@ EOF
 | 
			
		|||
	when Module
 | 
			
		||||
	  @binding = eval("IRB.conf[:__MAIN__].module_eval('binding', __FILE__, __LINE__)", @binding, __FILE__, __LINE__)
 | 
			
		||||
	else
 | 
			
		||||
	  begin 
 | 
			
		||||
	  begin
 | 
			
		||||
	    @binding = eval("IRB.conf[:__MAIN__].instance_eval('binding', __FILE__, __LINE__)", @binding, __FILE__, __LINE__)
 | 
			
		||||
	  rescue TypeError
 | 
			
		||||
	    IRB.fail CantChangeBinding, @main.inspect
 | 
			
		||||
| 
						 | 
				
			
			@ -80,7 +80,7 @@ EOF
 | 
			
		|||
    def evaluate(context, statements, file = __FILE__, line = __LINE__)
 | 
			
		||||
      eval(statements, @binding, file, line)
 | 
			
		||||
    end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
    # error message manipulator
 | 
			
		||||
    def filter_backtrace(bt)
 | 
			
		||||
      case IRB.conf[:CONTEXT_MODE]
 | 
			
		||||
| 
						 | 
				
			
			@ -96,7 +96,7 @@ EOF
 | 
			
		|||
	return nil if bt =~ /irb\/.*\.rb/
 | 
			
		||||
      when 3
 | 
			
		||||
	return nil if bt =~ /irb\/.*\.rb/
 | 
			
		||||
	bt.sub!(/:\s*in `irb_binding'/){""} 
 | 
			
		||||
	bt.sub!(/:\s*in `irb_binding'/){""}
 | 
			
		||||
      end
 | 
			
		||||
      bt
 | 
			
		||||
    end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
#
 | 
			
		||||
#   irb/ws-for-case-2.rb - 
 | 
			
		||||
#   irb/ws-for-case-2.rb -
 | 
			
		||||
#   	$Release Version: 0.9.5$
 | 
			
		||||
#   	$Revision$
 | 
			
		||||
#   	$Date$
 | 
			
		||||
| 
						 | 
				
			
			@ -7,7 +7,7 @@
 | 
			
		|||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
while true
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,7 +7,7 @@
 | 
			
		|||
#
 | 
			
		||||
# --
 | 
			
		||||
#
 | 
			
		||||
#   
 | 
			
		||||
#
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
require "irb"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
# The Mail class represents an internet mail message (as per RFC822, RFC2822)
 | 
			
		||||
# with headers and a body. 
 | 
			
		||||
# with headers and a body.
 | 
			
		||||
class Mail
 | 
			
		||||
 | 
			
		||||
  # Create a new Mail where +f+ is either a stream which responds to gets(),
 | 
			
		||||
| 
						 | 
				
			
			@ -31,7 +31,7 @@ class Mail
 | 
			
		|||
	  @header[attr] += "\n" + line
 | 
			
		||||
	end
 | 
			
		||||
      end
 | 
			
		||||
  
 | 
			
		||||
 | 
			
		||||
      return unless line
 | 
			
		||||
 | 
			
		||||
      while line = f.gets()
 | 
			
		||||
| 
						 | 
				
			
			@ -53,7 +53,7 @@ class Mail
 | 
			
		|||
    return @body
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  # Return the header corresponding to +field+. 
 | 
			
		||||
  # Return the header corresponding to +field+.
 | 
			
		||||
  #
 | 
			
		||||
  # Matching is case-insensitive.
 | 
			
		||||
  def [](field)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
Some files were not shown because too many files have changed in this diff Show more
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue