module Slugforge::Helper::Path
Public Class Methods
included(base)
click to toggle source
# File lib/slugforge/helper/path.rb, line 6 def self.included(base) base.extend ClassMethods base.source_root base.templates_dir end
Public Instance Methods
deploy_dir(*paths)
click to toggle source
# File lib/slugforge/helper/path.rb, line 49 def deploy_dir(*paths) @deploy_dir ||= File.join('/opt', 'apps', project_name) File.join(@deploy_dir, *paths) end
project_path(*paths)
click to toggle source
# File lib/slugforge/helper/path.rb, line 11 def project_path(*paths) File.join(project_root, *paths) end
project_root()
click to toggle source
# File lib/slugforge/helper/path.rb, line 15 def project_root return @locate_project unless @locate_project.nil? if options[:path] && Dir.exist?(File.expand_path(options[:path])) return File.expand_path(options[:path]) end path = File.expand_path(Dir.pwd) paths = path.split('/') until paths.empty? if Dir.exist?(File.join(*paths, '.git')) @locate_project = File.join(*paths) return @locate_project end paths.pop end raise error_class, "Invalid path. Unable to find a .git project anywhere in path #{path}. Specify a path with --path." end
release_dir(*paths)
click to toggle source
# File lib/slugforge/helper/path.rb, line 54 def release_dir(*paths) deploy_dir('releases', sha) end
scripts_dir(*paths)
click to toggle source
# File lib/slugforge/helper/path.rb, line 41 def scripts_dir(*paths) File.join(self.class.scripts_dir, *paths) end
system_with_path(cmd, path=nil)
click to toggle source
# File lib/slugforge/helper/path.rb, line 58 def system_with_path(cmd, path=nil) path ||= options[:path] cwd_command = path ? "cd #{path} && " : "" ::Bundler.with_clean_env { system("#{cwd_command}#{cmd}") } end
templates_dir(*paths)
click to toggle source
# File lib/slugforge/helper/path.rb, line 45 def templates_dir(*paths) File.join(self.class.templates_dir, *paths) end
upstart_dir()
click to toggle source
# File lib/slugforge/helper/path.rb, line 34 def upstart_dir @upstart_conf_dir ||= project_path('deploy', 'upstart').tap do |dir| FileUtils.mkdir_p(dir) end end