Class: Fontist::Import::Google::DataSources::Github
- Inherits:
-
Object
- Object
- Fontist::Import::Google::DataSources::Github
- Defined in:
- lib/fontist/import/google/data_sources/github.rb
Overview
Data source for fetching font data from Google Fonts GitHub repository
This data source reads font metadata from a local clone of the Google Fonts repository, parsing METADATA.pb files and extracting information from font files using otfinfo.
Instance Attribute Summary collapse
-
#source_path ⇒ Object
readonly
Returns the value of attribute source_path.
Instance Method Summary collapse
-
#clear_cache ⇒ nil
Clear the internal cache.
-
#fetch ⇒ Array<FontFamily>
Fetch and parse all font families from the repository.
-
#fetch_family(name) ⇒ FontFamily?
Fetch a specific font family by name.
-
#initialize(source_path:) ⇒ Github
constructor
Initialize a new GitHub data source.
Constructor Details
#initialize(source_path:) ⇒ Github
Initialize a new GitHub data source
19 20 21 22 23 |
# File 'lib/fontist/import/google/data_sources/github.rb', line 19 def initialize(source_path:) @source_path = Pathname.new(source_path) @cache = nil validate_source_path! end |
Instance Attribute Details
#source_path ⇒ Object (readonly)
Returns the value of attribute source_path.
14 15 16 |
# File 'lib/fontist/import/google/data_sources/github.rb', line 14 def source_path @source_path end |
Instance Method Details
#clear_cache ⇒ nil
Clear the internal cache
48 49 50 |
# File 'lib/fontist/import/google/data_sources/github.rb', line 48 def clear_cache @cache = nil end |
#fetch ⇒ Array<FontFamily>
Fetch and parse all font families from the repository
28 29 30 31 32 |
# File 'lib/fontist/import/google/data_sources/github.rb', line 28 def fetch return @cache if @cache @cache = parse_all_fonts end |
#fetch_family(name) ⇒ FontFamily?
Fetch a specific font family by name
38 39 40 41 42 43 |
# File 'lib/fontist/import/google/data_sources/github.rb', line 38 def fetch_family(name) family_path = find_family_path(name) return nil unless family_path parse_family(family_path) end |