Class: VagrantPlugins::Pushover::Config
- Inherits:
-
Object
- Object
- VagrantPlugins::Pushover::Config
- Defined in:
- lib/vagrant-pushover/config.rb
Instance Attribute Summary collapse
-
#device ⇒ Object
Returns the value of attribute device.
-
#execute ⇒ Object
Returns the value of attribute execute.
-
#message ⇒ Object
Returns the value of attribute message.
-
#priority ⇒ Object
Returns the value of attribute priority.
-
#sound ⇒ Object
Returns the value of attribute sound.
-
#timestamp ⇒ Object
Returns the value of attribute timestamp.
-
#title ⇒ Object
Returns the value of attribute title.
-
#token ⇒ Object
API parameters See more details, pushover.net/api.
-
#url ⇒ Object
Returns the value of attribute url.
-
#url_title ⇒ Object
Returns the value of attribute url_title.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
- #attributes ⇒ Object
- #execute? ⇒ Boolean
- #finalize! ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #read_key ⇒ Object
- #set {|_self| ... } ⇒ Object
- #validate(machine) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/vagrant-pushover/config.rb', line 22 def initialize super @execute = false @token = UNSET_VALUE @user = UNSET_VALUE @message = UNSET_VALUE @device = UNSET_VALUE @title = UNSET_VALUE @url = UNSET_VALUE @url_title = UNSET_VALUE @priority = UNSET_VALUE @timestamp = UNSET_VALUE @sound = UNSET_VALUE end |
Instance Attribute Details
#device ⇒ Object
Returns the value of attribute device.
14 15 16 |
# File 'lib/vagrant-pushover/config.rb', line 14 def device @device end |
#execute ⇒ Object
Returns the value of attribute execute.
7 8 9 |
# File 'lib/vagrant-pushover/config.rb', line 7 def execute @execute end |
#message ⇒ Object
Returns the value of attribute message.
13 14 15 |
# File 'lib/vagrant-pushover/config.rb', line 13 def @message end |
#priority ⇒ Object
Returns the value of attribute priority.
18 19 20 |
# File 'lib/vagrant-pushover/config.rb', line 18 def priority @priority end |
#sound ⇒ Object
Returns the value of attribute sound.
20 21 22 |
# File 'lib/vagrant-pushover/config.rb', line 20 def sound @sound end |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
19 20 21 |
# File 'lib/vagrant-pushover/config.rb', line 19 def @timestamp end |
#title ⇒ Object
Returns the value of attribute title.
15 16 17 |
# File 'lib/vagrant-pushover/config.rb', line 15 def title @title end |
#token ⇒ Object
API parameters See more details, pushover.net/api
11 12 13 |
# File 'lib/vagrant-pushover/config.rb', line 11 def token @token end |
#url ⇒ Object
Returns the value of attribute url.
16 17 18 |
# File 'lib/vagrant-pushover/config.rb', line 16 def url @url end |
#url_title ⇒ Object
Returns the value of attribute url_title.
17 18 19 |
# File 'lib/vagrant-pushover/config.rb', line 17 def url_title @url_title end |
#user ⇒ Object
Returns the value of attribute user.
12 13 14 |
# File 'lib/vagrant-pushover/config.rb', line 12 def user @user end |
Instance Method Details
#attributes ⇒ Object
65 66 67 |
# File 'lib/vagrant-pushover/config.rb', line 65 def attributes [ @title, @message, @token, @user, @device, @url, @url_title, @priority, @timestamp, @sound ] end |
#execute? ⇒ Boolean
69 70 71 72 73 74 |
# File 'lib/vagrant-pushover/config.rb', line 69 def execute? attributes.each do |attribute| return true if attribute != UNSET_VALUE end false end |
#finalize! ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/vagrant-pushover/config.rb', line 76 def finalize! @execute = true if execute? @title = "Vagrant pushover" if @title == UNSET_VALUE @message = "Provisioning is over." if @message == UNSET_VALUE @token = nil if @token == UNSET_VALUE @user = nil if @user == UNSET_VALUE @device = nil if @device == UNSET_VALUE @url = nil if @url == UNSET_VALUE @url_title = nil if @url_title == UNSET_VALUE @priority = 0 if @priority == UNSET_VALUE @timestamp = nil if @timestamp == UNSET_VALUE @sound = nil if @sound == UNSET_VALUE end |
#read_key ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/vagrant-pushover/config.rb', line 41 def read_key config_file = ::VagrantPlugins::Pushover.config_file if not config_file.exist? ::VagrantPlugins::Pushover.write_default_key end require config_file @token = PushoverConfig::TOKEN @user = PushoverConfig::USER end |
#set {|_self| ... } ⇒ Object
37 38 39 |
# File 'lib/vagrant-pushover/config.rb', line 37 def set yield self if block_given? end |
#validate(machine) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/vagrant-pushover/config.rb', line 53 def validate(machine) errors = [] errors << "Edit .vagrant/pushover.rb and set your keys." if @execute && (@token == "YOUR APP TOKEN" || @user == "YOUR USER KEY" ) errors << "Your application's API token must be set." if @execute && !@token errors << "The user/group key must be set." if @execute && !@user errors << "You don't need Emergency priority(2) in this plugin." if @execute && @priority == 2 errors << "Priority must be set {-1,0,1}." if @execute && ( not [-1,0,1].include?(@priority)) errors << "See more details, https://pushover.net/api" if errors.any? {pushover: errors} end |