Class: Dply::Repo

Inherits:
Object
  • Object
show all
Defined in:
lib/dply/repo.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dir, upstream, mirror: nil) ⇒ Repo

Returns a new instance of Repo.



7
8
9
10
11
# File 'lib/dply/repo.rb', line 7

def initialize(dir, upstream, mirror: nil)
  @dir = dir
  @upstream = upstream
  @mirror = mirror
end

Instance Attribute Details

#dirObject (readonly)

Returns the value of attribute dir.



5
6
7
# File 'lib/dply/repo.rb', line 5

def dir
  @dir
end

#mirrorObject (readonly)

Returns the value of attribute mirror.



5
6
7
# File 'lib/dply/repo.rb', line 5

def mirror
  @mirror
end

#upstreamObject (readonly)

Returns the value of attribute upstream.



5
6
7
# File 'lib/dply/repo.rb', line 5

def upstream
  @upstream
end

Instance Method Details

#createObject



13
14
15
16
17
18
19
# File 'lib/dply/repo.rb', line 13

def create
  if Dir.exist? "#{dir}/.git"
    raise Error, "unable to create repo (another repo already exists)" if not verify_remote_url
  else
    Git.clone upstream, dir, mirror: @mirror
  end
end