lib/fontist/import/formula_builder.rb in fontist-1.11.7 vs lib/fontist/import/formula_builder.rb in fontist-1.12.0

- old
+ new

@@ -2,40 +2,45 @@ require_relative "text_helper" module Fontist module Import class FormulaBuilder - FORMULA_ATTRIBUTES = %i[name description homepage resources + FORMULA_ATTRIBUTES = %i[description homepage resources font_collections fonts extract copyright license_url open_license digest command].freeze - attr_accessor :archive, - :url, - :extractor, - :options, - :font_files, - :font_collection_files, - :license_text + attr_writer :archive, + :url, + :extractor, + :options, + :font_files, + :font_collection_files, + :license_text, + :homepage def initialize @options = {} end def formula - FORMULA_ATTRIBUTES.map { |name| [name, send(name)] }.to_h.compact + formula_attributes.map { |name| [name, send(name)] }.to_h.compact end - private - def name - return options[:name] if options[:name] + return @options[:name] if @options[:name] unique_names = both_fonts.map(&:family_name).uniq TextHelper.longest_common_prefix(unique_names) || both_fonts.first.family_name end + private + + def formula_attributes + FORMULA_ATTRIBUTES + end + def both_fonts @both_fonts ||= group_fonts end def group_fonts @@ -48,10 +53,10 @@ def description name end def homepage - both_fonts.map(&:homepage).compact.first + @options[:homepage] || both_fonts.map(&:homepage).compact.first end def resources filename = name.gsub(" ", "_") + "." + @extractor.extension