Class: VagrantPlugins::ProxyConf::Action::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-proxyconf/action/base.rb

Overview

Base class for proxy configuration Actions

Direct Known Subclasses

ConfigureAptProxy, ConfigureEnvProxy

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ Base

Returns a new instance of Base.



12
13
14
15
# File 'lib/vagrant-proxyconf/action/base.rb', line 12

def initialize(app, env)
  @app    = app
  @logger = Log4r::Logger.new('vagrant::proxyconf')
end

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



10
11
12
# File 'lib/vagrant-proxyconf/action/base.rb', line 10

def logger
  @logger
end

Instance Method Details

#call(env) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/vagrant-proxyconf/action/base.rb', line 17

def call(env)
  @app.call env

  machine = env[:machine]
  config  = config(machine)

  if !config.enabled?
    logger.debug I18n.t("vagrant_proxyconf.#{config_name}.not_enabled")
  elsif !supported?(machine)
    env[:ui].info I18n.t("vagrant_proxyconf.#{config_name}.not_supported")
  else
    env[:ui].info I18n.t("vagrant_proxyconf.#{config_name}.configuring")
    write_config(machine, config)
  end
end

#config_nameString

Returns the name of the configuration section.

Returns:

  • (String)

    the name of the configuration section

Raises:

  • (NotImplementedError)


34
35
36
# File 'lib/vagrant-proxyconf/action/base.rb', line 34

def config_name
  raise NotImplementedError, "Must be implemented by the inheriting class"
end