class PackageFacts
Attributes
Public Class Methods
Source
# File lib/lace/package/facts.rb, line 13 def initialize(package_path) @package_path = Pathname.new(package_path) @facts_file = @package_path / '.lace.yml' raise PackageFactsNotFound, @package_path unless @facts_file.exist? @facts = facts_file_to_hash @unflavorable_facts = facts_file_to_hash end
Public Instance Methods
Source
# File lib/lace/package/facts.rb, line 30 def config_files if has_config_files? @facts['config_files'].flatten.map do |path| Pathname.glob(@package_path + path).delete_if do |match| match.directory? and path.include? '*' end end.flatten else [] end end
Source
# File lib/lace/package/facts.rb, line 82 def flavor!(the_flavor) raise PackageFlavorDoesNotExist.new(the_flavor, flavors) unless flavors.include? the_flavor @facts = @unflavorable_facts['flavors'][the_flavor] end
Source
# File lib/lace/package/facts.rb, line 22 def flavor_with(the_flavor) if has_flavors? && the_flavor.nil? raise FlavorArgumentRequired, flavors elsif has_flavors? && the_flavor != false flavor! the_flavor end end
Source
# File lib/lace/package/facts.rb, line 74 def flavors if @unflavorable_facts&.key?('flavors') @unflavorable_facts['flavors'].keys.sort else [] end end
Source
# File lib/lace/package/facts.rb, line 41 def globbed_folder if has_config_files? @facts['config_files'].flatten.select { |f| f.include? '*' } else [] end end
Source
# File lib/lace/package/facts.rb, line 48 def has_config_files? key? 'config_files' end
Source
# File lib/lace/package/facts.rb, line 52 def has_flavors? @unflavorable_facts && !@unflavorable_facts['flavors'].nil? end
Source
# File lib/lace/package/facts.rb, line 70 def homepage @unflavorable_facts['homepage'] if @unflavorable_facts.key? 'homepage' end
Source
# File lib/lace/package/facts.rb, line 9 def inspect "#<Facts:#{@package_path}>" end
Source
# File lib/lace/package/facts.rb, line 56 def key?(key) @unflavorable_facts && (@unflavorable_facts.key?(key) or @facts.key?(key)) end
Source
# File lib/lace/package/facts.rb, line 92 def post(hook_point) if @unflavorable_facts.nil? || !@facts.key?('post') [] else post_hook = @facts['post'] (post_hook[hook_point.to_s] || []).flatten end end
Source
# File lib/lace/package/facts.rb, line 64 def setup_files @facts['setup'].flatten rescue StandardError [] end
Source
# File lib/lace/package/facts.rb, line 88 def unflavor! @facts = @unflavorable_facts end
Source
# File lib/lace/package/facts.rb, line 60 def version @unflavorable_facts['version'] if @unflavorable_facts.key? 'version' end
Protected Instance Methods
Source
# File lib/lace/package/facts.rb, line 103 def facts_file_to_hash begin rendered_manifest = ERB.new(@facts_file.read, trim_mode: '-').result(binding) rescue Exception => e raise ManifestErbError.new(self, e) end value = YAML.safe_load rendered_manifest, aliases: true if value.is_a?(String) && value == '---' {} else value end end