guard 1.2.3 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,5 @@
1
1
  require 'rbconfig'
2
+ require 'guard/ui'
2
3
 
3
4
  module Guard
4
5
  module Notifier
@@ -104,7 +105,7 @@ module Guard
104
105
  :name => type,
105
106
  :title => title,
106
107
  :text => message,
107
- :icon => "file://#{ image }"
108
+ :icon => image
108
109
  }))
109
110
  end
110
111
 
@@ -1,4 +1,5 @@
1
1
  require 'rbconfig'
2
+ require 'guard/ui'
2
3
 
3
4
  module Guard
4
5
  module Notifier
@@ -1,4 +1,5 @@
1
1
  require 'rbconfig'
2
+ require 'guard/ui'
2
3
 
3
4
  module Guard
4
5
  module Notifier
@@ -58,7 +59,7 @@ module Guard
58
59
  false
59
60
  end
60
61
 
61
- rescue LoadError
62
+ rescue LoadError, NameError
62
63
  ::Guard::UI.error "Please add \"gem 'growl_notify'\" to your Gemfile and run Guard with \"bundle exec\"." unless silent
63
64
  false
64
65
  end
@@ -1,4 +1,5 @@
1
1
  require 'rbconfig'
2
+ require 'guard/ui'
2
3
 
3
4
  module Guard
4
5
  module Notifier
@@ -1,4 +1,5 @@
1
1
  require 'rbconfig'
2
+ require 'guard/ui'
2
3
 
3
4
  module Guard
4
5
  module Notifier
@@ -1,4 +1,5 @@
1
1
  require 'rbconfig'
2
+ require 'guard/ui'
2
3
 
3
4
  module Guard
4
5
  module Notifier
@@ -0,0 +1,65 @@
1
+ require 'guard/ui'
2
+
3
+ module Guard
4
+ module Notifier
5
+
6
+ # System notifications using the [terminal_notifier](https://github.com/alloy/terminal-notifier gem.
7
+ #
8
+ # This gem is available for OS X 10.8 Mountain Lion and sends notifications to the OS X
9
+ # notification center.
10
+ #
11
+ # @example Add the `terminal_notifier` gem to your `Gemfile`
12
+ # group :development
13
+ # gem 'terminal-notifier'
14
+ # end
15
+ #
16
+ # @example Add the `:terminal_notifier` notifier to your `Guardfile`
17
+ # notification :terminal_notifier
18
+ #
19
+ # @example Add the `:terminal_notifier` notifier with configuration options to your `Guardfile`
20
+ # notification :terminal_notifier, app_name: "MyApp"
21
+ #
22
+ module TerminalNotifier
23
+ extend self
24
+
25
+ # Test if the notification library is available.
26
+ #
27
+ # @param [Boolean] silent true if no error messages should be shown
28
+ # @return [Boolean] the availability status
29
+ #
30
+ def available?(silent=false)
31
+ require 'terminal-notifier'
32
+
33
+ if ::TerminalNotifier.available?
34
+ true
35
+ else
36
+ ::Guard::UI.error 'The :terminal_notifier only runs on Mac OS X 10.8 and later.' unless silent
37
+ false
38
+ end
39
+
40
+ rescue LoadError, NameError
41
+ ::Guard::UI.error "Please add \"gem 'terminal-notifier'\" to your Gemfile and run Guard with \"bundle exec\"." unless silent
42
+ false
43
+ end
44
+
45
+ # Show a system notification.
46
+ #
47
+ # @param [String] type the notification type. Either 'success', 'pending', 'failed' or 'notify'
48
+ # @param [String] title the notification title
49
+ # @param [String] message the notification message body
50
+ # @param [String] image the path to the notification image (ignored)
51
+ # @param [Hash] options additional notification library options
52
+ # @option options [String] app_name name of your app
53
+ # @option options [String] execute a command
54
+ # @option options [String] activate an app bundle
55
+ # @option options [String] open some url or file
56
+ #
57
+ def notify(type, title, message, image, options = { })
58
+ require 'terminal-notifier'
59
+ options[:title] = [options[:app_name] || 'Guard', type.downcase.capitalize, title].join ' '
60
+ options.delete :app_name if options[:app_name]
61
+ ::TerminalNotifier.notify(message, options)
62
+ end
63
+ end
64
+ end
65
+ end
data/lib/guard/runner.rb CHANGED
@@ -4,6 +4,10 @@ module Guard
4
4
  #
5
5
  class Runner
6
6
 
7
+ require 'guard'
8
+ require 'guard/ui'
9
+ require 'guard/watcher'
10
+
7
11
  # Deprecation message for the `run_on_change` method
8
12
  RUN_ON_CHANGE_DEPRECATION = <<-EOS.gsub(/^\s*/, '')
9
13
  Starting with Guard v1.1 the use of the 'run_on_change' method in the '%s' guard is deprecated.
@@ -30,8 +34,8 @@ module Guard
30
34
  #
31
35
  def deprecation_warning
32
36
  ::Guard.guards.each do |guard|
