Module: PathCommon

Included in:
GitHack, GitHack::GitRepo
Defined in:
lib/core_ext/path.rb

Instance Method Summary collapse

Instance Method Details

#absolute_path(path, dir = Dir.pwd) ⇒ Object



13
14
15
# File 'lib/core_ext/path.rb', line 13

def absolute_path(path,dir=Dir.pwd)
	Pathname.new(path).relative? ? File.expand_path(path,dir) : File.expand_path(path,"/")
end

#join(path, file = ".") ⇒ Object



20
21
22
# File 'lib/core_ext/path.rb', line 20

def join(path,file=".")
 File.join(path,file)
end

#project_dirObject

返回项目绝对目录



10
11
12
# File 'lib/core_ext/path.rb', line 10

def project_dir
  absolute_path("#{File.dirname(__FILE__)}/../../")
end

#project_file(path) ⇒ Object

给定相对项目根目录路径,返回绝对路径



6
7
8
# File 'lib/core_ext/path.rb', line 6

def project_file(path)
	join(project_dir,path)
end

#require_p(path) ⇒ Object

require file from project dir



17
18
19
# File 'lib/core_ext/path.rb', line 17

def require_p(path)
  require join(project_dir,path)
end