Fail when `mkdir' misses arguments

This commit is contained in:
Thibault Jouan
2014-10-09 20:12:44 +00:00
parent fdfd5df26f
commit 3f82b923b7
2 changed files with 13 additions and 10 deletions

View File

@@ -3,6 +3,8 @@ module Producer
module Actions
class Mkdir < Action
def setup
check_arguments_size! 1
@path = Pathname.new(arguments.first)
@options[:permissions] = @options.delete :mode if @options.key? :mode
@options[:owner] = @options.delete :user if @options.key? :user
end
@@ -12,19 +14,12 @@ module Producer
end
def apply
path.descend do |p|
@path.descend do |p|
next if fs.dir? p
fs.mkdir p.to_s
fs.setstat p.to_s, @options unless @options.empty?
end
end
private
def path
Pathname.new(arguments.first)
end
end
end
end