summaryrefslogtreecommitdiff
path: root/lib/leap_cli/path.rb
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2012-11-13 22:49:32 -0800
committerelijah <elijah@riseup.net>2012-11-13 22:49:32 -0800
commit10bd0ba9d66a32cb8e0f7fb322843005b23181b7 (patch)
tree5768b4fc787b189b5df9035596d7de945342852f /lib/leap_cli/path.rb
parent622236c3ad6abc4aef200cc2d4fc2a09effd8647 (diff)
cleaned up logging, and much improved error message when file is not found
Diffstat (limited to 'lib/leap_cli/path.rb')
-rw-r--r--lib/leap_cli/path.rb15
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/leap_cli/path.rb b/lib/leap_cli/path.rb
index 48b0d11..ed4e478 100644
--- a/lib/leap_cli/path.rb
+++ b/lib/leap_cli/path.rb
@@ -105,14 +105,14 @@ module LeapCli; module Path
end
#
- # tries to find a file somewhere with 'filename', under a directory 'name' if possible.
+ # tries to find a file somewhere with 'filename' (which is probably in the form [node.name, filename])
#
- def self.find_file(name, filename)
+ def self.find_file(filename)
# named path?
- if filename.is_a? Symbol
- path = named_path([filename, name], platform_provider)
+ if filename.is_a? Array
+ path = named_path(filename, platform_provider)
return path if File.exists?(path)
- path = named_path([filename, name], provider)
+ path = named_path(filename, provider)
return path if File.exists?(path)
end
@@ -162,6 +162,11 @@ module LeapCli; module Path
File.exists?(named_path(name, provider_dir))
end
+ def self.relative_path(path)
+ path = named_path(path)
+ path.sub(/^#{Regexp.escape(provider)}\//,'')
+ end
+
private
def self.find_in_directory_tree(filename)