Top Level Namespace

Defined Under Namespace

Modules: Knut_tools, Rake, YAML Classes: File, Gem_packer, Hash

Instance Method Summary collapse

Instance Method Details

#old_requireObject

Store require to use it in the redefinition.



47
# File 'lib/knut_tools/required_what.rb', line 47

alias :old_require :require

#require(package) ⇒ Object

Redefine require, to get an ‘expanded $“’ ($LOADED_FEATURES_FULL) All loaded features, but with the complete path.

If there is a name conflict between the files you load, a warning is collected in



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/knut_tools/required_what.rb', line 56

def require( package )
  #make the original require and return if there was a failure.
  return false unless old_require package
  loaded = $LOADED_FEATURES.last #get the filename of the last load
  found = []        #help variable to collect possible file pathes.
  #loop on search pathes
  $LOAD_PATH.each{|searchpath|  
    #Check if the last load is found in the search path
    found << "#{searchpath}/#{loaded}" if File.exist?( "#{searchpath}/#{loaded}")
  }

  #Store the path of the loaded feature
  $LOADED_FEATURES_FULL << found.first 
  case found.size
  when 0  #May not happen.
    $LOADED_FEATURES_WARN << "require: loaded #{loaded}, but don't know from where"
  when 1  #Everything ok.
  else
    $LOADED_FEATURES_WARN << "Filename conflict in require: #{loaded}: #{found.inspect}"
  end #found.size

  true  #return result of old_require
end

#test(txt) ⇒ Object



95
96
97
98
99
100
101
102
103
104
105
# File 'lib/knut_tools/yaml.rb', line 95

def test( txt  )
	puts '>>>>>>>>>>>>>>'
	puts "in:\t#{txt.inspect}"
	y = YAML.load( txt )
	puts "out:\t#{y.inspect}"
	puts "yaml:\t#{y.to_yaml.inspect}"
	puts y.to_yaml()
	puts y.to_yaml( :SortKey => true  )
	puts y.to_yaml( :SortKey => false  )
	puts '<<<<<<<<<<<<<<'
end