Class: VagrantPlugins::Skytap::Action::FetchEnvironment

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-skytap/action/fetch_environment.rb

Overview

Fetches the environment from the environment URL file, assuming the file exists and the corresponding Skytap environment does too.

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ FetchEnvironment

Returns a new instance of FetchEnvironment.



33
34
35
36
# File 'lib/vagrant-skytap/action/fetch_environment.rb', line 33

def initialize(app, env)
  @app = app
  @logger = Log4r::Logger.new("vagrant_skytap::action::fetch_environment")
end

Instance Method Details

#call(env) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/vagrant-skytap/action/fetch_environment.rb', line 38

def call(env)
  unless env[:environment]
    if props = API::Environment.properties(env)
      begin
        env[:environment] = API::Environment.fetch(env, props['url'])
      rescue Errors::DoesNotExist => ex
        @logger.info("Ignoring missing environment '#{props['url']}'.")
      end
    end
  end

  @app.call(env)
end