Class: Cejo::Floss::Grab

Inherits:
Object
  • Object
show all
Defined in:
lib/cejo/floss/grab.rb

Overview

Grab FLOSS Projects

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(utils, folder, url, info) ⇒ Grab

Returns a new instance of Grab.



11
12
13
14
15
16
# File 'lib/cejo/floss/grab.rb', line 11

def initialize(utils, folder, url, info)
  @utils = utils
  @folder = folder
  @url = url
  @info = info
end

Instance Attribute Details

#folderObject (readonly)

Returns the value of attribute folder.



9
10
11
# File 'lib/cejo/floss/grab.rb', line 9

def folder
  @folder
end

#infoObject (readonly)

Returns the value of attribute info.



9
10
11
# File 'lib/cejo/floss/grab.rb', line 9

def info
  @info
end

#urlObject (readonly)

Returns the value of attribute url.



9
10
11
# File 'lib/cejo/floss/grab.rb', line 9

def url
  @url
end

#utilsObject (readonly)

Returns the value of attribute utils.



9
10
11
# File 'lib/cejo/floss/grab.rb', line 9

def utils
  @utils
end

Instance Method Details

#do_cloneObject



25
26
27
28
29
# File 'lib/cejo/floss/grab.rb', line 25

def do_clone
  utils.spin('Cloning') do
    Git.clone url, folder
  end
end

#do_pullObject



18
19
20
21
22
23
# File 'lib/cejo/floss/grab.rb', line 18

def do_pull
  utils.spin('Pulling') do
    repo = Git.open folder
    repo.pull 'origin', repo.current_branch
  end
end

#runObject

Cloning/Pulling FLOSS Project



32
33
34
35
36
37
38
39
40
41
# File 'lib/cejo/floss/grab.rb', line 32

def run
  puts info.to_s

  if folder.exist?
    do_pull
  else
    do_clone
  end
  puts
end