Class: Mantis::Installer

Inherits:
Object
  • Object
show all
Defined in:
lib/mantis/installer.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.install(options = {}) ⇒ Object

Begins the installation process for Bundler. For more information see the #run method on this class.



8
9
10
11
12
# File 'lib/mantis/installer.rb', line 8

def self.install(options = {})
  installer = new()
  installer.run(options)
  installer
end

Instance Method Details

#run(options) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/mantis/installer.rb', line 14

def run(options)
  config = "Mantisfile"

  unless File.exists?(config)
   puts "No Mantisfile file found!"
   return
  end

  text = File.open(config).read
  text.gsub!(/\r\n?/, "\n")
  text.each_line do |line|

    next if line.strip! == ""

    uri, tag, name = line.split(',')

    if Dir.exists?(name.strip)
      puts "Fetching #{uri.strip} in #{name.strip}"
      g = Git.open(name.strip)
      g.fetch
    else
      puts "Cloning #{uri.strip} to #{name.strip}..."
      g = Git.clone(uri.strip, name.strip)
    end

    g.chdir do
      g.checkout(tag.strip)
      puts "Checking out #{tag.strip}"
    end
  end

end