diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/resource/remote_file.rb | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/lib/chef/resource/remote_file.rb b/lib/chef/resource/remote_file.rb index a10a0996a6..6334b1bf44 100644 --- a/lib/chef/resource/remote_file.rb +++ b/lib/chef/resource/remote_file.rb @@ -40,16 +40,16 @@ class Chef @provider = Chef::Provider::RemoteFile end + # source can take any of the following as arguments + # - A single string argument + # - Multiple string arguments + # - An array or strings + # - A delayed evaluator that evaluates to a string + # or array of strings + # All strings must be parsable as URIs. + # source returns an array of strings. def source(*args) - arg = if args.empty? - nil - elsif args[0].is_a?(Chef::DelayedEvaluator) && args.count == 1 - args[0] - elsif args.any? {|a| a.is_a?(Chef::DelayedEvaluator)} && args.count > 1 - raise Exceptions::InvalidRemoteFileURI, "Only 1 DelayedEvaluator is allowed" - else - Array(args).flatten - end + arg = parse_source_args(args) ret = set_or_return(:source, arg, { :callbacks => { @@ -62,6 +62,18 @@ class Chef end end + def parse_source_args(args) + if args.empty? + nil + elsif args[0].is_a?(Chef::DelayedEvaluator) && args.count == 1 + args[0] + elsif args.any? {|a| a.is_a?(Chef::DelayedEvaluator)} && args.count > 1 + raise Exceptions::InvalidRemoteFileURI, "Only 1 source argument allowed when using a lazy evaluator" + else + Array(args).flatten + end + end + def checksum(args=nil) set_or_return( :checksum, |