33
- UI.deprecation(RUN_ON_CHANGE_DEPRECATION % guard.class.name) if guard.respond_to?(:run_on_change)
34
- UI.deprecation(RUN_ON_DELETION_DEPRECATION % guard.class.name) if guard.respond_to?(:run_on_deletion)
37
+ ::Guard::UI.deprecation(RUN_ON_CHANGE_DEPRECATION % guard.class.name) if guard.respond_to?(:run_on_change)
38
+ ::Guard::UI.deprecation(RUN_ON_DELETION_DEPRECATION % guard.class.name) if guard.respond_to?(:run_on_deletion)
35
39
  end
36
40
  end
37
41
 
@@ -61,11 +65,11 @@ module Guard
61
65
  #
62
66
  def run_on_changes(modified, added, removed)
63
67
  scoped_guards do |guard|
64
- modified_paths = Watcher.match_files(guard, modified)
65
- added_paths = Watcher.match_files(guard, added)
66
- removed_paths = Watcher.match_files(guard, removed)
68
+ modified_paths = ::Guard::Watcher.match_files(guard, modified)
69
+ added_paths = ::Guard::Watcher.match_files(guard, added)
70
+ removed_paths = ::Guard::Watcher.match_files(guard, removed)
67
71
 
68
- UI.clear if clearable?(guard, modified_paths, added_paths, removed_paths)
72
+ ::Guard::UI.clear if clearable?(guard, modified_paths, added_paths, removed_paths)
69
73
 
70
74
  run_first_task_found(guard, MODIFICATION_TASKS, modified_paths) unless modified_paths.empty?
71
75
  run_first_task_found(guard, ADDITION_TASKS, added_paths) unless added_paths.empty?
@@ -95,11 +99,11 @@ module Guard
95
99
  rescue NoMethodError
96
100
  # Do nothing
97
101
  rescue Exception => ex
