From f65ad4c8542019e5a1c902f97d257a798714d6ee Mon Sep 17 00:00:00 2001 From: Chris Smith Date: Sat, 7 Nov 2015 21:00:22 -0600 Subject: [PATCH] Adding skipping note if configuration is set for it - Setting updatehost to hook in after - Updates to gem file --- Gemfile | 20 +++++++------------- lib/vagrant-hostsupdater/HostsUpdater.rb | 3 +++ lib/vagrant-hostsupdater/plugin.rb | 2 +- vagrant-hostsupdater.gemspec | 18 +++++++++--------- 4 files changed, 20 insertions(+), 23 deletions(-) diff --git a/Gemfile b/Gemfile index f7ddfd7..992a84e 100644 --- a/Gemfile +++ b/Gemfile @@ -1,15 +1,9 @@ -$:.unshift File.expand_path("../lib", __FILE__) - -Gem::Specification.new do |s| - s.name = "vagrant-hostsupdater" - s.version = '1.0.0' - s.license = 'MIT' - s.platform = Gem::Platform::RUBY - s.authors = ["Falk Kühnel", "Chris Smith"] - s.email = ["fk@cogitatio.de", "chris@cgsmith.net"] - s.homepage = "https://github.com/cogitatio/vagrant-hostsupdater" - s.summary = "Enables Vagrant to update hosts file on the host machine" - s.description = "Enables Vagrant to update hosts file on the host machine" - +source 'https://rubygems.org' +group :development do + gem 'vagrant', :git => 'git://github.com/mitchellh/vagrant.git', :tag => 'v1.6.2' end + +group :plugins do + gemspec +end \ No newline at end of file diff --git a/lib/vagrant-hostsupdater/HostsUpdater.rb b/lib/vagrant-hostsupdater/HostsUpdater.rb index 940dadb..53a858f 100644 --- a/lib/vagrant-hostsupdater/HostsUpdater.rb +++ b/lib/vagrant-hostsupdater/HostsUpdater.rb @@ -9,6 +9,9 @@ def getIps key, options = network[0], network[1] ip = options[:ip] if (key == :private_network || key == :public_network) && options[:hostsupdater] != "skip" ips.push(ip) if ip + if options[:hostsupdater] == 'skip' + @ui.info 'Skipping adding host entries (config.vm.network hostsupdater: "skip" is set)' + end end return ips end diff --git a/lib/vagrant-hostsupdater/plugin.rb b/lib/vagrant-hostsupdater/plugin.rb index c8a61ef..428d647 100644 --- a/lib/vagrant-hostsupdater/plugin.rb +++ b/lib/vagrant-hostsupdater/plugin.rb @@ -18,7 +18,7 @@ class Plugin < Vagrant.plugin('2') action_hook(:hostsupdater, :machine_action_up) do |hook| hook.prepend(Action::RemoveHosts) - hook.prepend(Action::UpdateHosts) + hook.after(Action::RemoveHosts, Action::UpdateHosts) end action_hook(:hostsupdater, :machine_action_provision) do |hook| diff --git a/vagrant-hostsupdater.gemspec b/vagrant-hostsupdater.gemspec index 84d1696..0825302 100644 --- a/vagrant-hostsupdater.gemspec +++ b/vagrant-hostsupdater.gemspec @@ -4,20 +4,20 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'vagrant-hostsupdater/version' Gem::Specification.new do |spec| - spec.name = "vagrant-hostsupdater" + spec.name = 'vagrant-hostsupdater' spec.version = VagrantPlugins::HostsUpdater::VERSION - spec.authors = ["Falk Kühnel"] - spec.email = ["fk@cogitatio.de"] + spec.authors = ['Falk Kühnel', 'Chris Smith'] + spec.email = ['fk@cogitatio.de', 'chris@cgsmith.net'] spec.description = %q{Enables Vagrant to update hosts file on the host machine} - spec.summary = %q{Enables Vagrant to update hosts file on the host machine} - spec.homepage = "https://github.com/cogitatio/vagrant-hostsupdater" - spec.license = "MIT" + spec.summary = spec.description + spec.homepage = 'https://github.com/cogitatio/vagrant-hostsupdater' + spec.license = 'MIT' spec.files = `git ls-files`.split($/) spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) - spec.require_paths = ["lib"] + spec.require_paths = ['lib'] - spec.add_development_dependency "bundler", "~> 1.3" - spec.add_development_dependency "rake" + spec.add_development_dependency 'bundler', '~> 1.3' + spec.add_development_dependency 'rake' end