Class: Dotstrap::Git
- Inherits:
-
Object
- Object
- Dotstrap::Git
- Defined in:
- lib/dotstrap/git.rb
Overview
TODO: split this into Git < Downloader class
Instance Attribute Summary collapse
-
#repo ⇒ Object
Returns the value of attribute repo.
-
#repo_name ⇒ Object
Returns the value of attribute repo_name.
-
#repo_owner ⇒ Object
Returns the value of attribute repo_owner.
-
#repo_path ⇒ Object
Returns the value of attribute repo_path.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#clone(url = @url, repo_path = @repo_path, repo = @repo) ⇒ Object
FIXME: if user is not logged in to Git the prompt for username/password is mangled because the threads are not synchronized.
-
#initialize(repo, dest_dir = Dotstrap.config_home) ⇒ Git
constructor
A new instance of Git.
- #pull(repo_path = @repo_path, repo = @repo) ⇒ Object
Constructor Details
#initialize(repo, dest_dir = Dotstrap.config_home) ⇒ Git
Returns a new instance of Git.
9 10 11 12 13 14 15 16 |
# File 'lib/dotstrap/git.rb', line 9 def initialize(repo, dest_dir = Dotstrap.config_home) @repo = determine_repo_slug(repo) # TODO: allow an option to specify to download with SSH or HTTPs from Git @url = determine_url(@repo) @repo_owner, @repo_name = split_repo_slug(@repo) @repo_path = File.join(dest_dir, "#{@repo_owner}-#{@repo_name}") # @repo_path = File.join(dest_dir, @github_user, @repo_name) end |
Instance Attribute Details
#repo ⇒ Object
Returns the value of attribute repo.
7 8 9 |
# File 'lib/dotstrap/git.rb', line 7 def repo @repo end |
#repo_name ⇒ Object
Returns the value of attribute repo_name.
7 8 9 |
# File 'lib/dotstrap/git.rb', line 7 def repo_name @repo_name end |
#repo_owner ⇒ Object
Returns the value of attribute repo_owner.
7 8 9 |
# File 'lib/dotstrap/git.rb', line 7 def repo_owner @repo_owner end |
#repo_path ⇒ Object
Returns the value of attribute repo_path.
7 8 9 |
# File 'lib/dotstrap/git.rb', line 7 def repo_path @repo_path end |
#url ⇒ Object
Returns the value of attribute url.
7 8 9 |
# File 'lib/dotstrap/git.rb', line 7 def url @url end |
Instance Method Details
#clone(url = @url, repo_path = @repo_path, repo = @repo) ⇒ Object
FIXME: if user is not logged in to Git the prompt for username/password is mangled because the threads are not synchronized
20 21 22 23 24 25 26 |
# File 'lib/dotstrap/git.rb', line 20 def clone(url = @url, repo_path = @repo_path, repo = @repo) return pull(repo_path) if Dir.exist?(repo_path) return false unless system('git', 'clone', *git_verbosity, url, repo_path) $LOG.debug { "CLONE #{repo} #{url} #{repo_path}" } $LOG.unknown { "#{'=> '.colorize(:blue)}#{repo}\nupdated" } repo_path end |
#pull(repo_path = @repo_path, repo = @repo) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/dotstrap/git.rb', line 28 def pull(repo_path = @repo_path, repo = @repo) Dir.chdir(repo_path) return false unless system('git', 'pull', *git_verbosity, repo_path) $LOG.debug { "PULL #{repo} #{url} #{repo_path}" } $LOG.unknown { "#{'=> '.colorize(:blue)}#{repo}\nupdated" } repo_path end |