Class: Fontist::Repo
- Inherits:
-
Object
- Object
- Fontist::Repo
- Defined in:
- lib/fontist/repo.rb
Class Method Summary collapse
Class Method Details
.list ⇒ Object
44 45 46 47 48 |
# File 'lib/fontist/repo.rb', line 44 def list Dir.glob(Fontist.private_formulas_path.join("*")) .select { |path| File.directory?(path) } .map { |path| File.basename(path) } end |
.remove(name) ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/fontist/repo.rb', line 34 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
6 7 8 9 10 |
# File 'lib/fontist/repo.rb', line 6 def setup(name, url) ensure_private_formulas_path_exists fetch_repo(name, url) Index.rebuild end |
.update(name) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/fontist/repo.rb', line 12 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 |