Class: MelissaData::VagrantPlugin::Actions::Update

Inherits:
Base
  • Object
show all
Defined in:
lib/melissadata/vagrant_plugin/actions/update.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from MelissaData::VagrantPlugin::Actions::Base

Instance Method Details

#call(env) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/melissadata/vagrant_plugin/actions/update.rb', line 4

def call(env)
  @vm = env['vm']
  if @vm.created? && @vm.vm.running?
    target_root = env['config'].melissadata.target_path
    env.ui.info I18n.t("vagrant.plugins.melissadata.updating"), :prefix => false

    sudo "gem uninstall melissadata" if test? "ruby -r md -e 'puts MD::VERSION'" #%Q!ruby -e 'require "rubygems"; require "melissadata"'!
    gem_filename = "melissadata-#{MelissaData::VERSION}.gem"
    copy_file "#{File.expand_path("pkg/#{gem_filename}", MelissaData.gem_root)}"
    sudo "gem install #{target_root}/#{gem_filename} && rm #{target_root}/#{gem_filename}"
  else
    env.ui.error "Vagrant VM is not running", :prefix => false
  end

  @app.call(env)
end