Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Ruby gem newbie question
David Madden
5/16/2008 10:27:00 AM
Hi,
I am trying to create a ruby gem and I have a slight problem finding a
file within it.
The structure of the code in my gem is as follows:
/
bin/
ai
lib/
app.rb
app/
# src files
templates/
default.txt
etc.
The gem loads fine, my problem is that I cannot find the default.txt
file in the templates dir from within the code in the app dir when it is
used from the command line.
I think it is trying to find the file in the working directory, but it
is inside the gem. I have a line in my src file:
DEFAULT = "../templates/default.txt"
What should I put in order to point to the file within the gem?
Thanks.
David.
--
Posted via
http://www.ruby-...
.
1 Answer
David Madden
5/16/2008 11:45:00 AM
0
Ok, I found a fix. I am not sure if this is the correct way but it seems
to work.
TEMPLATE_DIR = "/../templates/"
DEFAULT = "default.txt"
template = File.dirname(__FILE__) + TEMPLATE_DIR + DEFAULT
--
Posted via
http://www.ruby-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Ruby gem newbie question
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password