guard-puppet/lib/guard/puppet.rb

35 lines
840 B
Ruby
Raw Normal View History

2015-06-06 12:22:05 +00:00
require 'guard/compat/plugin'
2011-07-01 02:48:18 +00:00
2015-06-06 12:22:05 +00:00
module Guard
class Puppet < Plugin
2011-07-01 02:48:18 +00:00
class << self
attr_accessor :is_wrapping_exit
end
2015-06-06 12:22:05 +00:00
def initialize(options = {})
2011-07-01 02:48:18 +00:00
super
@options = options
2011-07-05 23:43:36 +00:00
UI.info "Guard::Puppet is watching for changes..."
2011-07-06 23:29:43 +00:00
run_all if options[:run_on_start]
2011-07-01 02:48:18 +00:00
end
def run_all
2011-07-01 03:53:15 +00:00
UI.info(msg = "Applying Puppet configuration...")
2011-07-01 02:48:18 +00:00
Notifier.notify msg, :title => "Puppet Config", :image => :pending
if Runner.new(@options).run != 0
2011-07-01 03:56:32 +00:00
Notifier.notify(msg = "Puppet config failure!", :title => "Puppet Config", :image => :failed)
2011-07-01 02:48:18 +00:00
else
2011-07-01 03:56:32 +00:00
Notifier.notify(msg = "Puppet config reapplied successfully!", :title => "Puppet Config")
2011-07-01 02:48:18 +00:00
end
2011-07-01 03:56:32 +00:00
UI.info(msg)
2011-07-01 02:48:18 +00:00
end
def run_on_change(files = [])
run_all
end
end
end
require 'guard/puppet/runner'