Class: Fontist::Repo
- Inherits:
-
Object
- Object
- Fontist::Repo
- Defined in:
- lib/fontist/repo.rb
Class Method Summary collapse
- .info(name) ⇒ Object
- .list ⇒ Object
- .remove(name) ⇒ Object
- .setup(name, url) ⇒ Object
- .update(name) ⇒ Object
Class Method Details
.info(name) ⇒ Object
106 107 108 109 110 111 112 113 |
# 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 ⇒ Object
100 101 102 103 104 |
# 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) ⇒ Object
90 91 92 93 94 95 96 97 98 |
# 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) ⇒ Object
62 63 64 65 66 |
# 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) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# 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.} MSG end |