snooper 2.1.5 → 2.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/snooper +16 -0
- data/data/_snooper.yaml +56 -0
- data/lib/snooper/snoop.rb +34 -10
- data/lib/snooper/version.rb +1 -1
- data/man/snooper-config.7.html +2 -2
- data/man/snooper.1 +7 -0
- data/man/snooper.1.html +12 -6
- data/man/snooper.1.ronn +12 -5
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f26141250e0dd9dbaca8220c7b6c43c56efd87e
|
4
|
+
data.tar.gz: 7778c3ee706a99d9dbd0e01c9dbb5606fec11c00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8eac98c5bc31e785dd73bd93171b3d6d9122bd1c33141c4ec3bb2eca4db4186eff521123d9a6c9cd3eaa118cf40ef45d8eb8156eeee5f803b7a5c9be58aa96c
|
7
|
+
data.tar.gz: 9d3aec46e183dc6670450db660d5e41a3b1d02c6668cdb2d97bf368f96424fc00c2376d8ddb06cc93c15df2041fe6afe992df53bad426e048e2f3c6b0e16dc89
|
data/bin/snooper
CHANGED
@@ -35,6 +35,22 @@ end
|
|
35
35
|
|
36
36
|
options = Snooper::Options.parse ARGV
|
37
37
|
|
38
|
+
if options.command == 'init'
|
39
|
+
require 'fileutils'
|
40
|
+
|
41
|
+
target = File.join Dir.pwd, ".snooper.yaml"
|
42
|
+
if File.exists? target
|
43
|
+
fatal_error "Configuration file '#{target}' already exists"
|
44
|
+
end
|
45
|
+
|
46
|
+
source = File.expand_path "../../data/_snooper.yaml", __FILE__
|
47
|
+
|
48
|
+
puts "Creating Snooper configuration file '#{target}'"
|
49
|
+
FileUtils::Verbose::cp source, target
|
50
|
+
|
51
|
+
exit 0
|
52
|
+
end
|
53
|
+
|
38
54
|
if options.config_path.nil?
|
39
55
|
fatal_error "couldn't find a config file. Did you miss a `--config=`?"
|
40
56
|
end
|
data/data/_snooper.yaml
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# Snooper is open source! - see LICENSE.md in source distributions for
|
2
|
+
# details. This file is released into the public domain and may be
|
3
|
+
# included in any software distribution, both commercial and non-comercial.
|
4
|
+
---
|
5
|
+
## Snooper Configuration File
|
6
|
+
|
7
|
+
## Base directory
|
8
|
+
#
|
9
|
+
# relative to this configuration file. All paths are relative to this directory.
|
10
|
+
base_path: .
|
11
|
+
|
12
|
+
## Command to execute
|
13
|
+
#
|
14
|
+
# When changes are noticed. This command is run in `base_path:`.
|
15
|
+
command: >
|
16
|
+
echo Edit '`command:`' in .snooper.yaml to change the command
|
17
|
+
that is run.
|
18
|
+
|
19
|
+
## Paths to Watch
|
20
|
+
#
|
21
|
+
# Resticts the paths in which changes are watched for. Add just the
|
22
|
+
# places you want to monitor here to prevent temporary files or build
|
23
|
+
# files triggering re-tests if you don't want them.
|
24
|
+
#paths: [bin, test, lib]
|
25
|
+
|
26
|
+
## Filters
|
27
|
+
#
|
28
|
+
# Restricts the types of files that trigger a re-test. If a file path
|
29
|
+
# matches any of these regular expressions then the command is
|
30
|
+
# executed.
|
31
|
+
filters:
|
32
|
+
# - \.rb$ # Ruby files
|
33
|
+
# - \.h$ # C/C++ header files
|
34
|
+
# - \.cpp$ # C++ files
|
35
|
+
# - \.c$ # C files
|
36
|
+
# - \.py$ # Python files
|
37
|
+
|
38
|
+
## Force Polling
|
39
|
+
#
|
40
|
+
# Use this setting to overide the normal file system watcher and use
|
41
|
+
# the polling mode. This may be required for some file system types or
|
42
|
+
# when working with some kinds of shared folders.
|
43
|
+
# force_poll: true
|
44
|
+
|
45
|
+
## Hooks
|
46
|
+
#
|
47
|
+
# Hooks allow special commands to be performed on a sub-set of the
|
48
|
+
# changes. They can be used to re-build specific files or run
|
49
|
+
# specialised test cases.
|
50
|
+
hooks:
|
51
|
+
- pattern: \.snooper\.yaml$
|
52
|
+
command: >
|
53
|
+
echo The snooper config file was edited!. Look at the '`hooks:`'
|
54
|
+
section in the snooper config file to see how to run command on a
|
55
|
+
subset of changes like this one is.
|
56
|
+
...
|
data/lib/snooper/snoop.rb
CHANGED
@@ -16,7 +16,6 @@ module Snooper
|
|
16
16
|
|
17
17
|
require 'listen'
|
18
18
|
require 'colored'
|
19
|
-
require 'terminfo'
|
20
19
|
|
21
20
|
##
|
22
21
|
# Public: Create a new source code spy
|
@@ -117,6 +116,21 @@ module Snooper
|
|
117
116
|
res
|
118
117
|
end
|
119
118
|
|
119
|
+
@terminal_width = nil
|
120
|
+
|
121
|
+
## Internal: Get the Terminal Width
|
122
|
+
#
|
123
|
+
# Returns the width of the terminal, if one is connected, in characters
|
124
|
+
def term_width
|
125
|
+
return @@terminal_width unless @terminal_width == nil
|
126
|
+
begin
|
127
|
+
require 'terminfo'
|
128
|
+
@@terminal_width = TermInfo.screen_width - 1
|
129
|
+
rescue
|
130
|
+
@@terminal_width = 79
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
120
134
|
##
|
121
135
|
# Internal: Prettify a status line
|
122
136
|
#
|
@@ -131,7 +145,7 @@ module Snooper
|
|
131
145
|
# Returns the prettified String.
|
132
146
|
def statusbar(message, time=nil)
|
133
147
|
message << " (#{time.round(3)}s)" if time
|
134
|
-
message = message.to_s.center
|
148
|
+
message = message.to_s.center term_width
|
135
149
|
block_given? ? yield(message) : message
|
136
150
|
end
|
137
151
|
|
@@ -144,20 +158,30 @@ module Snooper
|
|
144
158
|
#
|
145
159
|
# Returns the result of the listener
|
146
160
|
def run
|
161
|
+
evq = Queue.new
|
162
|
+
|
147
163
|
if @config.file_path
|
148
164
|
dir = File.dirname @config.file_path
|
149
165
|
filter = %r{#{File.basename @config.file_path}$}
|
150
|
-
Listen.to dir
|
166
|
+
@cfg_listener = Listen.to dir do |*args|
|
151
167
|
next unless args.reduce(&:+).include? @config.file_path
|
152
|
-
|
153
|
-
|
168
|
+
if @listener
|
169
|
+
puts statusbar "Re-loading Config File...", &:yellow
|
170
|
+
@listener.stop
|
171
|
+
evq.push true
|
172
|
+
end
|
154
173
|
end
|
174
|
+
@cfg_listener.start
|
155
175
|
end
|
156
176
|
|
177
|
+
# on C-c tell all listeners to stop
|
178
|
+
Signal.trap "INT", "DEFAULT"
|
179
|
+
|
157
180
|
# loop forever listening, each time the above block causes the listener
|
158
181
|
# to stop it will re-start listening with the new config.
|
159
182
|
while true
|
160
183
|
do_listening
|
184
|
+
break unless evq.pop
|
161
185
|
@config.reload
|
162
186
|
end
|
163
187
|
end
|
@@ -179,12 +203,14 @@ module Snooper
|
|
179
203
|
|
180
204
|
# Force a change to start with
|
181
205
|
run_command
|
182
|
-
|
206
|
+
|
183
207
|
params = {
|
184
208
|
latency: 0.5,
|
185
|
-
only: @config.filters, ignore: @config.ignored,
|
186
209
|
}
|
187
210
|
|
211
|
+
params[:only] = Regexp.new(@config.filters.join("|")) unless @config.filters.empty?
|
212
|
+
params[:ignore] = Regexp.new(@config.ignored.join("|")) unless @config.ignored.empty?
|
213
|
+
|
188
214
|
if @config.force_poll
|
189
215
|
params[:latency] = @config.force_poll
|
190
216
|
params[:force_poll] = true
|
@@ -194,9 +220,7 @@ module Snooper
|
|
194
220
|
self.on_change *args
|
195
221
|
end
|
196
222
|
|
197
|
-
|
198
|
-
Signal.trap("INT", "DEFAULT")
|
199
|
-
t.join
|
223
|
+
@listener.start
|
200
224
|
end
|
201
225
|
end
|
202
226
|
|
data/lib/snooper/version.rb
CHANGED
data/man/snooper-config.7.html
CHANGED
@@ -95,7 +95,7 @@
|
|
95
95
|
|
96
96
|
<h2 id="FORMAT">FORMAT</h2>
|
97
97
|
|
98
|
-
<p><
|
98
|
+
<p><span class="man-ref">snooper<span class="s">(1)</span></span> expects a YAML document of key-value pairs; each pair specifies an
|
99
99
|
option. Unknown options are ignored. Options that can contain a list of values
|
100
100
|
may also be given a single value.</p>
|
101
101
|
|
@@ -164,7 +164,7 @@ as the global <code>command:</code> key.</p></dd>
|
|
164
164
|
|
165
165
|
<h2 id="SEE-ALSO">SEE ALSO</h2>
|
166
166
|
|
167
|
-
<p><
|
167
|
+
<p><span class="man-ref">snooper<span class="s">(1)</span></span></p>
|
168
168
|
|
169
169
|
<h2 id="AUTHORS">AUTHORS</h2>
|
170
170
|
|
data/man/snooper.1
CHANGED
@@ -9,6 +9,9 @@
|
|
9
9
|
.SH "SYNOPSIS"
|
10
10
|
\fBsnooper\fR \fIoptions\fR [\fIcommand_line\fR]*
|
11
11
|
.
|
12
|
+
.br
|
13
|
+
\fBsnooper\fR init
|
14
|
+
.
|
12
15
|
.SH "DESCRIPTION"
|
13
16
|
\fBSnooper\fR is a lightweight test automation tool, it monitors files and folders while you work and re\-runs your tests when you change something\. Snooper doesn\'t care what language you\'re using or what framework you are testing with, it\'s all configureable\.
|
14
17
|
.
|
@@ -27,6 +30,10 @@ Force polling, optionally setting the frequency\. Polling frequency is measured
|
|
27
30
|
\fIcommand_line\fR
|
28
31
|
One or more \fIcommand_line\fRs to execute when source files change\. Overides any commands specified in the configuration file\.
|
29
32
|
.
|
33
|
+
.TP
|
34
|
+
\fBinit\fR
|
35
|
+
Create a new \fB\.snooper\.yaml\fR configuration file in the current working directory\. Use this to quickly add snooper support to a project\.
|
36
|
+
.
|
30
37
|
.SH "EXAMPLES"
|
31
38
|
\fB$ snooper\fR
|
32
39
|
.
|
data/man/snooper.1.html
CHANGED
@@ -93,7 +93,8 @@
|
|
93
93
|
|
94
94
|
<h2 id="SYNOPSIS">SYNOPSIS</h2>
|
95
95
|
|
96
|
-
<p><code>snooper</code> <var>options</var> [<var>command_line</var>]
|
96
|
+
<p><code>snooper</code> <var>options</var> [<var>command_line</var>]*<br />
|
97
|
+
<code>snooper</code> init</p>
|
97
98
|
|
98
99
|
<h2 id="DESCRIPTION">DESCRIPTION</h2>
|
99
100
|
|
@@ -104,18 +105,23 @@ testing with, it's all configureable.</p>
|
|
104
105
|
|
105
106
|
<h2 id="OPTIONS">OPTIONS</h2>
|
106
107
|
|
107
|
-
<p>Most configuration takes place in the <
|
108
|
+
<p>Most configuration takes place in the <span class="man-ref">snooper-config<span class="s">(7)</span></span> file. You can however
|
108
109
|
override the command that is run. This is useful if you are only working on a
|
109
110
|
subsection of a project that has it's own tests.</p>
|
110
111
|
|
111
112
|
<dl>
|
112
113
|
<dt><code>-c</code>, <code>--config</code> <var>configfile</var></dt><dd><p>Specify the configuration file to use. The default is <code>.snooper.yaml</code> in the
|
113
114
|
current directory, or any of it's parent directories.</p></dd>
|
114
|
-
<dt><code>-p</code>, <code>--poll</code> [<var>frequency</var>]</dt><dd><p>Force polling, optionally setting the frequency. Polling frequency
|
115
|
-
|
116
|
-
|
115
|
+
<dt><code>-p</code>, <code>--poll</code> [<var>frequency</var>]</dt><dd><p>Force polling, optionally setting the frequency. Polling frequency
|
116
|
+
is measured in seconds. Use this if there seem to be bugs in your
|
117
|
+
builtin OS file notification system. <em>Warning</em>: using this option
|
118
|
+
may slow down snooper's reaction to file changes and increase
|
119
|
+
resource usage.</p></dd>
|
117
120
|
<dt><var>command_line</var></dt><dd><p>One or more <var>command_line</var>s to execute when source files change. Overides any
|
118
121
|
commands specified in the configuration file.</p></dd>
|
122
|
+
<dt class="flush"><code>init</code></dt><dd><p>Create a new <code>.snooper.yaml</code> configuration file in the current
|
123
|
+
working directory. Use this to quickly add snooper support to a
|
124
|
+
project.</p></dd>
|
119
125
|
</dl>
|
120
126
|
|
121
127
|
|
@@ -136,7 +142,7 @@ when files change.</p>
|
|
136
142
|
|
137
143
|
<h2 id="SEE-ALSO">SEE ALSO</h2>
|
138
144
|
|
139
|
-
<p><
|
145
|
+
<p><span class="man-ref">snooper-config<span class="s">(7)</span></span></p>
|
140
146
|
|
141
147
|
<h2 id="AUTHORS">AUTHORS</h2>
|
142
148
|
|
data/man/snooper.1.ronn
CHANGED
@@ -3,7 +3,8 @@ snooper(1) -- Spy on Tests
|
|
3
3
|
|
4
4
|
## SYNOPSIS
|
5
5
|
|
6
|
-
`snooper` <options> [<command_line>]*
|
6
|
+
`snooper` <options> [<command_line>]*
|
7
|
+
`snooper` init
|
7
8
|
|
8
9
|
## DESCRIPTION
|
9
10
|
|
@@ -23,14 +24,21 @@ subsection of a project that has it's own tests.
|
|
23
24
|
current directory, or any of it's parent directories.
|
24
25
|
|
25
26
|
* `-p`, `--poll` [<frequency>]:
|
26
|
-
Force polling, optionally setting the frequency. Polling frequency
|
27
|
-
|
28
|
-
|
27
|
+
Force polling, optionally setting the frequency. Polling frequency
|
28
|
+
is measured in seconds. Use this if there seem to be bugs in your
|
29
|
+
builtin OS file notification system. _Warning_: using this option
|
30
|
+
may slow down snooper's reaction to file changes and increase
|
31
|
+
resource usage.
|
29
32
|
|
30
33
|
* <command_line>:
|
31
34
|
One or more <command_line>s to execute when source files change. Overides any
|
32
35
|
commands specified in the configuration file.
|
33
36
|
|
37
|
+
* `init`:
|
38
|
+
Create a new `.snooper.yaml` configuration file in the current
|
39
|
+
working directory. Use this to quickly add snooper support to a
|
40
|
+
project.
|
41
|
+
|
34
42
|
## EXAMPLES
|
35
43
|
|
36
44
|
`$ snooper`
|
@@ -53,4 +61,3 @@ snooper-config(7)
|
|
53
61
|
## AUTHORS
|
54
62
|
|
55
63
|
Will Speak (@willspeak)
|
56
|
-
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snooper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Will Speak
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colored
|
@@ -90,6 +90,7 @@ files:
|
|
90
90
|
- man/snooper.1
|
91
91
|
- man/snooper.1.html
|
92
92
|
- man/snooper.1.ronn
|
93
|
+
- data/_snooper.yaml
|
93
94
|
- LICENCE.md
|
94
95
|
- README.md
|
95
96
|
homepage: http://github.com/iwillspeak/snooper
|