Class: Rails
- Inherits:
-
Object
- Object
- Rails
- Defined in:
- lib/underglow/rails/environment.rb
Overview
Mock a Rails class that supplies the env and root if it’s not defined
Class Method Summary collapse
Class Method Details
.env ⇒ Object
7 8 9 |
# File 'lib/underglow/rails/environment.rb', line 7 def self.env ENV['RAILS_ENV'] || "development" end |
.root ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/underglow/rails/environment.rb', line 11 def self.root # File.dirname(File.dirname(File.expand_path(__FILE__))) if env == "development" if File.exists?("/vagrant") root = "/vagrant" else raise Exception, "Couldn't find root!" end else caller_path = "#{Dir.pwd}/#{caller.last.split(":").first}" # Assume we are using capistrano, so whatever is /*/current would be the root root = caller_path.sub(/\/current\/.*/, "/current") end Pathname.new(root) end |