guard 2.10.5 → 2.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/guard.rb +0 -3
- data/lib/guard/aruba_adapter.rb +6 -6
- data/lib/guard/cli.rb +5 -0
- data/lib/guard/commander.rb +1 -1
- data/lib/guard/commands/all.rb +2 -2
- data/lib/guard/commands/notification.rb +1 -1
- data/lib/guard/commands/reload.rb +2 -2
- data/lib/guard/commands/show.rb +1 -1
- data/lib/guard/deprecated/evaluator.rb +3 -1
- data/lib/guard/deprecated/guard.rb +57 -2
- data/lib/guard/dsl.rb +2 -3
- data/lib/guard/dsl_describer.rb +8 -20
- data/lib/guard/guardfile/evaluator.rb +5 -5
- data/lib/guard/guardfile/generator.rb +3 -3
- data/lib/guard/internals/debugging.rb +5 -5
- data/lib/guard/internals/session.rb +19 -8
- data/lib/guard/internals/state.rb +0 -13
- data/lib/guard/jobs/pry_wrapper.rb +5 -5
- data/lib/guard/notifier.rb +43 -219
- data/lib/guard/plugin_util.rb +1 -1
- data/lib/guard/terminal.rb +3 -2
- data/lib/guard/ui.rb +7 -2
- data/lib/guard/version.rb +1 -1
- data/lib/guard/watcher.rb +3 -3
- metadata +30 -15
- data/lib/guard/notifier/detected.rb +0 -87
- data/lib/guard/notifiers/base.rb +0 -221
- data/lib/guard/notifiers/emacs.rb +0 -99
- data/lib/guard/notifiers/file_notifier.rb +0 -54
- data/lib/guard/notifiers/gntp.rb +0 -111
- data/lib/guard/notifiers/growl.rb +0 -104
- data/lib/guard/notifiers/libnotify.rb +0 -86
- data/lib/guard/notifiers/notifysend.rb +0 -110
- data/lib/guard/notifiers/rb_notifu.rb +0 -100
- data/lib/guard/notifiers/terminal_notifier.rb +0 -90
- data/lib/guard/notifiers/terminal_title.rb +0 -31
- data/lib/guard/notifiers/tmux.rb +0 -335
- data/lib/guard/sheller.rb +0 -143
data/lib/guard/sheller.rb
DELETED
@@ -1,143 +0,0 @@
|
|
1
|
-
require "open3"
|
2
|
-
|
3
|
-
module Guard
|
4
|
-
# The Guard sheller abstract the actual subshell
|
5
|
-
# calls and allow easier stubbing.
|
6
|
-
#
|
7
|
-
class Sheller
|
8
|
-
attr_reader :status
|
9
|
-
|
10
|
-
# Creates a new Guard::Sheller object.
|
11
|
-
#
|
12
|
-
# @param [String] args a command to run in a subshell
|
13
|
-
# @param [Array<String>] args an array of command parts to run in a subshell
|
14
|
-
# @param [*String] args a list of command parts to run in a subshell
|
15
|
-
#
|
16
|
-
def initialize(*args)
|
17
|
-
fail ArgumentError, "no command given" if args.empty?
|
18
|
-
@command = args
|
19
|
-
@ran = false
|
20
|
-
end
|
21
|
-
|
22
|
-
# Shortcut for new(command).run
|
23
|
-
#
|
24
|
-
def self.run(*args)
|
25
|
-
new(*args).run
|
26
|
-
end
|
27
|
-
|
28
|
-
# Shortcut for new(command).run.stdout
|
29
|
-
#
|
30
|
-
def self.stdout(*args)
|
31
|
-
new(*args).stdout
|
32
|
-
end
|
33
|
-
|
34
|
-
# Shortcut for new(command).run.stderr
|
35
|
-
#
|
36
|
-
def self.stderr(*args)
|
37
|
-
new(*args).stderr
|
38
|
-
end
|
39
|
-
|
40
|
-
# Runs the command.
|
41
|
-
#
|
42
|
-
# @return [Boolean] whether or not the command succeeded.
|
43
|
-
#
|
44
|
-
def run
|
45
|
-
unless ran?
|
46
|
-
status, output, errors = self.class._system_with_capture(*@command)
|
47
|
-
@ran = true
|
48
|
-
@stdout = output
|
49
|
-
@stderr = errors
|
50
|
-
@status = status
|
51
|
-
end
|
52
|
-
|
53
|
-
ok?
|
54
|
-
end
|
55
|
-
|
56
|
-
# Returns true if the command has already been run, false otherwise.
|
57
|
-
#
|
58
|
-
# @return [Boolean] whether or not the command has already been run
|
59
|
-
#
|
60
|
-
def ran?
|
61
|
-
@ran
|
62
|
-
end
|
63
|
-
|
64
|
-
# Returns true if the command succeeded, false otherwise.
|
65
|
-
#
|
66
|
-
# @return [Boolean] whether or not the command succeeded
|
67
|
-
#
|
68
|
-
def ok?
|
69
|
-
run unless ran?
|
70
|
-
|
71
|
-
@status && @status.success?
|
72
|
-
end
|
73
|
-
|
74
|
-
# Returns the command's output.
|
75
|
-
#
|
76
|
-
# @return [String] the command output
|
77
|
-
#
|
78
|
-
def stdout
|
79
|
-
run unless ran?
|
80
|
-
|
81
|
-
@stdout
|
82
|
-
end
|
83
|
-
|
84
|
-
# Returns the command's error output.
|
85
|
-
#
|
86
|
-
# @return [String] the command output
|
87
|
-
#
|
88
|
-
def stderr
|
89
|
-
run unless ran?
|
90
|
-
|
91
|
-
@stderr
|
92
|
-
end
|
93
|
-
|
94
|
-
# No output capturing
|
95
|
-
#
|
96
|
-
# NOTE: `$stdout.puts system('cls')` on Windows won't work like
|
97
|
-
# it does for on systems with ansi terminals, so we need to be
|
98
|
-
# able to call Kernel.system directly.
|
99
|
-
def self.system(*args)
|
100
|
-
_system_with_no_capture(*args)
|
101
|
-
end
|
102
|
-
|
103
|
-
def self._system_with_no_capture(*args)
|
104
|
-
Kernel.system(*args)
|
105
|
-
result = $?
|
106
|
-
errors = (result == 0) || "Guard failed to run: #{args.inspect}"
|
107
|
-
[result, nil, errors]
|
108
|
-
end
|
109
|
-
|
110
|
-
def self._system_with_capture(*args)
|
111
|
-
# We use popen3, because it started working on recent versions
|
112
|
-
# of JRuby, while JRuby doesn't handle options to Kernel.system
|
113
|
-
args = _shellize_if_needed(args)
|
114
|
-
|
115
|
-
stdout, stderr, status = nil
|
116
|
-
Open3.popen3(*args) do |_stdin, _stdout, _stderr, _thr|
|
117
|
-
stdout = _stdout.read
|
118
|
-
stderr = _stderr.read
|
119
|
-
status = _thr.value
|
120
|
-
end
|
121
|
-
|
122
|
-
[status, stdout, stderr]
|
123
|
-
rescue Errno::ENOENT, IOError => e
|
124
|
-
[nil, nil, "Guard::Sheller failed (#{e.inspect})"]
|
125
|
-
end
|
126
|
-
|
127
|
-
# Only needed on JRUBY, because MRI properly detects ';' and metachars
|
128
|
-
def self._shellize_if_needed(args)
|
129
|
-
return args unless RUBY_PLATFORM == "java"
|
130
|
-
return args unless args.size == 1
|
131
|
-
return args unless /[;<>]/ =~ args.first
|
132
|
-
|
133
|
-
# NOTE: guard basically only uses UNIX commands anyway
|
134
|
-
# while JRuby doesn't support options to Kernel.system and doesn't
|
135
|
-
# automatically shell when there's a metacharacter in the command
|
136
|
-
#
|
137
|
-
# So ... I'm assuming /bin/sh exists - if not, PRs are welcome,
|
138
|
-
# because I have no clue what to do if /bin/sh doesn't exist.
|
139
|
-
# (use ENV["RUBYSHELL"] ? Detect cmd.exe ?)
|
140
|
-
["/bin/sh", "-c", args.first]
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|