Class: Repository
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#dst ⇒ Object
Returns the value of attribute dst.
-
#remotes ⇒ Object
Returns the value of attribute remotes.
-
#repo ⇒ Object
Returns the value of attribute repo.
-
#repo_uri ⇒ Object
Returns the value of attribute repo_uri.
Instance Method Summary collapse
- #add_remotes ⇒ Object
- #clone ⇒ Object
- #get_abs_path ⇒ Object
- #get_dst(config) ⇒ Object
- #get_remotes(config) ⇒ Object
-
#initialize(uri, config = nil) ⇒ Repository
constructor
TODO: think about better way to handle dst from URI.
Methods included from Logging
configure_logger_for, #logger, logger_for
Constructor Details
#initialize(uri, config = nil) ⇒ Repository
TODO: think about better way to handle dst from URI
8 9 10 11 12 13 14 |
# File 'lib/clenver/repository.rb', line 8 def initialize(uri, config = nil) @repo_uri = uri @dst = get_dst(config) @remotes = get_remotes(config) @abs_path = nil @repo = nil end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
6 7 8 |
# File 'lib/clenver/repository.rb', line 6 def config @config end |
#dst ⇒ Object
Returns the value of attribute dst.
6 7 8 |
# File 'lib/clenver/repository.rb', line 6 def dst @dst end |
#remotes ⇒ Object
Returns the value of attribute remotes.
6 7 8 |
# File 'lib/clenver/repository.rb', line 6 def remotes @remotes end |
#repo ⇒ Object
Returns the value of attribute repo.
6 7 8 |
# File 'lib/clenver/repository.rb', line 6 def repo @repo end |
#repo_uri ⇒ Object
Returns the value of attribute repo_uri.
6 7 8 |
# File 'lib/clenver/repository.rb', line 6 def repo_uri @repo_uri end |
Instance Method Details
#add_remotes ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/clenver/repository.rb', line 43 def add_remotes logger.debug("self.inspect:#{self.inspect}") unless remotes.nil? for name, uri in remotes do Git.open(dst).add_remote(name, uri) end end end |
#clone ⇒ Object
34 35 36 37 |
# File 'lib/clenver/repository.rb', line 34 def clone repo = Git.clone(repo_uri, dst) logger.debug("clone:#{repo}") end |
#get_abs_path ⇒ Object
39 40 41 |
# File 'lib/clenver/repository.rb', line 39 def get_abs_path @abs_path end |
#get_dst(config) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/clenver/repository.rb', line 24 def get_dst(config) unless config.nil? if config.has_key?('dst') return config['dst'][0] end end logger.debug("dst:#{Dir::pwd + "/" + File.basename(repo_uri, '.git')}") Dir::pwd + "/" + File.basename(repo_uri, '.git') end |
#get_remotes(config) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/clenver/repository.rb', line 16 def get_remotes(config) unless config.nil? if config.has_key?('remotes') config['remotes'] end end end |