diff --git a/lib/vagrant-backports/README.md b/lib/vagrant-backports/README.md new file mode 100644 index 0000000..e458704 --- /dev/null +++ b/lib/vagrant-backports/README.md @@ -0,0 +1,10 @@ +# vagrant-backports + + + +A "soon to be extracted" gem that helps Vagrant plugin developers to stay sane +when keeping up with Vagrant improvements and backwards incompatible changes. + +More information coming out soon... diff --git a/lib/vagrant-backports/utils.rb b/lib/vagrant-backports/utils.rb new file mode 100644 index 0000000..f0de881 --- /dev/null +++ b/lib/vagrant-backports/utils.rb @@ -0,0 +1,9 @@ +module Vagrant + module Backports + class << self + def vagrant_1_3_or_later? + Gem::Version.new(Vagrant::VERSION) >= Gem::Version.new('1.3.0') + end + end + end +end diff --git a/lib/vagrant-lxc/action.rb b/lib/vagrant-lxc/action.rb index 625646c..d0075e4 100644 --- a/lib/vagrant-lxc/action.rb +++ b/lib/vagrant-lxc/action.rb @@ -20,9 +20,8 @@ require 'vagrant-lxc/action/setup_package_files' require 'vagrant-lxc/action/share_folders' require 'vagrant-lxc/action/warn_networks' -unless Vagrant::LXC.vagrant_1_3_or_later - require 'vagrant-lxc/action/wait_for_communicator' - Vagrant::Action::Builtin.const_set :WaitForCommunicator, Vagrant::LXC::Action::WaitForCommunicator +unless Vagrant::Backports.vagrant_1_3_or_later? + require 'vagrant-backports/action/wait_for_communicator' end module Vagrant @@ -157,7 +156,7 @@ module Vagrant b3.use Builtin::EnvSet, :force_halt => true b3.use action_halt b3.use Destroy - if Vagrant::LXC.vagrant_1_3_or_later + if Vagrant::Backports.vagrant_1_3_or_later? b3.use Builtin::ProvisionerCleanup end else diff --git a/lib/vagrant-lxc/plugin.rb b/lib/vagrant-lxc/plugin.rb index 801c927..b2dd7b6 100644 --- a/lib/vagrant-lxc/plugin.rb +++ b/lib/vagrant-lxc/plugin.rb @@ -1,4 +1,5 @@ -require "vagrant" +require 'vagrant' +require 'vagrant-backports/utils' module Vagrant module LXC @@ -23,9 +24,5 @@ module Vagrant Config end end - - def self.vagrant_1_3_or_later - Gem::Version.new(Vagrant::VERSION) >= Gem::Version.new('1.3.0') - end end end