guard 0.7.0.rc1 → 0.7.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,2 +1,2 @@
1
- # A sample Guardfile
2
- # More info at https://github.com/guard/guard#readme
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
data/lib/guard/ui.rb CHANGED
@@ -1,110 +1,110 @@
1
- module Guard
2
- module UI
3
-
4
- ANSI_ESCAPE_BRIGHT = "1"
5
-
6
- ANSI_ESCAPE_BLACK = "30"
7
- ANSI_ESCAPE_RED = "31"
8
- ANSI_ESCAPE_GREEN = "32"
9
- ANSI_ESCAPE_YELLOW = "33"
10
- ANSI_ESCAPE_BLUE = "34"
11
- ANSI_ESCAPE_MAGENTA = "35"
12
- ANSI_ESCAPE_CYAN = "36"
13
- ANSI_ESCAPE_WHITE = "37"
14
-
15
- ANSI_ESCAPE_BGBLACK = "40"
16
- ANSI_ESCAPE_BGRED = "41"
17
- ANSI_ESCAPE_BGGREEN = "42"
18
- ANSI_ESCAPE_BGYELLOW = "43"
19
- ANSI_ESCAPE_BGBLUE = "44"
20
- ANSI_ESCAPE_BGMAGENTA = "45"
21
- ANSI_ESCAPE_BGCYAN = "46"
22
- ANSI_ESCAPE_BGWHITE = "47"
23
-
24
- class << self
25
-
26
- color_enabled = nil
27
-
28
- def info(message, options = {})
29
- unless ENV["GUARD_ENV"] == "test"
30
- reset_line if options[:reset]
31
- puts color(message) if message != ''
32
- end
33
- end
34
-
35
- def error(message, options={})
36
- unless ENV["GUARD_ENV"] == "test"
37
- reset_line if options[:reset]
38
- puts color('ERROR: ', :red) + message
39
- end
40
- end
41
-
42
- def deprecation(message, options = {})
43
- unless ENV["GUARD_ENV"] == "test"
44
- reset_line if options[:reset]
45
- puts color('DEPRECATION: ', :red) + message
46
- end
47
- end
48
-
49
- def debug(message, options={})
50
- unless ENV["GUARD_ENV"] == "test"
51
- reset_line if options[:reset]
52
- puts color("DEBUG (#{Time.now.strftime('%T')}): ", :yellow) + message if ::Guard.options && ::Guard.options[:debug]
53
- end
54
- end
55
-
56
- def reset_line
57
- print(color_enabled? ? "\r\e[0m" : "\r\n")
58
- end
59
-
60
- def clear
61
- system("clear;")
62
- end
63
-
64
- private
65
-
66
- # @deprecated
67
- def reset_color(text)
68
- deprecation('UI.reset_color(text) is deprecated, please use color(text, "") instead.')
69
- color(text, "")
70
- end
71
-
72
- def color(text, *color_options)
73
- color_code = ""
74
- color_options.each do |color_option|
75
- color_option = color_option.to_s
76
- if color_option != ""
77
- if !(color_option =~ /\d+/)
78
- color_option = const_get("ANSI_ESCAPE_#{color_option.upcase}")
79
- end
80
- color_code += ";" + color_option
81
- end
82
- end
83
- color_enabled? ? "\e[0#{color_code}m#{text}\e[0m" : text
84
- end
85
-
86
- def color_enabled?
87
- if @color_enabled.nil?
88
- if RbConfig::CONFIG['target_os'] =~ /mswin|mingw/i
89
- if ENV['ANSICON']
90
- @color_enabled = true
91
- else
92
- begin
93
- require 'rubygems' unless ENV['NO_RUBYGEMS']
94
- require 'Win32/Console/ANSI'
95
- @color_enabled = true
96
- rescue LoadError
97
- @color_enabled = false
98
- info "You must 'gem install win32console' to use color on Windows"
99
- end
100
- end
101
- else
102
- @color_enabled = true
103
- end
104
- end
105
- @color_enabled
106
- end
107
-
108
- end
109
- end
110
- end
1
+ module Guard
2
+ module UI
3
+
4
+ ANSI_ESCAPE_BRIGHT = "1"
5
+
6
+ ANSI_ESCAPE_BLACK = "30"
7
+ ANSI_ESCAPE_RED = "31"
8
+ ANSI_ESCAPE_GREEN = "32"
9
+ ANSI_ESCAPE_YELLOW = "33"
10
+ ANSI_ESCAPE_BLUE = "34"
11
+ ANSI_ESCAPE_MAGENTA = "35"
12
+ ANSI_ESCAPE_CYAN = "36"
13
+ ANSI_ESCAPE_WHITE = "37"
14
+
15
+ ANSI_ESCAPE_BGBLACK = "40"
16
+ ANSI_ESCAPE_BGRED = "41"
17
+ ANSI_ESCAPE_BGGREEN = "42"
18
+ ANSI_ESCAPE_BGYELLOW = "43"
19
+ ANSI_ESCAPE_BGBLUE = "44"
20
+ ANSI_ESCAPE_BGMAGENTA = "45"
21
+ ANSI_ESCAPE_BGCYAN = "46"
22
+ ANSI_ESCAPE_BGWHITE = "47"
23
+
24
+ class << self
25
+
26
+ color_enabled = nil
27
+
28
+ def info(message, options = {})
29
+ unless ENV["GUARD_ENV"] == "test"
30
+ reset_line if options[:reset]
31
+ puts color(message) if message != ''
32
+ end
33
+ end
34
+
35
+ def error(message, options={})
36
+ unless ENV["GUARD_ENV"] == "test"
37
+ reset_line if options[:reset]
38
+ puts color('ERROR: ', :red) + message
39
+ end
40
+ end
41
+
42
+ def deprecation(message, options = {})
43
+ unless ENV["GUARD_ENV"] == "test"
44
+ reset_line if options[:reset]
45
+ puts color('DEPRECATION: ', :red) + message
46
+ end
47
+ end
48
+
49
+ def debug(message, options={})
50
+ unless ENV["GUARD_ENV"] == "test"
51
+ reset_line if options[:reset]
52
+ puts color("DEBUG (#{Time.now.strftime('%T')}): ", :yellow) + message if ::Guard.options && ::Guard.options[:debug]
53
+ end
54
+ end
55
+
56
+ def reset_line
57
+ print(color_enabled? ? "\r\e[0m" : "\r\n")
58
+ end
59
+
60
+ def clear
61
+ system("clear;")
62
+ end
63
+
64
+ private
65
+
66
+ # @deprecated
67
+ def reset_color(text)
68
+ deprecation('UI.reset_color(text) is deprecated, please use color(text, "") instead.')
69
+ color(text, "")
70
+ end
71
+
72
+ def color(text, *color_options)
73
+ color_code = ""
74
+ color_options.each do |color_option|
75
+ color_option = color_option.to_s
76
+ if color_option != ""
77
+ if !(color_option =~ /\d+/)
78
+ color_option = const_get("ANSI_ESCAPE_#{color_option.upcase}")
79
+ end
80
+ color_code += ";" + color_option
81
+ end
82
+ end
83
+ color_enabled? ? "\e[0#{color_code}m#{text}\e[0m" : text
84
+ end
85
+
86
+ def color_enabled?
87
+ if @color_enabled.nil?
88
+ if RbConfig::CONFIG['target_os'] =~ /mswin|mingw/i
89
+ if ENV['ANSICON']
90
+ @color_enabled = true
91
+ else
92
+ begin
93
+ require 'rubygems' unless ENV['NO_RUBYGEMS']
94
+ require 'Win32/Console/ANSI'
95
+ @color_enabled = true
96
+ rescue LoadError
97
+ @color_enabled = false
98
+ info "You must 'gem install win32console' to use color on Windows"
99
+ end
100
+ end
101
+ else
102
+ @color_enabled = true
103
+ end
104
+ end
105
+ @color_enabled
106
+ end
107
+
108
+ end
109
+ end
110
+ end
data/lib/guard/version.rb CHANGED
@@ -1,3 +1,3 @@
1
- module Guard
2
- VERSION = "0.7.0.rc1" unless defined? Guard::VERSION
3
- end
1
+ module Guard
2
+ VERSION = "0.7.0" unless defined? Guard::VERSION
3
+ end
data/lib/guard/watcher.rb CHANGED
@@ -1,66 +1,66 @@
1
- module Guard
2
- class Watcher
3
- attr_accessor :pattern, :action
4
-
5
- def initialize(pattern, action = nil)
6
- @pattern, @action = pattern, action
7
- @@warning_printed ||= false
8
-
9
- # deprecation warning
10
- if @pattern.is_a?(String) && @pattern =~ /(^(\^))|(>?(\\\.)|(\.\*))|(\(.*\))|(\[.*\])|(\$$)/
11
- unless @@warning_printed
12
- UI.info "*"*20 + "\nDEPRECATION WARNING!\n" + "*"*20
13
- UI.info "You have strings in your Guardfile's watch patterns that seem to represent regexps.\nGuard matchs String with == and Regexp with Regexp#match.\nYou should either use plain String (without Regexp special characters) or real Regexp.\n"
14
- @@warning_printed = true
15
- end
16
- UI.info "\"#{@pattern}\" has been converted to #{Regexp.new(@pattern).inspect}\n"
17
- @pattern = Regexp.new(@pattern)
18
- end
19
- end
20
-
21
- def self.match_files(guard, files)
22
- guard.watchers.inject([]) do |paths, watcher|
23
- files.each do |file|
24
- if matches = watcher.match_file?(file)
25
- if watcher.action
26
- result = watcher.call_action(matches)
27
- paths << Array(result) if result.respond_to?(:empty?) && !result.empty?
28
- else
29
- paths << matches[0]
30
- end
31
- end
32
- end
33
- paths.flatten.map { |p| p.to_s }
34
- end
35
- end
36
-
37
- def self.match_files?(guards, files)
38
- guards.any? do |guard|
39
- guard.watchers.any? do |watcher|
40
- files.any? { |file| watcher.match_file?(file) }
41
- end
42
- end
43
- end
44
-
45
- def match_file?(file)
46
- if @pattern.is_a?(Regexp)
47
- file.match(@pattern)
48
- else
49
- file == @pattern ? [file] : nil
50
- end
51
- end
52
-
53
- def self.match_guardfile?(files)
54
- files.any? { |file| "#{Dir.pwd}/#{file}" == Dsl.guardfile_path }
55
- end
56
-
57
- def call_action(matches)
58
- begin
59
- @action.arity > 0 ? @action.call(matches) : @action.call
60
- rescue Exception => e
61
- UI.error "Problem with watch action!\n#{e.message}\n\n#{e.backtrace.join("\n")}"
62
- end
63
- end
64
-
65
- end
66
- end
1
+ module Guard
2
+ class Watcher
3
+ attr_accessor :pattern, :action
4
+
5
+ def initialize(pattern, action = nil)
6
+ @pattern, @action = pattern, action
7
+ @@warning_printed ||= false
8
+
9
+ # deprecation warning
10
+ if @pattern.is_a?(String) && @pattern =~ /(^(\^))|(>?(\\\.)|(\.\*))|(\(.*\))|(\[.*\])|(\$$)/
11
+ unless @@warning_printed
12
+ UI.info "*"*20 + "\nDEPRECATION WARNING!\n" + "*"*20
13
+ UI.info "You have strings in your Guardfile's watch patterns that seem to represent regexps.\nGuard matchs String with == and Regexp with Regexp#match.\nYou should either use plain String (without Regexp special characters) or real Regexp.\n"
14
+ @@warning_printed = true
15
+ end
16
+ UI.info "\"#{@pattern}\" has been converted to #{Regexp.new(@pattern).inspect}\n"
17
+ @pattern = Regexp.new(@pattern)
18
+ end
19
+ end
20
+
21
+ def self.match_files(guard, files)
22
+ guard.watchers.inject([]) do |paths, watcher|
23
+ files.each do |file|
24
+ if matches = watcher.match_file?(file)
25
+ if watcher.action
26
+ result = watcher.call_action(matches)
27
+ paths << Array(result) if result.respond_to?(:empty?) && !result.empty?
28
+ else
29
+ paths << matches[0]
30
+ end
31
+ end
32
+ end
33
+ paths.flatten.map { |p| p.to_s }
34
+ end
35
+ end
36
+
37
+ def self.match_files?(guards, files)
38
+ guards.any? do |guard|
39
+ guard.watchers.any? do |watcher|
40
+ files.any? { |file| watcher.match_file?(file) }
41
+ end
42
+ end
43
+ end
44
+
45
+ def match_file?(file)
46
+ if @pattern.is_a?(Regexp)
47
+ file.match(@pattern)
48
+ else
49
+ file == @pattern ? [file] : nil
50
+ end
51
+ end
52
+
53
+ def self.match_guardfile?(files)
54
+ files.any? { |file| "#{Dir.pwd}/#{file}" == Dsl.guardfile_path }
55
+ end
56
+
57
+ def call_action(matches)
58
+ begin
59
+ @action.arity > 0 ? @action.call(matches) : @action.call
60
+ rescue Exception => e
61
+ UI.error "Problem with watch action!\n#{e.message}\n\n#{e.backtrace.join("\n")}"
62
+ end
63
+ end
64
+
65
+ end
66
+ end
data/man/guard.1 CHANGED
@@ -1,93 +1,93 @@
1
- .\" generated with Ronn/v0.7.3
2
- .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
- .
4
- .TH "GUARD" "1" "September 2011" "" ""
5
- .
6
- .SH "NAME"
7
- \fBguard\fR \- Guard keeps an eye on your file modifications\.
8
- .
9
- .SH "DESCRIPTION"
10
- Guard is a command line tool that easily handle events on files modifications\.
11
- .
12
- .SH "SYNOPSIS"
13
- \fBguard <COMMAND> <OPTIONS>\fR
14
- .
15
- .SH "COMMANDS"
16
- .
17
- .SS "start"
18
- Starts Guard\. This is the default command if none is provided\.
19
- .
20
- .P
21
- The following options are available:
22
- .
23
- .P
24
- \fB\-c\fR, \fB\-\-clear\fR Clears the Shell after each change\.
25
- .
26
- .P
27
- \fB\-n\fR, \fB\-\-notify\fR \fIFLAG\fR Disable notifications (Growl or Libnotify depending on your system)\. Notifications can be disabled globally by setting a GUARD_NOTIFY environment variable to false\. FLAG can be \fBtrue\fR/\fBfalse\fR or \fBt\fR/\fBf\fR\.
28
- .
29
- .P
30
- \fB\-d\fR, \fB\-\-debug\fR Runs Guard in debug mode\.
31
- .
32
- .P
33
- \fB\-g\fR, \fB\-\-group\fR \fIGROUP1\fR \fIGROUP2\fR\.\.\. Runs only the groups specified by GROUP1, GROUP2 etc\. Groups name should be separated by spaces\. Guards that don\'t belong to a group are considered global and are always run\.
34
- .
35
- .P
36
- \fB\-w\fR, \fB\-\-watchdir\fR \fIPATH\fR
37
- .
38
- .P
39
- Tells Guard to watch PATH instead of \fB\./\fR\.
40
- .
41
- .P
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
- .
44
- .SS "init <a href=\"guard\.html\">GUARD</a>"
45
- If no Guardfile is present in the current directory, creates an empty Guardfile\.
46
- .
47
- .P
48
- If \fIGUARD\fR is present, add its default Guardfile configuration to the current Guardfile\. Note that \fIGUARD\fR is the guard\'s name without the \fBguard\-\fR prefix\. For instance to initialize guard\-rspec, run \fBguard init rspec\fR\.
49
- .
50
- .SS "list"
51
- Lists guards that can be used with the \fBinit\fR command\.
52
- .
53
- .SS "\-T, show"
54
- List defined groups and guards for the current Guardfile\.
55
- .
56
- .SS "\-h, help [COMMAND]"
57
- List all of Guard\'s available commands\.
58
- .
59
- .P
60
- If \fICOMMAND\fR is given, displays a specific help for \fITASK\fR\.
61
- .
62
- .SH "EXAMPLES"
63
- Initialize Guard and a specific guard at the same time:
64
- .
65
- .P
66
- \fB[bundle exec] guard init [rspec]\fR
67
- .
68
- .P
69
- Run Guard:
70
- .
71
- .P
72
- \fB[bundle exec] guard [start] \-\-watchdir ~/dev \-\-guardfile ~/env/Guardfile \-\-clear \-\-group backend frontend \-\-notify false \-\-debug\fR
73
- .
74
- .P
75
- or in a more concise way:
76
- .
77
- .P
78
- \fB[bundle exec] guard [start] \-w ~/dev \-G ~/env/Guardfile \-c \-g backend frontend \-n f \-d\fR
79
- .
80
- .SH "AUTHORS / CONTRIBUTORS"
81
- Thibaud Guillaume\-Gentil is the main author\.
82
- .
83
- .P
84
- A list of contributors based on all commits can be found here: https://github\.com/guard/guard/contributors
85
- .
86
- .P
87
- For an exhaustive list of all the contributors, please see the CHANGELOG: https://github\.com/guard/guard/blob/master/CHANGELOG\.md
88
- .
89
- .P
90
- This manual has been written by Remy Coutable\.
91
- .
92
- .SH "WWW"
93
- https://github\.com/guard/guard
1
+ .\" generated with Ronn/v0.7.3
2
+ .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
+ .
4
+ .TH "GUARD" "1" "September 2011" "" ""
5
+ .
6
+ .SH "NAME"
7
+ \fBguard\fR \- Guard keeps an eye on your file modifications\.
8
+ .
9
+ .SH "DESCRIPTION"
10
+ Guard is a command line tool that easily handle events on files modifications\.
11
+ .
12
+ .SH "SYNOPSIS"
13
+ \fBguard <COMMAND> <OPTIONS>\fR
14
+ .
15
+ .SH "COMMANDS"
16
+ .
17
+ .SS "start"
18
+ Starts Guard\. This is the default command if none is provided\.
19
+ .
20
+ .P
21
+ The following options are available:
22
+ .
23
+ .P
24
+ \fB\-c\fR, \fB\-\-clear\fR Clears the Shell after each change\.
25
+ .
26
+ .P
27
+ \fB\-n\fR, \fB\-\-notify\fR \fIFLAG\fR Disable notifications (Growl or Libnotify depending on your system)\. Notifications can be disabled globally by setting a GUARD_NOTIFY environment variable to false\. FLAG can be \fBtrue\fR/\fBfalse\fR or \fBt\fR/\fBf\fR\.
28
+ .
29
+ .P
30
+ \fB\-d\fR, \fB\-\-debug\fR Runs Guard in debug mode\.
31
+ .
32
+ .P
33
+ \fB\-g\fR, \fB\-\-group\fR \fIGROUP1\fR \fIGROUP2\fR\.\.\. Runs only the groups specified by GROUP1, GROUP2 etc\. Groups name should be separated by spaces\. Guards that don\'t belong to a group are considered global and are always run\.
34
+ .
35
+ .P
36
+ \fB\-w\fR, \fB\-\-watchdir\fR \fIPATH\fR
37
+ .
38
+ .P
39
+ Tells Guard to watch PATH instead of \fB\./\fR\.
40
+ .
41
+ .P
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
+ .
44
+ .SS "init <a href=\"guard\.html\">GUARD</a>"
45
+ If no Guardfile is present in the current directory, creates an empty Guardfile\.
46
+ .
47
+ .P
48
+ If \fIGUARD\fR is present, add its default Guardfile configuration to the current Guardfile\. Note that \fIGUARD\fR is the guard\'s name without the \fBguard\-\fR prefix\. For instance to initialize guard\-rspec, run \fBguard init rspec\fR\.
49
+ .
50
+ .SS "list"
51
+ Lists guards that can be used with the \fBinit\fR command\.
52
+ .
53
+ .SS "\-T, show"
54
+ List defined groups and guards for the current Guardfile\.
55
+ .
56
+ .SS "\-h, help [COMMAND]"
57
+ List all of Guard\'s available commands\.
58
+ .
59
+ .P
60
+ If \fICOMMAND\fR is given, displays a specific help for \fITASK\fR\.
61
+ .
62
+ .SH "EXAMPLES"
63
+ Initialize Guard and a specific guard at the same time:
64
+ .
65
+ .P
66
+ \fB[bundle exec] guard init [rspec]\fR
67
+ .
68
+ .P
69
+ Run Guard:
70
+ .
71
+ .P
72
+ \fB[bundle exec] guard [start] \-\-watchdir ~/dev \-\-guardfile ~/env/Guardfile \-\-clear \-\-group backend frontend \-\-notify false \-\-debug\fR
73
+ .
74
+ .P
75
+ or in a more concise way:
76
+ .
77
+ .P
78
+ \fB[bundle exec] guard [start] \-w ~/dev \-G ~/env/Guardfile \-c \-g backend frontend \-n f \-d\fR
79
+ .
80
+ .SH "AUTHORS / CONTRIBUTORS"
81
+ Thibaud Guillaume\-Gentil is the main author\.
82
+ .
83
+ .P
84
+ A list of contributors based on all commits can be found here: https://github\.com/guard/guard/contributors
85
+ .
86
+ .P
87
+ For an exhaustive list of all the contributors, please see the CHANGELOG: https://github\.com/guard/guard/blob/master/CHANGELOG\.md
88
+ .
89
+ .P
90
+ This manual has been written by Remy Coutable\.
91
+ .
92
+ .SH "WWW"
93
+ https://github\.com/guard/guard