guard 2.2.4 → 2.2.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a8af99f10f6df5f4ec30fda1e60627279c331afa
4
- data.tar.gz: fab4128ccc9c311302c80270de736dbdaefacae1
3
+ metadata.gz: 7b5c095e15ffd825f5b44a76fccc7876c3720c17
4
+ data.tar.gz: 17adc2900e6ba19bd56b266c45d8ab36a11ef9c1
5
5
  SHA512:
6
- metadata.gz: eea1545a513b80dd36aed19b1f94189a8508bbe01c8e9ff1416807597dbd3a58e3b5df68f4e1c973d264160e861240aa999a87340aed6ca7369a80fddff61c84
7
- data.tar.gz: d4d9c887f95c45cc671c7237d5c043eb2dd1b841d5b024f273260fda4164e8f080006a49bf7efe121997e3db9995831fd47360d24939f70a5be75a36ade05d95
6
+ metadata.gz: 3ebe13bbb141439cec3005cca533ab37c6b4d8352ea680cc432ecc32808796f057039870c7cba7848a2bcbdc8f87713a230cf11f9b91614eaee7ebe92e6a2c89
7
+ data.tar.gz: fb246be778aadad200aa3ca328c35c542aef5c639cd249a58eef920bd50c0358645c5ff30b97aa64a8cfd7de4ac5b0ec52b39a3f544a246c6c3beed22a7e3341
data/README.md CHANGED
@@ -478,7 +478,7 @@ group :docs do
478
478
  end
479
479
  ```
480
480
 
481
- Groups can be nested, reopened and can take muliple names to assign its plugin to multiple groups:
481
+ Groups can be nested, reopened and can take multiple names to assign its plugin to multiple groups:
482
482
 
483
483
  ```ruby
484
484
  group :desktop do
data/lib/guard/dsl.rb CHANGED
@@ -116,8 +116,9 @@ module Guard
116
116
  # @see Guard.add_group
117
117
  # @see #guard
118
118
  #
119
- def group(name, options = {})
120
- groups = Array(name)
119
+ def group(*args)
120
+ options = args.last.is_a?(Hash) ? args.pop : {}
121
+ groups = args
121
122
 
122
123
  groups.each do |group|
123
124
  raise ArgumentError, "'all' is not an allowed group name!" if group.to_sym == :all
@@ -169,8 +170,8 @@ module Guard
169
170
 
170
171
  yield if block_given?
171
172
 
172
- groups = @current_groups || [[:default]]
173
- groups.last.each do |group|
173
+ groups = @current_groups && @current_groups.last || [:default]
174
+ groups.each do |group|
174
175
  options.merge!(group: group, watchers: @watchers, callbacks: @callbacks)
175
176
  ::Guard.add_plugin(name, options)
176
177
  end
@@ -17,73 +17,6 @@ module Guard
17
17
 
18
18
  require 'guard/ui'
19
19
 
