Class: Utilio::Path

Inherits:
Object
  • Object
show all
Defined in:
lib/utilio/path.rb

Constant Summary collapse

APP_ROOT =
File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))

Class Method Summary collapse

Class Method Details

.app(*folders) ⇒ Object



19
20
21
# File 'lib/utilio/path.rb', line 19

def app *folders
  root(*['app', folders].flatten)
end

.root(*folders) ⇒ Object

Get the root path of the application, optionally passing in additional folders to be joined and expanded e.g. PathUtils.root ‘db’, ‘migrate’ # => /path/to/loudmouth/db/migrate



15
16
17
# File 'lib/utilio/path.rb', line 15

def root *folders
  File.expand_path(File.join(*([app_root, folders].flatten.uniq.tap{|path| path.delete(nil) })))
end

.root=(new_root) ⇒ Object



9
10
11
# File 'lib/utilio/path.rb', line 9

def root= new_root
  @app_root = new_root
end

.yaml_file(*path_to_file) ⇒ Object



23
24
25
# File 'lib/utilio/path.rb', line 23

def yaml_file *path_to_file
  YAML.load_file(root(*path_to_file))
end