guard 0.7.0 → 0.8.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.
- data/CHANGELOG.md +23 -1
- data/README.md +173 -226
- data/bin/guard +1 -1
- data/lib/guard.rb +243 -45
- data/lib/guard/cli.rb +135 -46
- data/lib/guard/dsl.rb +260 -38
- data/lib/guard/dsl_describer.rb +36 -4
- data/lib/guard/group.rb +22 -0
- data/lib/guard/guard.rb +53 -13
- data/lib/guard/hook.rb +61 -15
- data/lib/guard/interactor.rb +52 -14
- data/lib/guard/listener.rb +181 -26
- data/lib/guard/listeners/darwin.rb +26 -7
- data/lib/guard/listeners/linux.rb +32 -8
- data/lib/guard/listeners/polling.rb +23 -5
- data/lib/guard/listeners/windows.rb +25 -6
- data/lib/guard/notifier.rb +78 -3
- data/lib/guard/ui.rb +125 -47
- data/lib/guard/version.rb +4 -1
- data/lib/guard/watcher.rb +48 -4
- data/man/guard.1 +1 -1
- data/man/guard.1.html +1 -1
- metadata +36 -13
data/lib/guard/version.rb
CHANGED
data/lib/guard/watcher.rb
CHANGED
@@ -1,7 +1,18 @@
|
|
1
1
|
module Guard
|
2
|
+
|
3
|
+
# The watcher defines a RegExp that will be matched against file system modifications.
|
4
|
+
# When a watcher matches a change, an optional action block is executed to enable
|
5
|
+
# processing the file system change result.
|
6
|
+
#
|
2
7
|
class Watcher
|
8
|
+
|
3
9
|
attr_accessor :pattern, :action
|
4
10
|
|
11
|
+
# Initialize a file watcher.
|
12
|
+
#
|
13
|
+
# @param [String, Regexp] pattern the pattern to be watched by the guard
|
14
|
+
# @param [Block] action the action to execute before passing the result to the Guard
|
15
|
+
#
|
5
16
|
def initialize(pattern, action = nil)
|
6
17
|
@pattern, @action = pattern, action
|
7
18
|
@@warning_printed ||= false
|
@@ -10,14 +21,25 @@ module Guard
|
|
10
21
|
if @pattern.is_a?(String) && @pattern =~ /(^(\^))|(>?(\\\.)|(\.\*))|(\(.*\))|(\[.*\])|(\$$)/
|
11
22
|
unless @@warning_printed
|
12
23
|
UI.info "*"*20 + "\nDEPRECATION WARNING!\n" + "*"*20
|
13
|
-
UI.info
|
24
|
+
UI.info <<-MSG
|
25
|
+
You have a string in your Guardfile watch patterns that seem to represent a Regexp.
|
26
|
+
Guard matches String with == and Regexp with Regexp#match.
|
27
|
+
You should either use plain String (without Regexp special characters) or real Regexp.
|
28
|
+
MSG
|
14
29
|
@@warning_printed = true
|
15
30
|
end
|
16
|
-
|
31
|
+
|
32
|
+
UI.info "\"#{@pattern}\" has been converted to #{ Regexp.new(@pattern).inspect }\n"
|
17
33
|
@pattern = Regexp.new(@pattern)
|
18
34
|
end
|
19
35
|
end
|
20
36
|
|
37
|
+
# Finds the files that matches a Guard.
|
38
|
+
#
|
39
|
+
# @param [Guard::Guard] guard the guard which watchers are used
|
40
|
+
# @param [Array<String>] files the changed files
|
41
|
+
# @return [Array<String>] the matched files
|
42
|
+
#
|
21
43
|
def self.match_files(guard, files)
|
22
44
|
guard.watchers.inject([]) do |paths, watcher|
|
23
45
|
files.each do |file|
|
@@ -30,10 +52,17 @@ module Guard
|
|
30
52
|
end
|
31
53
|
end
|
32
54
|
end
|
55
|
+
|
33
56
|
paths.flatten.map { |p| p.to_s }
|
34
57
|
end
|
35
58
|
end
|
36
59
|
|
60
|
+
# Test if a file would be matched by any of the Guards watchers.
|
61
|
+
#
|
62
|
+
# @param [Array<Guard::Guard>] guards the guards to use the watchers from
|
63
|
+
# @param [Array<String>] files the files to test
|
64
|
+
# @return [Boolean] Whether a file matches
|
65
|
+
#
|
37
66
|
def self.match_files?(guards, files)
|
38
67
|
guards.any? do |guard|
|
39
68
|
guard.watchers.any? do |watcher|
|
@@ -42,6 +71,11 @@ module Guard
|
|
42
71
|
end
|
43
72
|
end
|
44
73
|
|
74
|
+
# Test the watchers pattern against a file.
|
75
|
+
#
|
76
|
+
# @param [String] file the file to test
|
77
|
+
# @return [Boolean] whether the given file is matched
|
78
|
+
#
|
45
79
|
def match_file?(file)
|
46
80
|
if @pattern.is_a?(Regexp)
|
47
81
|
file.match(@pattern)
|
@@ -50,15 +84,25 @@ module Guard
|
|
50
84
|
end
|
51
85
|
end
|
52
86
|
|
87
|
+
# Test if any of the files is the Guardfile.
|
88
|
+
#
|
89
|
+
# @param [Array<String>] the files to test
|
90
|
+
# @return [Boolean] whether one of these files is the Guardfile
|
91
|
+
#
|
53
92
|
def self.match_guardfile?(files)
|
54
|
-
files.any? { |file| "#{Dir.pwd}/#{file}" == Dsl.guardfile_path }
|
93
|
+
files.any? { |file| "#{ Dir.pwd }/#{ file }" == Dsl.guardfile_path }
|
55
94
|
end
|
56
95
|
|
96
|
+
# Executes a watcher action.
|
97
|
+
#
|
98
|
+
# @param [String, MatchData] the matched path or the match from the Regex
|
99
|
+
# @return [String] the final paths
|
100
|
+
#
|
57
101
|
def call_action(matches)
|
58
102
|
begin
|
59
103
|
@action.arity > 0 ? @action.call(matches) : @action.call
|
60
104
|
rescue Exception => e
|
61
|
-
UI.error "Problem with watch action!\n#{e.message}\n\n#{e.backtrace.join("\n")}"
|
105
|
+
UI.error "Problem with watch action!\n#{ e.message }\n\n#{ e.backtrace.join("\n") }"
|
62
106
|
end
|
63
107
|
end
|
64
108
|
|
data/man/guard.1
CHANGED
@@ -41,7 +41,7 @@ Tells Guard to watch PATH instead of \fB\./\fR\.
|
|
41
41
|
.P
|
42
42
|
\fB\-G\fR, \fB\-\-guardfile\fR \fIFILE\fR Tells Guard to use FILE as its Guardfile instead of \fB\./Guardfile\fR or \fB~/\.Guardfile\fR\.
|
43
43
|
.
|
44
|
-
.SS "init
|
44
|
+
.SS "init [GUARD]"
|
45
45
|
If no Guardfile is present in the current directory, creates an empty Guardfile\.
|
46
46
|
.
|
47
47
|
.P
|
data/man/guard.1.html
CHANGED
@@ -112,7 +112,7 @@
|
|
112
112
|
<p><code>-G</code>, <code>--guardfile</code> <var>FILE</var>
|
113
113
|
Tells Guard to use FILE as its Guardfile instead of <code>./Guardfile</code> or <code>~/.Guardfile</code>.</p>
|
114
114
|
|
115
|
-
<h3 id="init-GUARD">init
|
115
|
+
<h3 id="init-GUARD-">init [GUARD]</h3>
|
116
116
|
|
117
117
|
<p>If no Guardfile is present in the current directory, creates an empty Guardfile.</p>
|
118
118
|
|
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.
|
4
|
+
version: 0.8.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-09-
|
12
|
+
date: 2011-09-28 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: thor
|
16
|
+
requirement: &70188716349680 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.14.6
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70188716349680
|
14
25
|
- !ruby/object:Gem::Dependency
|
15
26
|
name: bundler
|
16
|
-
requirement: &
|
27
|
+
requirement: &70188716356800 !ruby/object:Gem::Requirement
|
17
28
|
none: false
|
18
29
|
requirements:
|
19
30
|
- - ! '>='
|
@@ -21,10 +32,10 @@ dependencies:
|
|
21
32
|
version: '0'
|
22
33
|
type: :development
|
23
34
|
prerelease: false
|
24
|
-
version_requirements: *
|
35
|
+
version_requirements: *70188716356800
|
25
36
|
- !ruby/object:Gem::Dependency
|
26
37
|
name: rspec
|
27
|
-
requirement: &
|
38
|
+
requirement: &70188716375700 !ruby/object:Gem::Requirement
|
28
39
|
none: false
|
29
40
|
requirements:
|
30
41
|
- - ~>
|
@@ -32,10 +43,10 @@ dependencies:
|
|
32
43
|
version: 2.6.0
|
33
44
|
type: :development
|
34
45
|
prerelease: false
|
35
|
-
version_requirements: *
|
46
|
+
version_requirements: *70188716375700
|
36
47
|
- !ruby/object:Gem::Dependency
|
37
48
|
name: guard-rspec
|
38
|
-
requirement: &
|
49
|
+
requirement: &70188716379040 !ruby/object:Gem::Requirement
|
39
50
|
none: false
|
40
51
|
requirements:
|
41
52
|
- - ~>
|
@@ -43,18 +54,29 @@ dependencies:
|
|
43
54
|
version: 0.3.1
|
44
55
|
type: :development
|
45
56
|
prerelease: false
|
46
|
-
version_requirements: *
|
57
|
+
version_requirements: *70188716379040
|
47
58
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
49
|
-
requirement: &
|
59
|
+
name: yard
|
60
|
+
requirement: &70188716412560 !ruby/object:Gem::Requirement
|
50
61
|
none: false
|
51
62
|
requirements:
|
52
63
|
- - ~>
|
53
64
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.
|
55
|
-
type: :
|
65
|
+
version: 0.7.2
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70188716412560
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: kramdown
|
71
|
+
requirement: &70188716830780 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ~>
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 0.13.3
|
77
|
+
type: :development
|
56
78
|
prerelease: false
|
57
|
-
version_requirements: *
|
79
|
+
version_requirements: *70188716830780
|
58
80
|
description: Guard is a command line tool to easily handle events on file system modifications.
|
59
81
|
email:
|
60
82
|
- thibaud@thibaud.me
|
@@ -70,6 +92,7 @@ files:
|
|
70
92
|
- lib/guard/cli.rb
|
71
93
|
- lib/guard/dsl.rb
|
72
94
|
- lib/guard/dsl_describer.rb
|
95
|
+
- lib/guard/group.rb
|
73
96
|
- lib/guard/guard.rb
|
74
97
|
- lib/guard/hook.rb
|
75
98
|
- lib/guard/interactor.rb
|