Module: GitDeploy::RemotePath
- Defined in:
- lib/git_deploy/remote_path.rb
Constant Summary collapse
- SCP_PATH =
%r{\A(?:[^@]+@)?[^:]+:(.+)\z}
Class Method Summary collapse
Class Method Details
.deploy_path(url, home: nil) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/git_deploy/remote_path.rb', line 20 def self.deploy_path(url, home: nil) path = raw_path(url) return path if path.start_with?('/', '~') home = yield if home.nil? && block_given? File.join(home, path) end |
.raw_path(url) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/git_deploy/remote_path.rb', line 7 def self.raw_path(url) if url.nil? || url.to_s.strip.empty? abort "Error: No deploy remote URL configured. Specify a remote with -r." end if url.match?(%r{\A[\w-]+://}) URI.parse(url).path else match = url.match(SCP_PATH) match ? match[1] : url end end |