I'm looking for a way for Sinatra to get filenames in the models, routes, and helpers directories.
app.rb
helpers
_init.rb
alpha.rb
bravo.rb
models
_init.rb
gulf.rb
hotel.rb
routes
_init.rb
kilo.rb
lima.rb
So in helpers/_init.rb I want to build an array of files for requiring:
.
..
_init.rb
alpha.rb
bravo.rb
reqs = Dir.entries('helpers').select {|i| i =~ /^[a-z]+.rb/}
I'd like to abstract this as much as I can, and make sure I'm using the right directory. Because this is a required with no direct output to anything I can really see, I'm winging it. Would be nice to know how to output to the MacOS console, if you know how that is done, that would be excellent.
Instead of ('models'), I'm trying Dir.getwd and it's coughing up an error.
cannot load such file -- /Library/WebServer/Documents/usersys/models/app (LoadError)
So it looks like Dir.getwd is resolving to the site root. Is there no way to have models/_init.rb know it's in the models directory?
Cheers