Module: Bcpm::Update

Defined in:
lib/bcpm/update.rb

Overview

Bcpm updating code.

Class Method Summary collapse

Class Method Details

.default_repo_uriObject

Git URI to the bcpm repository.



33
34
35
# File 'lib/bcpm/update.rb', line 33

def self.default_repo_uri
  '[email protected]:six370/bcpm.git'
end

.repo_uriObject

Git URI to the bcpm repository.



28
29
30
# File 'lib/bcpm/update.rb', line 28

def self.repo_uri
  Bcpm::Config[:bcpm_repo_uri] ||= default_repo_uri
end

.tempdirObject

Temporary directory name.



22
23
24
25
# File 'lib/bcpm/update.rb', line 22

def self.tempdir
  File.join Dir.tmpdir, 'bcpm',
      "update_#{Socket.hostname}_#{(Time.now.to_f * 1000).to_i}_#{$PID}"
end

.upgrade(branch = 'master') ⇒ Object

Updates bcpm to the latest version.



10
11
12
13
14
15
16
17
18
19
# File 'lib/bcpm/update.rb', line 10

def self.upgrade(branch = 'master')
  source_path = tempdir
  return false unless Bcpm::Git.clone_repo(repo_uri, 'master', source_path)    
  success = nil
  Dir.chdir source_path do
    success = Kernel.system 'rake', 'install'
  end
  FileUtils.rm_r source_path
  success
end