Class: Rack::Cappuccino
- Inherits:
-
Sinatra::Base
- Object
- Sinatra::Base
- Rack::Cappuccino
- Defined in:
- lib/rack/cappuccino.rb
Constant Summary collapse
- VERSION =
"0.0.2"
- CALLER =
Caller from when this file is loaded. Includes
config.ru
which we need forroot
. caller
Class Method Summary collapse
-
.root ⇒ Object
Little big of magic to find the directory of the
config.ru
file, ie: the root directory for our application.
Class Method Details
.root ⇒ Object
Little big of magic to find the directory of the config.ru
file, ie: the root directory for our application.
It looks through CALLER
for a call originating from config.ru
, extracts it’s relative path out and join it with Dir.getwd
. This gives us the full path to config.ru
and subsequently the root of our app.
If config.ru
was not used, it raises an error.
22 23 24 25 26 27 28 |
# File 'lib/rack/cappuccino.rb', line 22 def self.root config = CALLER.select { |c| c =~ /(config.ru)/ }.first config = config.scan(/(^.*?config\.ru)/).flatten.first ::File.dirname(::File.join(Dir.getwd, config)) rescue NoMethodError => e raise "Rack::Cappuccino apps must be loaded from a config.ru file." end |