Class: Gitload::Repo
- Inherits:
-
Object
- Object
- Gitload::Repo
- Defined in:
- lib/gitload/repo.rb
Direct Known Subclasses
Sources::Bitbucket::Repo, Sources::GitHub::Repo, Sources::GitLab::Repo
Instance Attribute Summary collapse
-
#api_data ⇒ Object
Returns the value of attribute api_data.
-
#clone_urls ⇒ Object
readonly
Returns the value of attribute clone_urls.
-
#cloned ⇒ Object
Returns the value of attribute cloned.
-
#fork ⇒ Object
Returns the value of attribute fork.
-
#name ⇒ Object
Returns the value of attribute name.
-
#owner ⇒ Object
Returns the value of attribute owner.
-
#owner_type ⇒ Object
Returns the value of attribute owner_type.
-
#source ⇒ Object
Returns the value of attribute source.
Instance Method Summary collapse
- #clone_to(dest, options = {}) ⇒ Object
- #clone_url(type = nil) ⇒ Object
- #cloned? ⇒ Boolean
- #fork? ⇒ Boolean
-
#initialize(source, api_data) ⇒ Repo
constructor
A new instance of Repo.
Constructor Details
#initialize(source, api_data) ⇒ Repo
Returns a new instance of Repo.
8 9 10 11 12 13 |
# File 'lib/gitload/repo.rb', line 8 def initialize source, api_data @source = source @api_data = api_data @cloned = false @clone_urls = {} end |
Instance Attribute Details
#api_data ⇒ Object
Returns the value of attribute api_data.
6 7 8 |
# File 'lib/gitload/repo.rb', line 6 def api_data @api_data end |
#clone_urls ⇒ Object (readonly)
Returns the value of attribute clone_urls.
5 6 7 |
# File 'lib/gitload/repo.rb', line 5 def clone_urls @clone_urls end |
#cloned ⇒ Object
Returns the value of attribute cloned.
6 7 8 |
# File 'lib/gitload/repo.rb', line 6 def cloned @cloned end |
#fork ⇒ Object
Returns the value of attribute fork.
6 7 8 |
# File 'lib/gitload/repo.rb', line 6 def fork @fork end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/gitload/repo.rb', line 6 def name @name end |
#owner ⇒ Object
Returns the value of attribute owner.
6 7 8 |
# File 'lib/gitload/repo.rb', line 6 def owner @owner end |
#owner_type ⇒ Object
Returns the value of attribute owner_type.
6 7 8 |
# File 'lib/gitload/repo.rb', line 6 def owner_type @owner_type end |
#source ⇒ Object
Returns the value of attribute source.
6 7 8 |
# File 'lib/gitload/repo.rb', line 6 def source @source end |
Instance Method Details
#clone_to(dest, options = {}) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/gitload/repo.rb', line 27 def clone_to dest, = {} if @cloned && ![:force] return elsif File.exists? dest @cloned = true CommandLine.print "#{dest} already exists", color: :green return end command = [ :git, :clone, clone_url([:clone_url_type]), dest ] if [:dry_run] CommandLine.print CommandLine.escape(command), color: :yellow else CommandLine.execute command end @cloned = true end |
#clone_url(type = nil) ⇒ Object
23 24 25 |
# File 'lib/gitload/repo.rb', line 23 def clone_url type = nil @clone_urls[type || :http] end |
#cloned? ⇒ Boolean
15 16 17 |
# File 'lib/gitload/repo.rb', line 15 def cloned? !!@cloned end |
#fork? ⇒ Boolean
19 20 21 |
# File 'lib/gitload/repo.rb', line 19 def fork? !!@fork end |