Sha256: bc1391890bf9795995c57a70ae285a9c5bc58a582d35ee297a3bacf03a08b51b

Contents?: true

Size: 730 Bytes

Versions: 10

Compression:

Stored size: 730 Bytes

Contents

module Fontist
  class CacheCLI < Thor
    include CLI::ClassOptions

    desc "clear", "Clear fontist cache"
    def clear
      handle_class_options(options)
      dir = Fontist.downloads_path
      dir.each_child(&:rmtree) if dir.exist?
      clear_indexes
      Fontist.ui.success("Cache has been successfully removed.")
      CLI::STATUS_SUCCESS
    end

    private

    def clear_indexes
      delete_file_with_lock(Fontist.system_index_path)
      delete_file_with_lock(Fontist.system_preferred_family_index_path)
    end

    def delete_file_with_lock(path)
      path.delete if path.exist?
      lock_path = Pathname.new Fontist::Utils::Cache.lock_path(path)
      lock_path.delete if lock_path.exist?
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
fontist-1.21.2 lib/fontist/cache_cli.rb
fontist-1.21.1 lib/fontist/cache_cli.rb
fontist-1.20.0 lib/fontist/cache_cli.rb
fontist-1.19.0 lib/fontist/cache_cli.rb
fontist-1.18.2 lib/fontist/cache_cli.rb
fontist-1.17.1 lib/fontist/cache_cli.rb
fontist-1.17.0 lib/fontist/cache_cli.rb
fontist-1.16.0 lib/fontist/cache_cli.rb
fontist-1.15.2 lib/fontist/cache_cli.rb
fontist-1.15.1 lib/fontist/cache_cli.rb