summaryrefslogtreecommitdiff
path: root/provider_base/lib/macros/files.rb
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2014-10-31 00:01:57 -0700
committerelijah <elijah@riseup.net>2014-10-31 00:01:57 -0700
commit1d4670f8b9b4c1f3d4cd8017a3f6145ccdd41312 (patch)
treed3272ca05c567219d1f9a476b56f2a8cb808cb19 /provider_base/lib/macros/files.rb
parentd3e24760b33d6ae20f153d3c144d7d443fb0b69e (diff)
add support for property tor.key
Diffstat (limited to 'provider_base/lib/macros/files.rb')
-rw-r--r--provider_base/lib/macros/files.rb14
1 files changed, 12 insertions, 2 deletions
diff --git a/provider_base/lib/macros/files.rb b/provider_base/lib/macros/files.rb
index b3ba4a06..958958bc 100644
--- a/provider_base/lib/macros/files.rb
+++ b/provider_base/lib/macros/files.rb
@@ -48,13 +48,22 @@ module LeapCli
# * if the path does not exist locally, but exists in provider_base, then the default file from
# provider_base is copied locally. this is required for rsync to work correctly.
#
- def file_path(path)
+ def file_path(path, options={})
if path.is_a? Symbol
path = [path, @node.name]
+ elsif path.is_a? String
+ # ensure it prefixed with files/
+ unless path =~ /^files\//
+ path = "files/" + path
+ end
end
actual_path = Path.find_file(path)
if actual_path.nil?
- Util::log 2, :skipping, "file_path(\"#{path}\") because there is no such file."
+ if options[:missing]
+ raise FileMissing.new(Path.named_path(path), options)
+ else
+ Util::log 2, :skipping, "file_path(\"#{path}\") because there is no such file."
+ end
nil
else
if actual_path =~ /^#{Regexp.escape(Path.provider_base)}/
@@ -70,6 +79,7 @@ module LeapCli
actual_path += '/' # ensure directories end with /, important for building rsync command
end
relative_path = Path.relative_path(actual_path)
+ relative_path.sub!(/^files\//, '') # remove "files/" prefix
@node.file_paths << relative_path
File.join(Leap::Platform.files_dir, relative_path)
end