Class: VagrantPlugins::Pushbullet::Action
- Inherits:
-
Object
- Object
- VagrantPlugins::Pushbullet::Action
- Defined in:
- lib/vagrant-pushbullet/action.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ Action
constructor
A new instance of Action.
- #notification(config, config_file) ⇒ Object
Constructor Details
#initialize(app, env) ⇒ Action
Returns a new instance of Action.
8 9 10 11 12 13 |
# File 'lib/vagrant-pushbullet/action.rb', line 8 def initialize(app,env) @app = app @ui = env[:ui] @machine = env[:machine].name.to_s @machinfo = env[:machine] end |
Instance Method Details
#call(env) ⇒ Object
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 |
# File 'lib/vagrant-pushbullet/action.rb', line 15 def call(env) # Before machine action state = env[:machine].state.id # Execute machine action @app.call(env) # After execute machine action config = env[:machine].config.Pushbullet action = env[:machine_action] provision = env[:provision_enabled] config_file = ::VagrantPlugins::Pushbullet.config_file unless config_file.exist? && config.is_config_valid puts "some validation failed" env[:ui].error("Pushbullet plugin configuration has not yet been set up. \nPlease replace required values in config file: #{config_file} ") end case action when :up notification(config, config_file) if state != :running && provision && config.is_config_valid when :reload notification(config, config_file) if provision && config.is_config_valid when :provision notification(config, config_file) if config.is_config_valid end end |
#notification(config, config_file) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/vagrant-pushbullet/action.rb', line 44 def notification(config, config_file) #TODO: append provisioning result, success or fail. require config_file devices = PushbulletConfig::DEVICES token = PushbulletConfig::TOKEN client = Washbullet::Client.new(token) if(devices.length > 0) devices.each {|iden| client.push_note(iden, "Vagrant Finished: #{@machine}", '') } else #push to all client.push_note('', "Vagrant Finished: #{@machine}", '') end end |