Module: Fontist::Indexes::IndexMixin::ClassMethods
- Defined in:
- lib/fontist/indexes/index_mixin.rb
Instance Method Summary collapse
- #from_file(file_path = path) ⇒ Object
- #rebuild ⇒ Object
- #rebuild_with_formulas(formulas) ⇒ Object
- #reset_cache ⇒ Object
Instance Method Details
#from_file(file_path = path) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/fontist/indexes/index_mixin.rb', line 9 def from_file(file_path = path) Fontist.ui.debug("Index: #{file_path}") Fontist.formulas_repo_path_exists! rebuild unless File.exist?(file_path) file_content = File.read(file_path).strip if file_content.empty? raise Fontist::Errors::FontIndexCorrupted, "Index file is empty: #{file_path}" end from_yaml(file_content) end |
#rebuild ⇒ Object
26 27 28 29 |
# File 'lib/fontist/indexes/index_mixin.rb', line 26 def rebuild # puts "Rebuilding index..." new.build end |
#rebuild_with_formulas(formulas) ⇒ Object
31 32 33 |
# File 'lib/fontist/indexes/index_mixin.rb', line 31 def rebuild_with_formulas(formulas) new.build_with_formulas(formulas) end |
#reset_cache ⇒ Object
35 36 37 38 39 |
# File 'lib/fontist/indexes/index_mixin.rb', line 35 def reset_cache # Delete the index file to force rebuild on next access # This is important for tests to ensure clean state File.delete(path) if File.exist?(path) end |