R
Roger Pack
This has probably been done "1,000,000" times, but here's another hack
at it.
The background:
If you've ever gotten a message like
../smart_require/test.rb:1: warning: already initialized constant A
you know that ruby 1.8.x "re-requires" a file if you pass in a different
paths to the same file.
ex:
require 'test.rb'
require '../current_dir/test.rb'
results in test.rb being loaded twice, despite the semantics of require
being that it loads only once.
Ruby 1.9 overcomes this.
This file overcomes this for 1.8.x
ex:
c:\dev>ruby example_bad.rb
../dev/test.rb:1: warning: already initialized constant A
C:\dev\>ruby -runique_require example_bad.rb
# no warning is displayed
To use:
download the unique_require.rb file from
http://github.com/rogerdpack/roger-useful/tree/master
unique_require folder
require it [preferably first].
Feedback welcome.
-=r
at it.
The background:
If you've ever gotten a message like
../smart_require/test.rb:1: warning: already initialized constant A
you know that ruby 1.8.x "re-requires" a file if you pass in a different
paths to the same file.
ex:
require 'test.rb'
require '../current_dir/test.rb'
results in test.rb being loaded twice, despite the semantics of require
being that it loads only once.
Ruby 1.9 overcomes this.
This file overcomes this for 1.8.x
ex:
c:\dev>ruby example_bad.rb
../dev/test.rb:1: warning: already initialized constant A
C:\dev\>ruby -runique_require example_bad.rb
# no warning is displayed
To use:
download the unique_require.rb file from
http://github.com/rogerdpack/roger-useful/tree/master
unique_require folder
require it [preferably first].
Feedback welcome.
-=r