Class: Gitload::Repo

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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_dataObject

Returns the value of attribute api_data.



6
7
8
# File 'lib/gitload/repo.rb', line 6

def api_data
  @api_data
end

#clone_urlsObject (readonly)

Returns the value of attribute clone_urls.



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

def clone_urls
  @clone_urls
end

#clonedObject

Returns the value of attribute cloned.



6
7
8
# File 'lib/gitload/repo.rb', line 6

def cloned
  @cloned
end

#forkObject

Returns the value of attribute fork.



6
7
8
# File 'lib/gitload/repo.rb', line 6

def fork
  @fork
end

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/gitload/repo.rb', line 6

def name
  @name
end

#ownerObject

Returns the value of attribute owner.



6
7
8
# File 'lib/gitload/repo.rb', line 6

def owner
  @owner
end

#owner_typeObject

Returns the value of attribute owner_type.



6
7
8
# File 'lib/gitload/repo.rb', line 6

def owner_type
  @owner_type
end

#sourceObject

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, options = {}
  if @cloned && !options[:force]
    return
  elsif File.exists? dest
    @cloned = true
    CommandLine.print "#{dest} already exists", color: :green
    return
  end

  command = [ :git, :clone, clone_url(options[:clone_url_type]), dest ]

  if options[: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

Returns:

  • (Boolean)


15
16
17
# File 'lib/gitload/repo.rb', line 15

def cloned?
  !!@cloned
end

#fork?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/gitload/repo.rb', line 19

def fork?
  !!@fork
end