Class: Fontist::Import::FormulaBuilder
- Inherits:
-
Object
- Object
- Fontist::Import::FormulaBuilder
- Defined in:
- lib/fontist/import/formula_builder.rb
Direct Known Subclasses
Constant Summary collapse
- FORMULA_ATTRIBUTES =
%i[name platforms description homepage resources font_collections fonts extract copyright license_url requires_license_agreement open_license digest command import_source font_version].freeze
Instance Attribute Summary collapse
-
#error_collector ⇒ Object
writeonly
Sets the attribute error_collector.
-
#font_collection_files ⇒ Object
writeonly
Sets the attribute font_collection_files.
-
#font_files ⇒ Object
writeonly
Sets the attribute font_files.
- #font_version ⇒ Object
- #import_source ⇒ Object
-
#license_text ⇒ Object
writeonly
Sets the attribute license_text.
-
#operations ⇒ Object
writeonly
Sets the attribute operations.
-
#options ⇒ Object
writeonly
Sets the attribute options.
-
#resources ⇒ Object
writeonly
Sets the attribute resources.
Instance Method Summary collapse
- #formula ⇒ Object
-
#initialize ⇒ FormulaBuilder
constructor
A new instance of FormulaBuilder.
- #save ⇒ Object
-
#set_google_import_source(commit_id:, api_version:, last_modified:, family_id:) ⇒ Object
Convenience method to set Google import source.
-
#set_macos_import_source(framework_version:, posted_date:, asset_id:) ⇒ Object
Convenience method to set macOS import source.
-
#set_sil_import_source(version:, release_date:) ⇒ Object
Convenience method to set SIL import source.
Constructor Details
#initialize ⇒ FormulaBuilder
Returns a new instance of FormulaBuilder.
28 29 30 31 32 |
# File 'lib/fontist/import/formula_builder.rb', line 28 def initialize @options = {} @font_files = [] @font_collection_files = [] end |
Instance Attribute Details
#error_collector=(value) ⇒ Object (writeonly)
Sets the attribute error_collector
18 19 20 |
# File 'lib/fontist/import/formula_builder.rb', line 18 def error_collector=(value) @error_collector = value end |
#font_collection_files=(value) ⇒ Object (writeonly)
Sets the attribute font_collection_files
18 19 20 |
# File 'lib/fontist/import/formula_builder.rb', line 18 def font_collection_files=(value) @font_collection_files = value end |
#font_files=(value) ⇒ Object (writeonly)
Sets the attribute font_files
18 19 20 |
# File 'lib/fontist/import/formula_builder.rb', line 18 def font_files=(value) @font_files = value end |
#font_version ⇒ Object
55 56 57 |
# File 'lib/fontist/import/formula_builder.rb', line 55 def font_version @font_version end |
#import_source ⇒ Object
51 52 53 |
# File 'lib/fontist/import/formula_builder.rb', line 51 def import_source @import_source end |
#license_text=(value) ⇒ Object (writeonly)
Sets the attribute license_text
18 19 20 |
# File 'lib/fontist/import/formula_builder.rb', line 18 def license_text=(value) @license_text = value end |
#operations=(value) ⇒ Object (writeonly)
Sets the attribute operations
18 19 20 |
# File 'lib/fontist/import/formula_builder.rb', line 18 def operations=(value) @operations = value end |
#options=(value) ⇒ Object (writeonly)
Sets the attribute options
18 19 20 |
# File 'lib/fontist/import/formula_builder.rb', line 18 def (value) @options = value end |
#resources=(value) ⇒ Object
Sets the attribute resources
18 19 20 |
# File 'lib/fontist/import/formula_builder.rb', line 18 def resources=(value) @resources = value end |
Instance Method Details
#formula ⇒ Object
34 35 36 |
# File 'lib/fontist/import/formula_builder.rb', line 34 def formula formula_attributes.to_h { |name| [name, send(name)] }.compact end |
#save ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/fontist/import/formula_builder.rb', line 38 def save path = path_from_name # Honor keep_existing option - don't overwrite if file exists and keep_existing is true if @options[:keep_existing] && File.exist?(path) return path end yaml = YAML.dump(Helpers::HashHelper.stringify_keys(formula)) File.write(path, yaml) path end |
#set_google_import_source(commit_id:, api_version:, last_modified:, family_id:) ⇒ Object
Convenience method to set Google import source
70 71 72 73 74 75 76 77 78 79 |
# File 'lib/fontist/import/formula_builder.rb', line 70 def set_google_import_source(commit_id:, api_version:, last_modified:, family_id:) @import_source = GoogleImportSource.new( type: "google", commit_id: commit_id, api_version: api_version, last_modified: last_modified, family_id: family_id, ) end |
#set_macos_import_source(framework_version:, posted_date:, asset_id:) ⇒ Object
Convenience method to set macOS import source
60 61 62 63 64 65 66 67 |
# File 'lib/fontist/import/formula_builder.rb', line 60 def set_macos_import_source(framework_version:, posted_date:, asset_id:) @import_source = MacosImportSource.new( type: "macos", framework_version: framework_version, posted_date: posted_date, asset_id: asset_id, ) end |
#set_sil_import_source(version:, release_date:) ⇒ Object
Convenience method to set SIL import source
82 83 84 85 86 87 88 |
# File 'lib/fontist/import/formula_builder.rb', line 82 def set_sil_import_source(version:, release_date:) @import_source = SilImportSource.new( type: "sil", version: version, release_date: release_date, ) end |