class PackageFacts
Attributes
facts_file[R]
Public Class Methods
new(package_path)
click to toggle source
# File lib/lace/package/facts.rb, line 11 def initialize package_path @package_path = Pathname.new(package_path) @facts_file = @package_path/".lace.yml" raise PackageFactsNotFound.new(@package_path) unless @facts_file.exist? @facts = facts_file_to_hash @unflavorable_facts = facts_file_to_hash end
Public Instance Methods
config_files()
click to toggle source
# File lib/lace/package/facts.rb, line 27 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
flavor!(the_flavor)
click to toggle source
# File lib/lace/package/facts.rb, line 69 def flavor! the_flavor raise PackageFlavorDoesNotExist.new(the_flavor, flavors) unless flavors.include? the_flavor @facts = @unflavorable_facts["flavors"][the_flavor] end
flavor_with(the_flavor)
click to toggle source
# File lib/lace/package/facts.rb, line 19 def flavor_with the_flavor if has_flavors? && the_flavor.nil? raise FlavorArgumentRequired.new flavors elsif has_flavors? && the_flavor != false flavor! the_flavor end end
flavors()
click to toggle source
# File lib/lace/package/facts.rb, line 61 def flavors if @unflavorable_facts && @unflavorable_facts.key?("flavors") @unflavorable_facts["flavors"].keys.sort else [] end end
has_config_files?()
click to toggle source
# File lib/lace/package/facts.rb, line 37 def has_config_files? has_key? 'config_files' end
has_flavors?()
click to toggle source
# File lib/lace/package/facts.rb, line 41 def has_flavors? @unflavorable_facts && !@unflavorable_facts["flavors"].nil? end
has_key?(key)
click to toggle source
# File lib/lace/package/facts.rb, line 45 def has_key? key @unflavorable_facts && ( @unflavorable_facts.has_key?(key) or @facts.has_key?(key)) end
homepage()
click to toggle source
# File lib/lace/package/facts.rb, line 57 def homepage @unflavorable_facts["homepage"] if @unflavorable_facts.key? "homepage" end
inspect()
click to toggle source
# File lib/lace/package/facts.rb, line 7 def inspect "#<Facts:#{@package_path}>" end
post(hook_point)
click to toggle source
# File lib/lace/package/facts.rb, line 78 def post hook_point if @unflavorable_facts.nil? or !@facts.key? "post" [] else post_hook = @facts["post"] (post_hook[hook_point.to_s] || []).flatten end end
setup_files()
click to toggle source
# File lib/lace/package/facts.rb, line 53 def setup_files @facts["setup"].flatten rescue [] end
unflavor!()
click to toggle source
# File lib/lace/package/facts.rb, line 74 def unflavor! @facts = @unflavorable_facts end
version()
click to toggle source
# File lib/lace/package/facts.rb, line 49 def version @unflavorable_facts["version"] if @unflavorable_facts.key? "version" end
Protected Instance Methods
facts_file_to_hash()
click to toggle source
# File lib/lace/package/facts.rb, line 88 def facts_file_to_hash begin rendered_manifest = ERB.new(@facts_file.read, nil, '-').result(binding) rescue Exception => e raise ManifestErbError.new(self, e) end value = YAML.load rendered_manifest if value.is_a?(String) && value == "---" return Hash.new else value end end