Module: Fontist::Indexes::IndexMixin::ClassMethods

Defined in:
lib/fontist/indexes/index_mixin.rb

Instance Method Summary collapse

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

#rebuildObject



26
27
28
29
# File 'lib/fontist/indexes/index_mixin.rb', line 26

def rebuild
  # puts "Rebuilding index..."
  new.build
end