Class: Guard::Pusher
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(watchers = [], options = {}) ⇒ Pusher
constructor
A new instance of Pusher.
- #run_on_changes(paths) ⇒ Object
Constructor Details
#initialize(watchers = [], options = {}) ⇒ Pusher
Returns a new instance of Pusher.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/guard/pusher.rb', line 22 def initialize(watchers = [], = {}) super @options = config = if File.file?('config/pusher.yml') YAML.load(ERB.new(File.read('config/pusher.yml')).result)['development'] else end if self.class.configure(config) UI.info('Pusher is ready.', :reset => true) else UI.info("D'oh! Pusher not properly configured. Make sure to add app_id, key and secret.", :reset => true) end end |
Class Method Details
.configure(options) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/guard/pusher.rb', line 9 def self.configure() %w{app_id key secret}.inject(Hash.new) { |hash, key| hash[key] = [key] || [key.to_sym] hash }.each { |config, value| ::Pusher.send("#{config}=", value) } ::Pusher['guard-pusher'] rescue ::Pusher::ConfigurationError end |
Instance Method Details
#run_on_changes(paths) ⇒ Object
40 41 42 |
# File 'lib/guard/pusher.rb', line 40 def run_on_changes(paths) ::Pusher['guard-pusher'].trigger(@options[:event] || 'guard', { :paths => paths }) end |