summaryrefslogtreecommitdiff
path: root/lib/leap_cli/util.rb
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2015-01-22 14:12:14 -0800
committerelijah <elijah@riseup.net>2015-01-22 14:12:14 -0800
commit0bb30766e6f6fe1832343132b3433533e7b314a0 (patch)
tree587114d6fee2c8f4b74df5d06015397c0d5e3dcd /lib/leap_cli/util.rb
parent5dbbc5ba6d4e83f11bf4787dc020865001ad8ef4 (diff)
added support for custom tests in files/tests
Diffstat (limited to 'lib/leap_cli/util.rb')
-rw-r--r--lib/leap_cli/util.rb44
1 files changed, 28 insertions, 16 deletions
diff --git a/lib/leap_cli/util.rb b/lib/leap_cli/util.rb
index ce5471c..9edb150 100644
--- a/lib/leap_cli/util.rb
+++ b/lib/leap_cli/util.rb
@@ -97,6 +97,23 @@ module LeapCli
return output
end
+ def assert_config!(conf_path)
+ value = nil
+ begin
+ value = manager.instance_eval(conf_path)
+ #rescue NoMethodError
+ #rescue NameError
+ ensure
+ assert! !value.nil? && value != "REQUIRED" do
+ log :missing, "required configuration value for #{conf_path}"
+ end
+ end
+ end
+
+ ##
+ ## FILES AND DIRECTORIES
+ ##
+
def assert_files_missing!(*files)
options = files.last.is_a?(Hash) ? files.pop : {}
base = options[:base] || Path.provider
@@ -117,19 +134,6 @@ module LeapCli
end
end
- def assert_config!(conf_path)
- value = nil
- begin
- value = manager.instance_eval(conf_path)
- #rescue NoMethodError
- #rescue NameError
- ensure
- assert! !value.nil? && value != "REQUIRED" do
- log :missing, "required configuration value for #{conf_path}"
- end
- end
- end
-
def assert_files_exist!(*files)
options = files.last.is_a?(Hash) ? files.pop : {}
file_list = files.collect { |file_path|
@@ -149,6 +153,7 @@ module LeapCli
end
end
+ # takes a list of symbolic paths. returns true if all files exist or are directories.
def file_exists?(*files)
files.each do |file_path|
file_path = Path.named_path(file_path)
@@ -159,9 +164,16 @@ module LeapCli
return true
end
- ##
- ## FILES AND DIRECTORIES
- ##
+ # takes a list of symbolic paths. returns true if all are directories.
+ def dir_exists?(*dirs)
+ dirs.each do |dir_path|
+ dir_path = Path.named_path(dir_path)
+ if !Dir.exists?(dir_path)
+ return false
+ end
+ end
+ return true
+ end
#
# creates a directory if it doesn't already exist