Module: Freighthop

Defined in:
lib/freighthop.rb,
lib/freighthop/version.rb

Defined Under Namespace

Classes: CLI, Config, VagrantEnv

Constant Summary collapse

VERSION =
"0.6.1"

Class Method Summary collapse

Class Method Details

.app_nameObject



27
28
29
# File 'lib/freighthop.rb', line 27

def app_name
  @app_name ||= host_root.basename.to_s.gsub(/[_ ]/, '-')
end

.box_urlObject



45
46
47
48
49
50
51
# File 'lib/freighthop.rb', line 45

def box_url
  if vmware?
    'http://files.vagrantup.com/precise64_vmware.box'
  else
    'http://files.vagrantup.com/precise64.box'
  end
end

.cpusObject



66
67
68
# File 'lib/freighthop.rb', line 66

def cpus
  Freighthop::Config.fetch('freighthop::cpus', 2)
end

.freighthop_rootObject



23
24
25
# File 'lib/freighthop.rb', line 23

def freighthop_root
  Pathname(File.dirname(__FILE__)).join('..').expand_path
end

.guest_rootObject



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

def guest_root
  Pathname("/srv/#{app_name}")
end

.host_rootObject



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

def host_root
  Pathname.pwd
end

.hostnameObject



31
32
33
# File 'lib/freighthop.rb', line 31

def hostname
  "#{app_name}.vagrant.dev"
end

.mountsObject



53
54
55
56
57
58
59
60
# File 'lib/freighthop.rb', line 53

def mounts
  Freighthop::Config.fetch('freighthop::mounts', []).map do |host, guest|
    [
      File.expand_path(host_root.join(host)),
      File.expand_path(guest_root.join(guest)),
    ]
  end
end

.nfs?Boolean

For now only use NFS on vmware to work around this issue: github.com/phinze/landrush/issues/17

Returns:

  • (Boolean)


37
38
39
40
41
42
43
# File 'lib/freighthop.rb', line 37

def nfs?
  if ENV.key? 'FREIGHTHOP_NFS'
    ['1','true','on'].include?(ENV['FREIGHTHOP_NFS'])
  else
    vmware?
  end
end

.provision_scriptsObject



62
63
64
# File 'lib/freighthop.rb', line 62

def provision_scripts
  Freighthop::Config.fetch('freighthop::provision_scripts', [])
end

.ramObject



70
71
72
# File 'lib/freighthop.rb', line 70

def ram
  Freighthop::Config.fetch('freighthop::ram', 1024)
end

.vmware?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/freighthop.rb', line 11

def vmware?
  !!(defined? HashiCorp)
end