module Librarian::Chef::ManifestReader
Constants
- MANIFESTS
Public Instance Methods
check_manifest(name, manifest_path)
click to toggle source
# File lib/librarian/chef/manifest_reader.rb, line 40 def check_manifest(name, manifest_path) manifest = read_manifest(name, manifest_path) manifest["name"] == name end
compile_manifest(name, path)
click to toggle source
# File lib/librarian/chef/manifest_reader.rb, line 25 def compile_manifest(name, path) # Inefficient, if there are many cookbooks with uncompiled metadata. require 'chef/json_compat' require 'chef/cookbook/metadata' md = ::Chef::Cookbook::Metadata.new md.name(name) md.from_file(path.join('metadata.rb').to_s) {"name" => md.name, "version" => md.version, "dependencies" => md.dependencies} end
manifest?(name, path)
click to toggle source
# File lib/librarian/chef/manifest_reader.rb, line 35 def manifest?(name, path) path = Pathname.new(path) !!manifest_path(path) end
manifest_path(path)
click to toggle source
# File lib/librarian/chef/manifest_reader.rb, line 13 def manifest_path(path) MANIFESTS.map{|s| path.join(s)}.find{|s| s.exist?} end
read_manifest(name, manifest_path)
click to toggle source
# File lib/librarian/chef/manifest_reader.rb, line 17 def read_manifest(name, manifest_path) case manifest_path.extname when ".json" then JSON.parse(binread(manifest_path)) when ".yml", ".yaml" then YAML.load(binread(manifest_path)) when ".rb" then compile_manifest(name, manifest_path.dirname) end end
Private Instance Methods
binread(path)
click to toggle source
# File lib/librarian/chef/manifest_reader.rb, line 48 def binread(path) File.binread(path) end