Class: Vagrant::Notify::Config
- Inherits:
-
Object
- Object
- Vagrant::Notify::Config
- Defined in:
- lib/vagrant-notify/config.rb
Instance Attribute Summary collapse
-
#bind_ip ⇒ Object
Returns the value of attribute bind_ip.
-
#enable ⇒ Object
Returns the value of attribute enable.
Instance Method Summary collapse
- #finalize! ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #validate(machine) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
6 7 8 9 |
# File 'lib/vagrant-notify/config.rb', line 6 def initialize() @enable = UNSET_VALUE @bind_ip = UNSET_VALUE end |
Instance Attribute Details
#bind_ip ⇒ Object
Returns the value of attribute bind_ip.
4 5 6 |
# File 'lib/vagrant-notify/config.rb', line 4 def bind_ip @bind_ip end |
#enable ⇒ Object
Returns the value of attribute enable.
4 5 6 |
# File 'lib/vagrant-notify/config.rb', line 4 def enable @enable end |
Instance Method Details
#finalize! ⇒ Object
46 47 48 49 |
# File 'lib/vagrant-notify/config.rb', line 46 def finalize! @enable = 0 if @enable == UNSET_VALUE @bind_ip = @bind_ip if @bind_ip == UNSET_VALUE end |
#validate(machine) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/vagrant-notify/config.rb', line 11 def validate(machine) errors = _detected_errors if backed_by_cloud_provider?(machine) machine.ui.warn("Disabling vagrant-notify, cloud provider #{machine.provider_name} in use.") @enable = false end if @enable != 0 if @enable != false && @enable != true errors << "Unknown option: #{@enable}" end end if backed_by_supported_provider?(machine) if @bind_ip.is_a?(String) require "resolv" unless @bind_ip =~ Resolv::IPv4::Regex errors << "Invalid bind IP address: #{@bind_ip}" end elsif @bind_ip.is_a?(FalseClass) || @bind_ip.is_a?(Fixnum) || @bind_ip.is_a?(Array) || @bind_ip.is_a?(Hash) errors << "Unknown bind IP address: #{@bind_ip}" else @bind_ip = SUPPORTED_PROVIDERS[machine.provider_name] end else machine.ui.warn("#{machine.provider_name.to_s} provider is not supported by vagrant-notify. Please feel free to open a new issue https://github.com/fgrehm/vagrant-notify/issues") @enable = false end { "notify" => errors } end |