Class: VagrantPlugins::Pushbullet::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-pushbullet/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



11
12
13
14
15
16
17
# File 'lib/vagrant-pushbullet/config.rb', line 11

def initialize
  super

  @token     = UNSET_VALUE

  @config_file = UNSET_VALUE
end

Instance Attribute Details

#messageObject

Returns the value of attribute message.



9
10
11
# File 'lib/vagrant-pushbullet/config.rb', line 9

def message
  @message
end

#tokenObject

API parameters



8
9
10
# File 'lib/vagrant-pushbullet/config.rb', line 8

def token
  @token
end

Instance Method Details

#attributesObject



42
43
44
# File 'lib/vagrant-pushbullet/config.rb', line 42

def attributes
  [  @token  ]
end

#finalize!Object



53
54
55
# File 'lib/vagrant-pushbullet/config.rb', line 53

def finalize!
  @token     = nil                     if @token     == UNSET_VALUE   
end

#is_config_validObject



46
47
48
49
50
51
# File 'lib/vagrant-pushbullet/config.rb', line 46

def is_config_valid
    attributes.each do |attribute|
      return true if attribute != UNSET_VALUE
    end
    false
end

#set {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



19
20
21
# File 'lib/vagrant-pushbullet/config.rb', line 19

def set
  yield self if block_given?
end

#validate(machine) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/vagrant-pushbullet/config.rb', line 24

def validate(machine)
  errors = []
  @config_file = ::VagrantPlugins::Pushbullet.config_file

  unless @config_file && @config_file.exist?
  
    errors << "Pushbullet configuration file created at:  #{@config_file}"
    errors << "run `pushbullet-config` for assistance on entering required values in that file."
    errors << "\n       --- you will not see this error again ----"
    ::VagrantPlugins::Pushbullet.write_default_key
  end

  require @config_file
  @token = PushbulletConfig::TOKEN

  {Pushbullet: errors}
end