Class: Guard::Luca
Instance Attribute Summary collapse
-
#faye_notifier ⇒ Object
Returns the value of attribute faye_notifier.
-
#project ⇒ Object
Returns the value of attribute project.
Instance Method Summary collapse
- #faye_url ⇒ Object
- #generate_notification_payload_for(paths = []) ⇒ Object
-
#initialize(watchers = [], options = {}) ⇒ Luca
constructor
A new instance of Luca.
- #run_on_changes(paths) ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(watchers = [], options = {}) ⇒ Luca
Returns a new instance of Luca.
21 22 23 24 25 26 27 28 |
# File 'lib/guard/luca.rb', line 21 def initialize(watchers=[],={}) super UI.info "Guard::Luca" @faye_notifier = FayeNotifier.new(faye_url) @project = ::Luca::Project.find_by_path( Dir.pwd() ) throw "Could not find a luca project in redis. Create one for this path." unless @project end |
Instance Attribute Details
#faye_notifier ⇒ Object
Returns the value of attribute faye_notifier.
19 20 21 |
# File 'lib/guard/luca.rb', line 19 def faye_notifier @faye_notifier end |
#project ⇒ Object
Returns the value of attribute project.
19 20 21 |
# File 'lib/guard/luca.rb', line 19 def project @project end |
Instance Method Details
#faye_url ⇒ Object
44 45 46 |
# File 'lib/guard/luca.rb', line 44 def faye_url ENV['LUCA_CODE_SYNC_URL'] || "//localhost:9292/faye" end |
#generate_notification_payload_for(paths = []) ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/guard/luca.rb', line 34 def generate_notification_payload_for(paths=[]) paths.compact.inject({}) do |memo,guard_path| base = "stylesheets" base = "javascripts" if guard_path.match(/(coffee|js|ejs.haml|mustache)$/) path = File.join(".","app","assets", base , guard_path) memo[path] = project.app.find_asset_wrapper_for(guard_path).to_change_notification memo end end |
#run_on_changes(paths) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/guard/luca.rb', line 48 def run_on_changes(paths) # temp paths.map(&:downcase!) notification_payload = generate_notification_payload_for(paths) UI.info notification_payload.to_json faye_notifier.publish("/changes", notification_payload ) end |
#start ⇒ Object
30 31 32 |
# File 'lib/guard/luca.rb', line 30 def start UI.info "Guard::Luca has been started" end |