Support `mkdir' status attributes

This commit is contained in:
Thibault Jouan
2014-10-08 11:21:32 +00:00
parent 6f2ff17b94
commit a84b34b7ca
7 changed files with 53 additions and 33 deletions

View File

@@ -7,11 +7,12 @@ module Producer
def_delegators :@env, :input, :output, :error_output, :remote
def_delegators :remote, :fs
attr_reader :env, :arguments
attr_reader :env, :arguments, :options
def initialize(env, *args)
def initialize(env, *args, **options)
@env = env
@arguments = args
@options = options
end
def name

View File

@@ -2,6 +2,12 @@ module Producer
module Core
module Actions
class Mkdir < Action
def initialize(env, *args, **options)
super
@options[:permissions] = @options.delete :mode if @options.key? :mode
@options[:owner] = @options.delete :user if @options.key? :user
end
def name
'mkdir'
end
@@ -10,7 +16,7 @@ module Producer
path.descend do |p|
next if fs.dir? p
fs.mkdir p.to_s
fs.chmod p.to_s, mode if mode
fs.setstat p.to_s, @options unless @options.empty?
end
end
@@ -20,10 +26,6 @@ module Producer
def path
Pathname.new(arguments.first)
end
def mode
arguments[1]
end
end
end
end

View File

@@ -20,13 +20,16 @@ module Producer
false
end
def chmod(path, mode)
sftp.setstat! path, permissions: mode
def setstat(path, attributes)
sftp.setstat! path, attributes
end
def mkdir(path, mode = nil)
options = mode ? { permissions: mode } : {}
sftp.mkdir! path, options
def chmod(path, mode)
setstat path, permissions: mode
end
def mkdir(path, attributes = {})
ret = sftp.mkdir! path, attributes
end
def file_read(path)