module Minimart::Utils::FileHelper
Public Class Methods
cookbook_in_path?(path)
click to toggle source
Determine whether or not a given directory contains a cookbook. @param [String] path The directory to check @return [Boolean]
# File lib/minimart/utils/file_helper.rb, line 25 def self.cookbook_in_path?(path) file_exists?(File.join(path, 'metadata.json')) || file_exists?(File.join(path, 'metadata.rb')) end
cookbook_path_in_directory(path)
click to toggle source
Find the first cookbook in the given path @param [String] path The directory to search for cookbooks in @return [String] The path to the cookbook
# File lib/minimart/utils/file_helper.rb, line 10 def self.cookbook_path_in_directory(path) cookbook_in_path?(path) ? path : find_cookbooks_in_directory(path).first end
file_exists?(path)
click to toggle source
# File lib/minimart/utils/file_helper.rb, line 30 def self.file_exists?(path) File.exists?(path) end
find_cookbooks_in_directory(path)
click to toggle source
List all of the cookbooks in a given directory @param [String] path The directory to find cookbooks in @return [Array<String>] An array of paths to any cookbooks found in the supplied path.
raise NoCookbooksFoundError
if cookbooks.empty?
# File lib/minimart/utils/file_helper.rb, line 18 def self.find_cookbooks_in_directory(path) Dir.glob(File.join(path, '/*/')).select { |d| cookbook_in_path?(d) } end