Module: BundleBoss::Watchdog
- Defined in:
- lib/bundle_boss/watchdog.rb
Class Method Summary collapse
- .error(name, msg) ⇒ Object
- .info(name, msg) ⇒ Object
- .load(settings = {}) ⇒ Object
- .project_index ⇒ Object
- .run! ⇒ Object
- .success(name) ⇒ Object
Class Method Details
.error(name, msg) ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/bundle_boss/watchdog.rb', line 35 def error(name, msg) p [:error, msg] if @settings['notifications'] GrowlNotify.sticky!(:title => name, :description => msg, :icon => File.(File.dirname(__FILE__) + '/../../images/failed.png')) end end |
.info(name, msg) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/bundle_boss/watchdog.rb', line 17 def info(name, msg) p [:info, name, msg] if @settings['notifications'] GrowlNotify.normal(:title => name, :description => msg, :icon => File.(File.dirname(__FILE__) + '/../../images/pending.png')) end end |
.load(settings = {}) ⇒ Object
4 5 6 7 8 |
# File 'lib/bundle_boss/watchdog.rb', line 4 def load(settings = {}) @settings = settings['settings'] @bundler = settings['bundler'] @projects = settings['projects'].map {|path| File.(path) } end |
.project_index ⇒ Object
10 11 12 13 14 15 |
# File 'lib/bundle_boss/watchdog.rb', line 10 def project_index @index ||= @projects.inject({}) do |accum, path| accum[path.hash] = BundleBoss::Project.new(path, @bundler, @settings) accum end end |
.run! ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/bundle_boss/watchdog.rb', line 44 def run! watchdog = FSEvent.new watchdog.watch project_index.values.map(&:path) do |paths| paths.each do |path| hash = File.(path).hash project = project_index[hash] next unless project project.bundle if project.gemfile_changed? end end info('BundleBoss', 'Bundling like a boss.') watchdog.run end |
.success(name) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/bundle_boss/watchdog.rb', line 26 def success(name) p [:success, name] if @settings['notifications'] GrowlNotify.very_low(:title => name, :description => 'All systems go!', :icon => File.(File.dirname(__FILE__) + '/../../images/success.png')) end end |