98
- UI.error("#{ guard.class.name } failed to achieve its <#{ task.to_s }>, exception was:" +
102
+ ::Guard::UI.error("#{ guard.class.name } failed to achieve its <#{ task.to_s }>, exception was:" +
99
103
  "\n#{ ex.class }: #{ ex.message }\n#{ ex.backtrace.join("\n") }")
100
104
 
101
105
  ::Guard.guards.delete guard
102
- UI.info("\n#{ guard.class.name } has just been fired")
106
+ ::Guard::UI.info("\n#{ guard.class.name } has just been fired")
103
107
 
104
108
  ex
105
109
  end
@@ -137,7 +141,7 @@ module Guard
137
141
  run_supervised_task(guard, task, task_param)
138
142
  break
139
143
  else
140
- UI.debug "Trying to run #{ guard.class.name }##{ task.to_s } with #{ task_param.inspect }"
144
+ ::Guard::UI.debug "Trying to run #{ guard.class.name }##{ task.to_s } with #{ task_param.inspect }"
141
145
  end
142
146
  end
143
147
  end
@@ -147,7 +151,7 @@ module Guard
147
151
  # Stop the task run for the all Guard plugins within a group if one Guard
148
152
  # throws `:task_has_failed`.
149
153
  #
150
- # @param [Hash] scopes an hash with a Guard plugin or a group scope
154
+ # @param [Hash] scopes hash with a Guard plugin or a group scope
151
155
  # @yield the task to run
152
156
  #
153
157
  def scoped_guards(scopes = {})
data/lib/guard/ui.rb CHANGED
@@ -87,7 +87,7 @@ module Guard
87
87
  # Show a scoped action message.
88
88
  #
89
89
  # @param [String] action the action to show
90
- # @param [Hash] scopes an hash with a guard or a group scope
90
+ # @param [Hash] scopes hash with a guard or a group scope
91
91
  #
92
92
  def action_with_scopes(action, scopes)
93
93
  scope_message ||= scopes[:guard]
data/lib/guard/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Guard
2
2
  # The current gem version of Guard
3
- VERSION = '1.2.3'
3
+ VERSION = '1.3.0'
4
4
  end
@@ -95,7 +95,7 @@ x
95
95
  VERSION
96
96
  s
97
97
  5
98
- 1.2.2
98
+ 1.3.0
99
99
  x
100
100
  9
101
101
  const_set
data/lib/guard/watcher.rb CHANGED
@@ -6,6 +6,8 @@ module Guard
6
6
  #
7
7
  class Watcher
8
8
 
9
+ require 'guard/ui'
10
+
9
11
  attr_accessor :pattern, :action
10
12
 
11
13
  # Initialize a file watcher.
@@ -20,8 +22,8 @@ module Guard
20
22
  # deprecation warning
21
23
  if @pattern.is_a?(String) && @pattern =~ /(^(\^))|(>?(\\\.)|(\.\*))|(\(.*\))|(\[.*\])|(\$$)/
22
24
  unless @@warning_printed
23
- UI.info "*"*20 + "\nDEPRECATION WARNING!\n" + "*"*20
24
- UI.info <<-MSG
25
+ ::Guard::UI.info "*"*20 + "\nDEPRECATION WARNING!\n" + "*"*20
26
+ ::Guard::UI.info <<-MSG
25
27
  You have a string in your Guardfile watch patterns that seem to represent a Regexp.
26
28
  Guard matches String with == and Regexp with Regexp#match.
27
29
  You should either use plain String (without Regexp special characters) or real Regexp.
@@ -29,7 +31,7 @@ module Guard
29
31
  @@warning_printed = true
30
32
  end
31
33
 
32
- UI.info "\"#{@pattern}\" has been converted to #{ Regexp.new(@pattern).inspect }\n"
34
+ ::Guard::UI.info "\"#{@pattern}\" has been converted to #{ Regexp.new(@pattern).inspect }\n"
33
35
  @pattern = Regexp.new(@pattern)
34
36
  end
35
37
  end
@@ -79,7 +81,7 @@ module Guard
79
81
  # @deprecated Use .match instead
80
82
  #
81
83
  def match_file?(file)
82
- UI.info "Guard::Watcher.match_file? is deprecated, please use Guard::Watcher.match instead."
84
+ ::Guard::UI.info "Guard::Watcher.match_file? is deprecated, please use Guard::Watcher.match instead."
83
85
  match(file)
84
86
  end
85
87
 
@@ -121,7 +123,7 @@ module Guard
121
123
  begin
122
124
  @action.arity > 0 ? @action.call(matches) : @action.call
123
125
  rescue Exception => e
124
- UI.error "Problem with watch action!\n#{ e.message }\n\n#{ e.backtrace.join("\n") }"
126
+ ::Guard::UI.error "Problem with watch action!\n#{ e.message }\n\n#{ e.backtrace.join("\n") }"
125
127
  end
126
128
  end
127
129
 
data/man/guard.1 CHANGED
@@ -53,11 +53,11 @@ The following options are available:
53
53
  .P
54
54
  \fB\-p\fR, \fB\-\-force\-polling\fR Force usage of the Listen polling listener\.
55
55
  .
56
- .SS "init [GUARD]"
56
+ .SS "init [GUARDS]"
57
57
  If no Guardfile is present in the current directory, creates an empty Guardfile\.
58
58
  .
59
59
  .P
60
- If \fIGUARD\fR is present, add its default Guardfile configuration to the current Guardfile\. Note that \fIGUARD\fR is the Guard plugin name without the \fBguard\-\fR prefix\. For instance to initialize guard\-rspec, run \fBguard init rspec\fR\.
60
+ If \fIGUARDS\fR are present, add their default Guardfile configuration to the current Guardfile\. Note that \fIGUARDS\fR is a list of the Guard plugin names without the \fBguard\-\fR prefix\. For instance to initialize guard\-rspec, run \fBguard init rspec\fR\.
61
61
  .
62
62
  .SS "list"
63
63
  Lists Guard plugins that can be used with the \fBinit\fR command\.
data/man/guard.1.html CHANGED
@@ -126,12 +126,12 @@
126
126
  <p><code>-p</code>, <code>--force-polling</code>
127
127
  Force usage of the Listen polling listener.</p>
128
128
 
129
- <h3 id="init-GUARD-">init [GUARD]</h3>
129
+ <h3 id="init-GUARDS-">init [GUARDS]</h3>
130
130
 
131
131
  <p>If no Guardfile is present in the current directory, creates an empty Guardfile.</p>
132
132
 
133
- <p>If <var>GUARD</var> is present, add its default Guardfile configuration to the current Guardfile.
134
- Note that <var>GUARD</var> is the Guard plugin name without the <code>guard-</code> prefix.
133
+ <p>If <var>GUARDS</var> are present, add their default Guardfile configuration to the current Guardfile.
134
+ Note that <var>GUARDS</var> is a list of the Guard plugin names without the <code>guard-</code> prefix.
135
135
  For instance to initialize guard-rspec, run <code>guard init rspec</code>.</p>
136
136
 
137
137
  <h3 id="list">list</h3>
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: 1.2.3
4
+ version: 1.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-02 00:00:00.000000000 Z
12
+ date: 2012-08-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
@@ -117,12 +117,14 @@ files:
117
117
  - lib/guard/interactors/readline.rb
118
118
  - lib/guard/interactors/simple.rb
119
119
  - lib/guard/notifier.rb
120
+ - lib/guard/notifiers/emacs.rb
120
121
  - lib/guard/notifiers/gntp.rb
121
122
  - lib/guard/notifiers/growl.rb
122
123
  - lib/guard/notifiers/growl_notify.rb
123
124
  - lib/guard/notifiers/libnotify.rb
124
125
  - lib/guard/notifiers/notifysend.rb
125
126
  - lib/guard/notifiers/rb_notifu.rb
127
+ - lib/guard/notifiers/terminal_notifier.rb
126
128
  - lib/guard/runner.rb
127
129
  - lib/guard/templates/Guardfile
128
130
  - lib/guard/ui.rb
@@ -149,7 +151,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
149
151
  version: '0'
150
152
  segments:
151
153
  - 0
152
- hash: 4606659073432291932
154
+ hash: -1136247660184135072
153
155
  required_rubygems_version: !ruby/object:Gem::Requirement
154
156
  none: false
155
157
  requirements: