Sha256: 3cc3ef1332de7d0b7dc7d1cad8f5df5896229c8e2771e0955e5b8edf149036ed

Contents?: true

Size: 1.13 KB

Versions: 4

Compression:

Stored size: 1.13 KB

Contents

require_relative "indexes/font_index"
require_relative "indexes/filename_index"

module Fontist
  class Index
    def self.rebuild_for_main_repo
      unless Dir.exist?(Fontist.private_formulas_path)
        return do_rebuild_for_main_repo_with
      end

      Dir.mktmpdir do |dir|
        tmp_private_path = File.join(dir, "private")
        FileUtils.mv(Fontist.private_formulas_path, tmp_private_path)

        do_rebuild_for_main_repo_with

        FileUtils.mv(tmp_private_path, Fontist.private_formulas_path)
      end
    end

    def self.do_rebuild_for_main_repo_with
      Fontist.formula_index_path = Fontist.formulas_repo_path.join("index.yml")
      Fontist.formula_filename_index_path =
        Fontist.formulas_repo_path.join("filename_index.yml")

      rebuild

      Fontist.formula_index_path = nil
      Fontist.formula_filename_index_path = nil
    end

    def self.rebuild
      Fontist::Indexes::FontIndex.rebuild
      Fontist::Indexes::FilenameIndex.rebuild

      reset_cache
    end

    def self.reset_cache
      Fontist::Indexes::FontIndex.reset_cache
      Fontist::Indexes::FilenameIndex.reset_cache
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fontist-1.9.3 lib/fontist/index.rb
fontist-1.9.2 lib/fontist/index.rb
fontist-1.9.1 lib/fontist/index.rb
fontist-1.9.0 lib/fontist/index.rb