class Fontist::Repo

Public Class Methods

info(name) click to toggle source
# File lib/fontist/repo.rb, line 106
def info(name)
  path = Pathname.new repo_path(name)
  unless path.exist?
    raise(Errors::RepoNotFoundError, "No such repo '#{name}'.")
  end

  Info.new(name, path)
end
list() click to toggle source
# File lib/fontist/repo.rb, line 100
def list
  Dir.glob(Fontist.private_formulas_path.join("*"))
    .select { |path| File.directory?(path) }
    .map { |path| File.basename(path) }
end
remove(name) click to toggle source
# File lib/fontist/repo.rb, line 90
def remove(name)
  path = repo_path(name)
  unless Dir.exist?(path)
    raise(Errors::RepoNotFoundError, "No such repo '#{name}'.")
  end

  FileUtils.rm_r(path)
  Index.rebuild
end
setup(name, url) click to toggle source
# File lib/fontist/repo.rb, line 62
def setup(name, url)
  ensure_private_formulas_path_exists
  fetch_repo(name, url)
  Index.rebuild
end
update(name) click to toggle source
# File lib/fontist/repo.rb, line 68
      def update(name)
        path = repo_path(name)
        unless Dir.exist?(path)
          raise(Errors::RepoNotFoundError, "No such repo '#{name}'.")
        end

        git = Git.open(path)
        git.pull("origin", git.current_branch)

        Index.rebuild
      rescue Git::GitExecuteError => e
        raise Errors::RepoCouldNotBeUpdatedError.new(<<~MSG.chomp)
          Formulas repo '#{name}' could not be updated.
          Please consider reinitializing it with:
            fontist remove #{name}
            fontist setup #{name} REPO_URL

          Git error:
          #{e.message}
        MSG
      end