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[schema_version 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
- #schema_version ⇒ 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.
22 23 24 25 26 |
# File 'lib/fontist/import/formula_builder.rb', line 22 def initialize @options = {} @font_files = [] @font_collection_files = [] end |
Instance Attribute Details
#error_collector=(value) ⇒ Object (writeonly)
Sets the attribute error_collector
12 13 14 |
# File 'lib/fontist/import/formula_builder.rb', line 12 def error_collector=(value) @error_collector = value end |
#font_collection_files=(value) ⇒ Object (writeonly)
Sets the attribute font_collection_files
12 13 14 |
# File 'lib/fontist/import/formula_builder.rb', line 12 def font_collection_files=(value) @font_collection_files = value end |
#font_files=(value) ⇒ Object (writeonly)
Sets the attribute font_files
12 13 14 |
# File 'lib/fontist/import/formula_builder.rb', line 12 def font_files=(value) @font_files = value end |
#font_version ⇒ Object
53 54 55 |
# File 'lib/fontist/import/formula_builder.rb', line 53 def font_version @font_version end |
#import_source ⇒ Object
49 50 51 |
# File 'lib/fontist/import/formula_builder.rb', line 49 def import_source @import_source end |
#license_text=(value) ⇒ Object (writeonly)
Sets the attribute license_text
12 13 14 |
# File 'lib/fontist/import/formula_builder.rb', line 12 def license_text=(value) @license_text = value end |
#operations=(value) ⇒ Object (writeonly)
Sets the attribute operations
12 13 14 |
# File 'lib/fontist/import/formula_builder.rb', line 12 def operations=(value) @operations = value end |
#options=(value) ⇒ Object (writeonly)
Sets the attribute options
12 13 14 |
# File 'lib/fontist/import/formula_builder.rb', line 12 def (value) @options = value end |
#resources=(value) ⇒ Object
Sets the attribute resources
12 13 14 |
# File 'lib/fontist/import/formula_builder.rb', line 12 def resources=(value) @resources = value end |
Instance Method Details
#formula ⇒ Object
28 29 30 |
# File 'lib/fontist/import/formula_builder.rb', line 28 def formula formula_attributes.to_h { |name| [name, send(name)] }.compact end |
#save ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/fontist/import/formula_builder.rb', line 32 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 |
#schema_version ⇒ Object
45 46 47 |
# File 'lib/fontist/import/formula_builder.rb', line 45 def schema_version @options[:schema_version] || 4 end |
#set_google_import_source(commit_id:, api_version:, last_modified:, family_id:) ⇒ Object
Convenience method to set Google import source
68 69 70 71 72 73 74 75 76 77 |
# File 'lib/fontist/import/formula_builder.rb', line 68 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
58 59 60 61 62 63 64 65 |
# File 'lib/fontist/import/formula_builder.rb', line 58 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
80 81 82 83 84 85 86 |
# File 'lib/fontist/import/formula_builder.rb', line 80 def set_sil_import_source(version:, release_date:) @import_source = SilImportSource.new( type: "sil", version: version, release_date: release_date, ) end |