Skip to content

Commit

Permalink
Merge branch 'master' into stdin
Browse files Browse the repository at this point in the history
Conflicts:
	Guardfile
	lib/guard.rb
  • Loading branch information
thibaudgg committed Aug 30, 2011
2 parents 63c3015 + b144514 commit 5de94cc
Show file tree
Hide file tree
Showing 14 changed files with 309 additions and 103 deletions.
28 changes: 22 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
## 0.6.2 - August 17, 2011

### Bugs fixes:

- Re-add the possibility to use the `growl` gem since the `growl_notify` gem this is currently known to not work in conjunction with Spork. ([@netzpirat][])
- Ensure that scoped groups and group name are symbolized before checking for inclusion. ([@rymai][])

### New features:

- Groups are now stored in a @groups variable (will be used for future features). ([@rymai][])
- Guards will now receive their group in the options hash at initialization (will be used for future features). ([@rymai][])

### Improvement:

- Explain the growl/growl_notify differences in the README. ([@netzpirat][])

## 0.6.1 - August 15, 2011

### Bugs fixes:
Expand All @@ -12,11 +28,11 @@
- Pull request [#107](https://github.com/guard/guard/pull/107): Small spelling fix. ([@dnagir][])
- Dir.glob now ignores files that don't need to be watched. ([@rymai][])

### New features
### New features:

- Pull request [#112](https://github.com/guard/guard/pull/112): Add `list` command to CLI. ([@docwhat][])

### Improvements
### Improvements:

- Pull request [#99](https://github.com/guard/guard/pull/99): [OS X] Switch from growl gem to growl_notify gem. ([@johnbintz][])
- Pull request [#115](https://github.com/guard/guard/pull/115): [Linux] Add ':transient => true' to default libnotify options. ([@zonque][])
Expand All @@ -35,12 +51,12 @@

## 0.5.0 - July 2, 2011

### New features
### New features:

- Guard::Ego is now part of Guard, so Guardfile is automagically re-evaluated when modified. ([@thibaudgg][])
- Pull request [#91](https://github.com/guard/guard/pull/91): Show Guards in Guardfile with the `guard -T`. ([@johnbintz][])

### Improvements
### Improvements:

- Issue [#98](https://github.com/guard/guard/issues/98): Multiple calls per watch event on linux with rb-inotify. ([@jeffutter][] & [@netzpirat][])
- Pull request [#94](https://github.com/guard/guard/pull/94): Show backtrace in terminal when a problem with a watch action occurs. ([@capotej][])
Expand All @@ -62,7 +78,7 @@

## 0.4.1 - June 7, 2011

### Improvements
### Improvements:

- Pull request [#77](https://github.com/guard/guard/pull/77): Refactor `get_guard_class` to first try the constant and fallback to require + various tweaks. ([@mislav][])
- Notifier improvement, don't use system notification library if could not be required. ([@yannlugrin][])
Expand All @@ -78,7 +94,7 @@
- Pull request [#73](https://github.com/guard/guard/pull/73): Allow DSL's `group` method to accept a Symbol as group name. ([@johnbintz][])
- Pull request [#51](https://github.com/guard/guard/pull/51): Allow options (like `:priority`) to be passed through to the Notifier. ([@indirect][] & [@netzpirat][])

### Improvements
### Improvements:

- Pull request [#74](https://github.com/guard/guard/pull/74): Added link definitions to make the CHANGELOG more DRY! That's for sure now, we have the cleanest CHANGELOG ever! (even the link definitions are sorted alphabetically!) ([@pcreux][])

Expand Down
6 changes: 1 addition & 5 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,11 @@ group :guard do
gem 'guard-ronn'
end

group :test do
gem 'fuubar'
end

require 'rbconfig'

if RbConfig::CONFIG['target_os'] =~ /darwin/i
gem 'rb-fsevent', '>= 0.4.0', :require => false
gem 'growl_notify', :require => false
gem 'growl', '~> 1.0.3', :require => false
end
if RbConfig::CONFIG['target_os'] =~ /linux/i
gem 'rb-inotify', '>= 0.8.5', :require => false
Expand Down
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Features
* [Directory Change Notification](http://msdn.microsoft.com/en-us/library/aa365261\(VS.85\).aspx) support on Windows ([rb-fchange, >= 0.0.2](https://rubygems.org/gems/rb-fchange) required).
* Polling on the other operating systems (help us to support more OS).
* Automatic & Super fast (when polling is not used) files modifications detection (even new files are detected).
* Growl notifications ([growlnotify](http://growl.info/documentation/growlnotify.php) & [growl gem](https://rubygems.org/gems/growl) required).
* Growl notifications ([growl_notify gem](https://rubygems.org/gems/growl_notify) or [growlnotify](http://growl.info/documentation/growlnotify.php) & [growl gem](https://rubygems.org/gems/growl) required).
* Libnotify notifications ([libnotify gem](https://rubygems.org/gems/libnotify) required).
* Tested against Ruby 1.8.7, 1.9.2 and REE.

Expand Down Expand Up @@ -55,19 +55,25 @@ Install the rb-fsevent gem for [FSEvent](http://en.wikipedia.org/wiki/FSEvents)
$ gem install rb-fsevent
```

Install the growl_notify gem if you want notification support:
Install either the growl_notify or the growl gem if you want notification support:

``` bash
$ gem install growl_notify
$ # or
$ gem install growl
```

And add it to your Gemfile:
And add them to your Gemfile:

``` ruby
gem 'rb-fsevent'
gem 'growl_notify'
gem 'growl'
```

The difference between growl and growl_notify is that growl_notify uses AppleScript to
display a message, whereas growl uses the `growlnotify` command. In general the AppleScript
approach is preferred, but this is currently known to not work in conjunction with Spork.

### On Linux

Install the rb-inotify gem for [inotify](http://en.wikipedia.org/wiki/Inotify) support:
Expand Down
20 changes: 13 additions & 7 deletions lib/guard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ module Guard
autoload :Notifier, 'guard/notifier'

class << self
attr_accessor :options, :guards, :interactor, :listener
attr_accessor :options, :guards, :groups, :interactor, :listener

# initialize this singleton
def setup(options = {})
@options = options
@guards = []
@groups = [:default]
@interactor = Interactor.new
@listener = Listener.select_and_init(@options[:watchdir] ? File.expand_path(@options[:watchdir]) : Dir.pwd)

Expand Down Expand Up @@ -105,20 +106,25 @@ def supervised_task(guard, task_to_supervise, *args)
end

def add_guard(name, watchers = [], options = {})
if name.downcase == 'ego'
if name.to_sym == :ego
UI.deprecation("Guard::Ego is now part of Guard. You can remove it from your Guardfile.")
else
guard_class = get_guard_class(name)
@guards << guard_class.new(watchers, options)
guard = get_guard_class(name).new(watchers, options)
@guards << guard
end
end

def add_group(name)
@groups << name.to_sym unless name.nil?
end

def get_guard_class(name)
name = name.to_s
try_require = false
const_name = name.to_s.downcase.gsub('-', '')
const_name = name.downcase.gsub('-', '')
begin
require "guard/#{name.to_s.downcase}" if try_require
self.const_get(self.constants.find {|c| c.to_s.downcase == const_name })
require "guard/#{name.downcase}" if try_require
self.const_get(self.constants.find { |c| c.to_s.downcase == const_name })
rescue TypeError
unless try_require
try_require = true
Expand Down
11 changes: 9 additions & 2 deletions lib/guard/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,20 @@ def home_guardfile_path

def group(name, &guard_definition)
@groups = @@options[:group] || []
guard_definition.call if guard_definition && (@groups.empty? || @groups.include?(name.to_s))
name = name.to_sym

if guard_definition && (@groups.empty? || @groups.map(&:to_sym).include?(name))
@current_group = name
guard_definition.call
@current_group = nil
end
end

def guard(name, options = {}, &watch_definition)
@watchers = []
watch_definition.call if watch_definition
::Guard.add_guard(name, @watchers, options)
options.update(:group => (@current_group || :default))
::Guard.add_guard(name.to_s.downcase.to_sym, @watchers, options)
end

def watch(pattern, &action)
Expand Down
3 changes: 2 additions & 1 deletion lib/guard/guard.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
module Guard
class Guard

attr_accessor :watchers, :options
attr_accessor :watchers, :options, :group

def initialize(watchers = [], options = {})
@group = options.delete(:group) || :default
@watchers, @options = watchers, options
end

Expand Down
32 changes: 22 additions & 10 deletions lib/guard/notifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,18 @@ def self.enabled?
def self.notify_mac(title, message, image, options)
require_growl # need for guard-rspec formatter that is called out of guard scope

options = { :description => message, :title => title, :icon => image_path(image), :application_name => APPLICATION_NAME }.merge(options)
options.delete(:name)
default_options = { :title => title, :icon => image_path(image), :name => APPLICATION_NAME }
default_options.merge!(options)

GrowlNotify.send_notification(options) if enabled?
if defined?(GrowlNotify)
default_options[:description] = message
default_options[:application_name] = APPLICATION_NAME
default_options.delete(:name)

GrowlNotify.send_notification(default_options) if enabled?
else
Growl.notify message, default_options.merge(options) if enabled?
end
end

def self.notify_linux(title, message, image, options)
Expand Down Expand Up @@ -94,17 +102,21 @@ def self.image_level(image)
end

def self.require_growl
require 'growl_notify'

if GrowlNotify.application_name != APPLICATION_NAME
GrowlNotify.config do |c|
c.notifications = c.default_notifications = [ APPLICATION_NAME ]
c.application_name = c.notifications.first
begin
require 'growl_notify'

if GrowlNotify.application_name != APPLICATION_NAME
GrowlNotify.config do |c|
c.notifications = c.default_notifications = [ APPLICATION_NAME ]
c.application_name = c.notifications.first
end
end
rescue LoadError
require 'growl'
end
rescue LoadError
turn_off
UI.info "Please install growl_notify gem for Mac OS X notification support and add it to your Gemfile"
UI.info "Please install growl or growl_notify gem for Mac OS X notification support and add it to your Gemfile"
end

def self.require_libnotify
Expand Down
2 changes: 1 addition & 1 deletion lib/guard/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Guard
VERSION = "0.6.1" unless defined? Guard::VERSION
VERSION = "0.6.2" unless defined? Guard::VERSION
end
2 changes: 1 addition & 1 deletion man/guard.ronn → man/guard.1.ronn
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ List defined groups and guards for the current Guardfile.
### -h, help [COMMAND]

List all of Guard's available commands.

If <COMMAND> is given, displays a specific help for <TASK>.

## EXAMPLES
Expand Down
Loading

0 comments on commit 5de94cc

Please sign in to comment.