class Fontist::Manifest
Manifest class for managing font manifests.
Public Class Methods
Source
# File lib/fontist/manifest.rb, line 75 def self.from_file(path, locations: false) Fontist.ui.debug("Manifest: #{path}") unless File.exist?(path) raise Fontist::Errors::ManifestCouldNotBeFoundError, "Manifest file not found: #{path}" end file_content = File.read(path).strip if file_content.empty? raise Fontist::Errors::ManifestCouldNotBeReadError, "Manifest file is empty: #{path}" end manifest_model = begin from_yaml(file_content) rescue StandardError => e raise Fontist::Errors::ManifestCouldNotBeReadError, "Manifest file could not be read: #{e.message}" end manifest_model.to_response(locations: locations) end
Source
# File lib/fontist/manifest.rb, line 100 def self.from_hash(data, options = {}) locations = options.delete(:locations) || false model = super(data, options) model.to_response(locations: locations) end
              Calls superclass method
              
            
        Public Instance Methods
Source
# File lib/fontist/manifest.rb, line 112 def fonts_casted Array(fonts).map do |font| self.class.font_class === font ? font : self.class.font_class.new(font.to_h) end end
Source
# File lib/fontist/manifest.rb, line 118 def install(confirmation: "no", hide_licenses: false, no_progress: false) fonts_casted.each do |font| paths = font.group_paths if paths.length < fonts_casted.length font.install(confirmation: confirmation, hide_licenses: hide_licenses, no_progress: no_progress) end end to_response end
Source
# File lib/fontist/manifest.rb, line 139 def to_file(path) FileUtils.mkdir_p(File.dirname(path)) File.write(path, to_yaml) end
Source
# File lib/fontist/manifest.rb, line 129 def to_response(locations: false) return self if fonts_casted.any?(&:group_paths_empty?) && !locations ManifestResponse.new.tap do |response| response.fonts = fonts_casted.map do |font| font.to_response(locations: locations) end end end