Requiring in a Java-like Import Way

Z

Zach Dennis

Since Navindra wanted to know how-to handle java-like imports I've
blogged my solution which allows:

require 'mypackage.subpackage.file'
require 'mypackage.*'

to be used. So check it out if this you're interested...

http://blog.mktec.com/zdennis/ruby

Zach
 
N

Navindra Umanee

Zach Dennis said:
Since Navindra wanted to know how-to handle java-like imports I've
blogged my solution which allows:

require 'mypackage.subpackage.file'
require 'mypackage.*'

to be used. So check it out if this you're interested...

http://blog.mktec.com/zdennis/ruby

That's actually neat... thanks.

Cheers,
Navin.
 
R

Robert Klemme

Zach Dennis said:
Since Navindra wanted to know how-to handle java-like imports I've blogged
my solution which allows:

require 'mypackage.subpackage.file'
require 'mypackage.*'

to be used. So check it out if this you're interested...

http://blog.mktec.com/zdennis/ruby

some remarks: I'd change "what.gsub!( /\./, '/' )" into "what = what.gsub(
/\./, '/' )" in order to not fiddle with the argument (could be frozen after
all). Is it possible that your regexp should've read "if( what =~
/^(.*)\.\*$/ )" (main issue the missing "\.")?

Kind regards

robert
 
Z

Zach Dennis

Robert said:
some remarks: I'd change "what.gsub!( /\./, '/' )" into "what =
what.gsub( /\./, '/' )" in order to not fiddle with the argument (could
be frozen after all).

Ah...yes. thx
Is it possible that your regexp should've read
"if( what =~ /^(.*)\.\*$/ )" (main issue the missing "\.")?

its possible for someone to name a file "file*" but that is poor naming,
but entirely possible! I'll make the update for the "\." to be. thx for
pointing this out.

Zach
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top