guard 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,19 @@
1
+ ## 0.6.2 - August 17, 2011
2
+
3
+ ### Bugs fixes:
4
+
5
+ - 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][])
6
+ - Ensure that scoped groups and group name are symbolized before checking for inclusion. ([@rymai][])
7
+
8
+ ### New features
9
+
10
+ - Groups are now stored in a @groups variable (will be used for future features). ([@rymai][])
11
+ - Guards will now receive their group in the options hash at initialization (will be used for future features). ([@rymai][])
12
+
13
+ ### Improvement
14
+
15
+ - Explain the growl/growl_notify differences in the README. ([@netzpirat][])
16
+
1
17
  ## 0.6.1 - August 15, 2011
2
18
 
3
19
  ### Bugs fixes:
data/README.md CHANGED
@@ -13,7 +13,7 @@ Features
13
13
  * [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).
14
14
  * Polling on the other operating systems (help us to support more OS).
15
15
  * Automatic & Super fast (when polling is not used) files modifications detection (even new files are detected).
16
- * Growl notifications ([growlnotify](http://growl.info/documentation/growlnotify.php) & [growl gem](https://rubygems.org/gems/growl) required).
16
+ * 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).
17
17
  * Libnotify notifications ([libnotify gem](https://rubygems.org/gems/libnotify) required).
18
18
  * Tested against Ruby 1.8.7, 1.9.2 and REE.
19
19
 
@@ -55,19 +55,25 @@ Install the rb-fsevent gem for [FSEvent](http://en.wikipedia.org/wiki/FSEvents)
55
55
  $ gem install rb-fsevent
56
56
  ```
57
57
 
58
- Install the growl_notify gem if you want notification support:
58
+ Install either the growl_notify or the growl gem if you want notification support:
59
59
 
60
60
  ``` bash
61
61
  $ gem install growl_notify
62
+ $ # or
63
+ $ gem install growl
62
64
  ```
63
65
 
64
- And add it to your Gemfile:
66
+ And add them to your Gemfile:
65
67
 
66
68
  ``` ruby
67
69
  gem 'rb-fsevent'
68
- gem 'growl_notify'
70
+ gem 'growl'
69
71
  ```
70
72
 
73
+ The difference between growl and growl_notify is that growl_notify uses AppleScript to
74
+ display a message, whereas growl uses the `growlnotify` command. In general the AppleScript
75
+ approach is preferred, but this is currently known to not work in conjunction with Spork.
76
+
71
77
  ### On Linux
72
78
 
73
79
  Install the rb-inotify gem for [inotify](http://en.wikipedia.org/wiki/Inotify) support:
@@ -9,12 +9,13 @@ module Guard
9
9
  autoload :Notifier, 'guard/notifier'
10
10
 
11
11
  class << self
12
- attr_accessor :options, :guards, :listener
12
+ attr_accessor :options, :guards, :groups, :listener
13
13
 
14
14
  # initialize this singleton
15
15
  def setup(options = {})
16
16
  @options = options
17
17
  @listener = Listener.select_and_init(@options[:watchdir] ? File.expand_path(@options[:watchdir]) : Dir.pwd)
18
+ @groups = [:default]
18
19
  @guards = []
19
20
 
20
21
  @options[:notify] && ENV["GUARD_NOTIFY"] != 'false' ? Notifier.turn_on : Notifier.turn_off
@@ -82,20 +83,25 @@ module Guard
82
83
  end
83
84
 
84
85
  def add_guard(name, watchers = [], options = {})
85
- if name.downcase == 'ego'
86
+ if name.to_sym == :ego
86
87
  UI.deprecation("Guard::Ego is now part of Guard. You can remove it from your Guardfile.")
87
88
  else
88
- guard_class = get_guard_class(name)
89
- @guards << guard_class.new(watchers, options)
89
+ guard = get_guard_class(name).new(watchers, options)
90
+ @guards << guard
90
91
  end
91
92
  end
92
93
 
94
+ def add_group(name)
95
+ @groups << name.to_sym unless name.nil?
96
+ end
97
+
93
98
  def get_guard_class(name)
99
+ name = name.to_s
94
100
  try_require = false
95
- const_name = name.to_s.downcase.gsub('-', '')
101
+ const_name = name.downcase.gsub('-', '')
96
102
  begin
97
- require "guard/#{name.to_s.downcase}" if try_require
98
- self.const_get(self.constants.find {|c| c.to_s.downcase == const_name })
103
+ require "guard/#{name.downcase}" if try_require
104
+ self.const_get(self.constants.find { |c| c.to_s.downcase == const_name })
99
105
  rescue TypeError
100
106
  unless try_require
101
107
  try_require = true
@@ -106,13 +106,20 @@ module Guard
106
106
 
107
107
  def group(name, &guard_definition)
108
108
  @groups = @@options[:group] || []
109
- guard_definition.call if guard_definition && (@groups.empty? || @groups.include?(name.to_s))
109
+ name = name.to_sym
110
+
111
+ if guard_definition && (@groups.empty? || @groups.map(&:to_sym).include?(name))
112
+ @current_group = name
113
+ guard_definition.call
114
+ @current_group = nil
115
+ end
110
116
  end
111
117
 
112
118
  def guard(name, options = {}, &watch_definition)
113
119
  @watchers = []
114
120
  watch_definition.call if watch_definition
115
- ::Guard.add_guard(name, @watchers, options)
121
+ options.update(:group => (@current_group || :default))
122
+ ::Guard.add_guard(name.to_s.downcase.to_sym, @watchers, options)
116
123
  end
117
124
 
118
125
  def watch(pattern, &action)
@@ -1,9 +1,10 @@
1
1
  module Guard
2
2
  class Guard
3
3
 
4
- attr_accessor :watchers, :options
4
+ attr_accessor :watchers, :options, :group
5
5
 
6
6
  def initialize(watchers = [], options = {})
7
+ @group = options.delete(:group) || :default
7
8
  @watchers, @options = watchers, options
8
9
  end
9
10
 
@@ -47,10 +47,18 @@ module Guard
47
47
  def self.notify_mac(title, message, image, options)
48
48
  require_growl # need for guard-rspec formatter that is called out of guard scope
49
49
 
50
- options = { :description => message, :title => title, :icon => image_path(image), :application_name => APPLICATION_NAME }.merge(options)
51
- options.delete(:name)
50
+ default_options = { :title => title, :icon => image_path(image), :name => APPLICATION_NAME }
51
+ default_options.merge!(options)
52
52
 
53
- GrowlNotify.send_notification(options) if enabled?
53
+ if defined?(GrowlNotify)
54
+ default_options[:description] = message
55
+ default_options[:application_name] = APPLICATION_NAME
56
+ default_options.delete(:name)
57
+
58
+ GrowlNotify.send_notification(default_options) if enabled?
59
+ else
60
+ Growl.notify message, default_options.merge(options) if enabled?
61
+ end
54
62
  end
55
63
 
56
64
  def self.notify_linux(title, message, image, options)
@@ -94,17 +102,21 @@ module Guard
94
102
  end
95
103
 
96
104
  def self.require_growl
97
- require 'growl_notify'
98
-
99
- if GrowlNotify.application_name != APPLICATION_NAME
100
- GrowlNotify.config do |c|
101
- c.notifications = c.default_notifications = [ APPLICATION_NAME ]
102
- c.application_name = c.notifications.first
105
+ begin
106
+ require 'growl_notify'
107
+
108
+ if GrowlNotify.application_name != APPLICATION_NAME
109
+ GrowlNotify.config do |c|
110
+ c.notifications = c.default_notifications = [ APPLICATION_NAME ]
111
+ c.application_name = c.notifications.first
112
+ end
103
113
  end
114
+ rescue LoadError
115
+ require 'growl'
104
116
  end
105
117
  rescue LoadError
106
118
  turn_off
107
- UI.info "Please install growl_notify gem for Mac OS X notification support and add it to your Gemfile"
119
+ UI.info "Please install growl or growl_notify gem for Mac OS X notification support and add it to your Gemfile"
108
120
  end
109
121
 
110
122
  def self.require_libnotify
@@ -1,3 +1,3 @@
1
1
  module Guard
2
- VERSION = "0.6.1" unless defined? Guard::VERSION
2
+ VERSION = "0.6.2" unless defined? Guard::VERSION
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-08-15 00:00:00.000000000Z
12
+ date: 2011-08-17 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
16
- requirement: &70208916582320 !ruby/object:Gem::Requirement
16
+ requirement: &70138447631700 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70208916582320
24
+ version_requirements: *70138447631700
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &70208916581740 !ruby/object:Gem::Requirement
27
+ requirement: &70138447631080 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 2.6.0
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70208916581740
35
+ version_requirements: *70138447631080
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: guard-rspec
38
- requirement: &70208916581220 !ruby/object:Gem::Requirement
38
+ requirement: &70138447630400 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 0.3.1
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70208916581220
46
+ version_requirements: *70138447630400
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: thor
49
- requirement: &70208916580720 !ruby/object:Gem::Requirement
49
+ requirement: &70138447629860 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: 0.14.6
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70208916580720
57
+ version_requirements: *70138447629860
58
58
  description: Guard is a command line tool to easily handle events on file system modifications.
59
59
  email:
60
60
  - thibaud@thibaud.me