Sha256: 91ee3300209b7c39c2ce2822652e88413d3434a232c5e2e4d29153df355666fa
Contents?: true
Size: 1.23 KB
Versions: 17
Compression:
Stored size: 1.23 KB
Contents
module Berkshelf module Validator class << self # Perform a complete cookbook validation checking: # * File names for inappropriate characters # * Invalid Ruby syntax # * Invalid ERB templates # # @param [Array<CachedCookbook>, CachedCookbook] cookbooks # the Cookbook(s) to validate def validate(cookbooks) Array(cookbooks).each do |cookbook| validate_files(cookbook) cookbook.validate end end # Validate that the given cookbook does not have "bad" files. Currently # this means including spaces in filenames (such as recipes) # # @param [Array<CachedCookbook>, CachedCookbook] cookbooks # the Cookbook(s) to validate def validate_files(cookbooks) Array(cookbooks).each do |cookbook| path = cookbook.path.to_s files = Dir.chdir(path) do Dir.glob(File.join("**", "*.rb")).select do |f| f = File.join(path, f) parent = Pathname.new(path).dirname.to_s f.gsub(parent, "") =~ /[[:space:]]/ end end raise InvalidCookbookFiles.new(cookbook, files) unless files.empty? end end end end end
Version data entries
17 entries across 17 versions & 1 rubygems