module Grass

Constants

VERSION

Public Class Methods

app_root() click to toggle source
# File lib/grass.rb, line 25
def app_root
  @@app_root ||= "#{self.root}/app".gsub("//","/")
end
cache() click to toggle source
# File lib/grass.rb, line 29
def cache
  $cache ||= begin
    config = self.load_config('cache')
    Dalli::Client.new config.delete("servers").split(","), config.symbolize_keys!
  end
end
cache=(cache) click to toggle source
# File lib/grass.rb, line 36
def cache=cache
  $cache = cache
end
env() click to toggle source
# File lib/grass.rb, line 40
def env
  ENV['RACK_ENV'] ||= "development"
end
gem_root() click to toggle source
# File lib/grass.rb, line 13
def gem_root
  @@gemroot ||= File.expand_path('../..', __FILE__)
end
load_config(file) click to toggle source
# File lib/grass.rb, line 44
def load_config file
  db_conf = YAML.load(ERB.new(File.read("#{Grass.root}/config/#{file}.yml")).result)[self.env]
end
root() click to toggle source
# File lib/grass.rb, line 17
def root
  @@root ||= find_root_with_flag("Procfile", Dir.pwd).to_s
end
root=(root) click to toggle source
# File lib/grass.rb, line 21
def root= root
  @@root = root
end

Private Class Methods

find_root_with_flag(flag, default=nil) click to toggle source

i steal this from rails

# File lib/grass.rb, line 53
def self.find_root_with_flag(flag, default=nil)
  root_path = self.class.called_from[0]

  while root_path && ::File.directory?(root_path) && !::File.exist?("#{root_path}/#{flag}")
    parent = ::File.dirname(root_path)
    root_path = parent != root_path && parent
  end

  root = ::File.exist?("#{root_path}/#{flag}") ? root_path : default
  raise "Could not find root path for #{self}" unless root

  RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ ?
  Pathname.new(root).expand_path : Pathname.new(root).realpath
end