lib/freighthop.rb in freighthop-0.0.2 vs lib/freighthop.rb in freighthop-0.0.3
- old
+ new
@@ -1,7 +1,8 @@
require 'pathname'
require_relative 'freighthop/version'
+require_relative 'freighthop/config'
unless defined? Vagrant
raise "i expect to be required from a Vagrantfile"
end
@@ -9,22 +10,16 @@
class << self
def vmware?
!!(defined? HashiCorp)
end
- def host_rails_root
- @rails_root ||= begin
- Pathname.pwd.tap do |pwd|
- unless pwd.join('config', 'boot.rb').file?
- raise 'run me with a rails app as PWD, using VAGRANT_CWD to refer to my directory'
- end
- end
- end
+ def host_root
+ Pathname.pwd
end
- def guest_rails_root
- "/srv/#{app_name}"
+ def guest_root
+ Pathname("/srv/#{app_name}")
end
def app_name
@app_name ||= host_rails_root.basename.to_s
end
@@ -40,9 +35,18 @@
def box_url
if vmware?
'http://files.vagrantup.com/precise64_vmware.box'
else
'http://files.vagrantup.com/precise64.box'
+ end
+ end
+
+ def mounts
+ Freighthop::Config.fetch("freighthop::mounts").map do |host, guest|
+ [
+ File.expand_path(host_rails_root.join(host)),
+ File.expand_path(guest_rails_root.join(guest)),
+ ]
end
end
end
end