Class: Fontist::Index
- Inherits:
-
Lutaml::Model::Collection
- Object
- Lutaml::Model::Collection
- Fontist::Index
- Defined in:
- lib/fontist/index.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_file(path) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/fontist/index.rb', line 29 def self.from_file(path) return new unless File.exist?(path) content = File.read(path) from_yaml(content) end |
.rebuild ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/fontist/index.rb', line 40 def self.rebuild # Load formulas once and share across all indexes formulas = Formula.all Fontist::Indexes::DefaultFamilyFontIndex.rebuild_with_formulas(formulas).to_file Fontist::Indexes::PreferredFamilyFontIndex.rebuild_with_formulas(formulas).to_file Fontist::Indexes::FilenameIndex.rebuild_with_formulas(formulas).to_file # DO NOT call reset_cache here - it deletes the index files we just created! # reset_cache is called in test cleanup hooks (fresh_home, empty_home, etc.) # to delete old index files between tests end |
.reset_cache ⇒ Object
53 54 55 56 57 |
# File 'lib/fontist/index.rb', line 53 def self.reset_cache Fontist::Indexes::DefaultFamilyFontIndex.reset_cache Fontist::Indexes::PreferredFamilyFontIndex.reset_cache Fontist::Indexes::FilenameIndex.reset_cache end |
Instance Method Details
#to_file(path) ⇒ Object
36 37 38 |
# File 'lib/fontist/index.rb', line 36 def to_file(path) File.write(path, to_yaml) end |