Extract make_directory_for

This commit is contained in:
David Heinemeier Hansson
2023-01-23 10:37:19 +01:00
parent cd44014069
commit 148c43fe29
3 changed files with 11 additions and 7 deletions

View File

@@ -14,12 +14,8 @@ class Mrsk::Cli::Accessory < Mrsk::Cli::Base
accessory = MRSK.accessory(name)
on(accessory.host) do
accessory.files.each do |(local, remote)|
if Pathname.new(local).exist?
execute :mkdir, "-p", Pathname.new(remote).dirname.to_s
upload! local.to_s, remote.to_s
else
raise "Missing file: #{local}"
end
execute *accessory.make_directory_for(local, remote)
upload! local, remote
end
end
end

View File

@@ -46,6 +46,14 @@ class Mrsk::Commands::Accessory < Mrsk::Commands::Base
).join(" "), host: host
end
def make_directory_for(local, remote)
if Pathname.new(local).exist?
[ :mkdir, "-p", Pathname.new(remote).dirname.to_s ]
else
raise "Missing file: #{local}"
end
end
def remove_files
[ :rm, "-rf", service_name ]
end

View File

@@ -66,7 +66,7 @@ class Mrsk::Configuration::Assessory
end
def expand_local_file_path(local_file)
Pathname.new(File.expand_path(local_file))
Pathname.new(File.expand_path(local_file)).to_s
end
def expand_remote_file_path(remote_file)