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 |
# File 'lib/vagrant-notify/config.rb', line 6 def initialize() @enable = 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
45 46 47 |
# File 'lib/vagrant-notify/config.rb', line 45 def finalize! @enable = 0 if @enable == UNSET_VALUE end |
#validate(machine) ⇒ Object
10 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 |
# File 'lib/vagrant-notify/config.rb', line 10 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 |