Module: Rpremote::RemotePath
- Defined in:
- lib/rpremote/remote_path.rb,
sig/rpremote.rbs
Constant Summary collapse
- PREFIX =
":"
Class Method Summary collapse
Class Method Details
.remote?(path) ⇒ Boolean
9 10 11 |
# File 'lib/rpremote/remote_path.rb', line 9 def remote?(path) path.start_with?(PREFIX) end |
.unwrap(path) ⇒ String
13 14 15 |
# File 'lib/rpremote/remote_path.rb', line 13 def unwrap(path) path.delete_prefix(PREFIX) end |
.validate(path) ⇒ String
17 18 19 20 21 22 23 24 25 |
# File 'lib/rpremote/remote_path.rb', line 17 def validate(path) raise ArgumentError, "path must be remote (prefix it with :)" unless remote?(path) remote = unwrap(path) raise ArgumentError, "remote path must be absolute" unless remote.start_with?("/") raise ArgumentError, "remote path must not contain .." if remote.split("/").include?("..") remote end |