Class: Protobox::Util::Platform

Inherits:
Object
  • Object
show all
Defined in:
lib/protobox/util.rb

Class Method Summary collapse

Class Method Details

.gitObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/protobox/util.rb', line 8

def git
  @git ||= if ENV['GIT'] and File.executable?(ENV['GIT'])
    ENV['GIT']
  elsif Context.command?('git')
    'git'
  else
    s = `xcrun -find git 2>/dev/null`.chomp
    s if $? and not s.empty?
  end

  return unless @git

  # Github only supports HTTPS fetches on 1.7.10 or later:
  # https://help.github.com/articles/https-cloning-errors
  `#{@git} --version` =~ /git version (\d\.\d+\.\d+)/
  return if $1.nil? or $1 < "1.7.10"

  @git
end

.vagrantObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/protobox/util.rb', line 28

def vagrant
  @vagrant ||= if ENV['VAGRANT'] and File.executable(ENV['VAGRANT'])
    ENV['VAGRANT']
  elsif Context.command?('vagrant')
    'vagrant'
  else
    s = `xcrun -find vagrant 2>/dev/null`.chomp
    s if $? and not s.empty?
  end

  return unless @vagrant

  @vagrant
end