20
- # The Hooker module gets included.
21
- #
22
- # @param [Class] base the class that includes the module
23
- #
24
- def self.included(base)
25
- base.send :include, InstanceMethods
26
- end
27
-
28
- # Instance methods that gets included in the base class.
29
- #
30
- module InstanceMethods
31
-
32
- # When event is a Symbol, {#hook} will generate a hook name
33
- # by concatenating the method name from where {#hook} is called
34
- # with the given Symbol.
35
- #
36
- # @example Add a hook with a Symbol
37
- #
38
- # def run_all
39
- # hook :foo
40
- # end
41
- #
42
- # Here, when {Guard::Plugin::Base#run_all} is called, {#hook} will notify
43
- # callbacks registered for the "run_all_foo" event.
44
- #
45
- # When event is a String, {#hook} will directly turn the String
46
- # into a Symbol.
47
- #
48
- # @example Add a hook with a String
49
- #
50
- # def run_all
51
- # hook "foo_bar"
52
- # end
53
- #
54
- # When {Guard::Plugin::Base#run_all} is called, {#hook} will notify
55
- # callbacks registered for the "foo_bar" event.
56
- #
57
- # @param [Symbol, String] event the name of the Guard event
58
- # @param [Array] args the parameters are passed as is to the callbacks
59
- # registered for the given event.
60
- #
61
- def hook(event, *args)
62
- hook_name = if event.is_a? Symbol
63
- calling_method = caller[0][/`([^']*)'/, 1]
64
- "#{ calling_method }_#{ event }"
65
- else
66
- event
67
- end
68
-
69
- ::Guard::UI.debug "Hook :#{ hook_name } executed for #{ self.class }"
70
-
71
- Hooker.notify(self, hook_name.to_sym, *args)
72
- end
73
-
74
- private
75
-
76
- # Add all the Guard::Plugin's callbacks to the global @callbacks array
77
- # that's used by Guard to know which callbacks to notify.
78
- #
79
- def _register_callbacks
80
- callbacks.each do |callback|
81
- Hooker.add_callback(callback[:listener], self, callback[:events])
82
- end
83
- end
84
-
85
- end
86
-
87
20
  # Get all callbacks registered for all Guard plugins present in the
88
21
  # Guardfile.
89
22
  #
@@ -98,22 +31,11 @@ module Guard
98
31
  # @param [Array<Symbol>] events the events to register
99
32
  #
100
33
  def self.add_callback(listener, guard_plugin, events)
101
- _events = events.is_a?(Array) ? events : [events]
102
- _events.each do |event|
34
+ Array(events).each do |event|
103
35
  callbacks[[guard_plugin, event]] << listener
104
36
  end
105
37
  end
106
38
 
107
- # Checks if a callback has been registered.
108
- #
109
- # @param [Block] listener the listener to notify
110
- # @param [Guard::Plugin] guard_plugin the Guard plugin to add the callback
111
- # @param [Symbol] event the event to look for
112
- #
113
- def self.has_callback?(listener, guard_plugin, event)
114
- callbacks[[guard_plugin, event]].include?(listener)
115
- end
116
-
117
39
  # Notify a callback.
118
40
  #
119
41
  # @param [Guard::Plugin] guard_plugin the Guard plugin to add the callback
@@ -132,6 +54,59 @@ module Guard
132
54
  @callbacks = nil
133
55
  end
134
56
 
57
+ # When event is a Symbol, {#hook} will generate a hook name
58
+ # by concatenating the method name from where {#hook} is called
59
+ # with the given Symbol.
60
+ #
61
+ # @example Add a hook with a Symbol
62
+ #
63
+ # def run_all
64
+ # hook :foo
65
+ # end
66
+ #
67
+ # Here, when {Guard::Plugin::Base#run_all} is called, {#hook} will notify
68
+ # callbacks registered for the "run_all_foo" event.
69
+ #
70
+ # When event is a String, {#hook} will directly turn the String
71
+ # into a Symbol.
72
+ #
73
+ # @example Add a hook with a String
74
+ #
75
+ # def run_all
76
+ # hook "foo_bar"
77
+ # end
78
+ #
79
+ # When {Guard::Plugin::Base#run_all} is called, {#hook} will notify
80
+ # callbacks registered for the "foo_bar" event.
81
+ #
82
+ # @param [Symbol, String] event the name of the Guard event
83
+ # @param [Array] args the parameters are passed as is to the callbacks
84
+ # registered for the given event.
85
+ #
86
+ def hook(event, *args)
87
+ hook_name = if event.is_a? Symbol
88
+ calling_method = caller[0][/`([^']*)'/, 1]
89
+ "#{ calling_method }_#{ event }"
90
+ else
91
+ event
92
+ end
93
+
94
+ ::Guard::UI.debug "Hook :#{ hook_name } executed for #{ self.class }"
95
+
96
+ Hooker.notify(self, hook_name.to_sym, *args)
97
+ end
98
+
99
+ private
100
+
101
+ # Add all the Guard::Plugin's callbacks to the global @callbacks array
102
+ # that's used by Guard to know which callbacks to notify.
103
+ #
104
+ def _register_callbacks
105
+ callbacks.each do |callback|
106
+ Hooker.add_callback(callback[:listener], self, callback[:events])
107
+ end
108
+ end
109
+
135
110
  end
136
111
  end
137
112
  end
data/lib/guard/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Guard
2
- VERSION = '2.2.4'
2
+ VERSION = '2.2.5'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.4
4
+ version: 2.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thibaud Guillaume-Gentil
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-17 00:00:00.000000000 Z
11
+ date: 2013-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -193,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
193
193
  version: '0'
194
194
  requirements: []
195
195
  rubyforge_project:
196
- rubygems_version: 2.1.10
196
+ rubygems_version: 2.0.14
197
197
  signing_key:
198
198
  specification_version: 4
199
199
  summary: Guard keeps an eye on your file modifications