snooper 2.1.1 → 2.1.3

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: 3911c398b1c83b549e996a605f65e79211e2ee4a
4
- data.tar.gz: a91ca9f1ff1b114c70e9d9872fa695975b98c752
3
+ metadata.gz: ecf5d18d47ffc327af5f333db3b4336e68d9549f
4
+ data.tar.gz: 9de0ed66d00dcdebfd4b689ac20a95d49735a920
5
5
  SHA512:
6
- metadata.gz: 5bc6a4a0e02acbfee57efe128efb893dc3e8ee40e848b312e257adf07b42ba552c5c775d5d40eb43ecf5f35b7a961e0889331e2913b158208c8f43ee7e962265
7
- data.tar.gz: aaadd056771a21fcd7bc14d40baee028da7f87222d12fbafc0227ec2c94b5df50d534f801bc6eec587a0d4a9da316435880b9877d80979d13eca556d80ce68db
6
+ metadata.gz: 085d681726b0628ae5ca2a681cf8cba65080b109343a4c2d8144d0164ddd98405f80ed82934e7ddd2a97425589b5ece31eaf5f3557dd04a07525bea43901cd40
7
+ data.tar.gz: 2ed397a6e998f5fe90397208d5a9a0c0f9e372dd2f2be350c3733d282eb0bc0a746d58072d38b56b6a81f0229b3dad5f65d2ac74d993319fd00430bcf309fb50
@@ -34,5 +34,8 @@ end
34
34
  # Override the command if one was specified
35
35
  config.command = options.command if options.command
36
36
 
37
+ # Force polling if command line flag is set
38
+ config.force_poll = options.poll if options.poll
39
+
37
40
  # Run the tests, pusing the target directory
38
41
  test_loop config
@@ -35,6 +35,9 @@ module Snooper
35
35
  # file_path - The location the config was loaded from
36
36
  attr_accessor :file_path
37
37
 
38
+ # force_poll - Make sure polling is used
39
+ attr_accessor :force_poll
40
+
38
41
  ##
39
42
  # Public: create a new config object
40
43
  #
@@ -77,6 +80,19 @@ module Snooper
77
80
  @ignored = rgx_key.call :ignored
78
81
 
79
82
  @hooks = (options[:hooks] && create_hooks(options[:hooks])) || []
83
+
84
+ # Force poll if it is stored in the options file.
85
+ case options[:force_poll]
86
+ when true
87
+ @force_poll = 1.0
88
+
89
+ when false, nil
90
+ @force_poll = nil
91
+
92
+ else
93
+ @force_poll = options[:force_poll].to_f
94
+ @force_poll = 1.0 if @force_poll <= 0.0
95
+ end
80
96
  end
81
97
 
82
98
  ##
@@ -147,6 +163,9 @@ module Snooper
147
163
  Hook.new hook_hash["pattern"], hook_hash["command"]
148
164
  end
149
165
 
166
+ when 'force_poll'
167
+ # Boolean conversion is all done by YAML
168
+
150
169
  else
151
170
  $stderr.puts "warning: ignoring unknown option #{key}"
152
171
  end
@@ -8,7 +8,7 @@ module Snooper
8
8
  ##
9
9
  # Public: File Change Hook
10
10
  #
11
- # Hooks represent a command that is fired when a given file changes.
11
+ # Hooks represent a command that is fired when a given file changes.
12
12
  class Hook
13
13
 
14
14
  ##
@@ -11,7 +11,7 @@ module Snooper
11
11
 
12
12
  ##
13
13
  # Public: Command Line Options
14
- ParsedOptions = Struct.new :config_path, :command
14
+ ParsedOptions = Struct.new :config_path, :command, :poll
15
15
 
16
16
  ##
17
17
  # Public: Parse the command line
@@ -50,6 +50,10 @@ END
50
50
  exit
51
51
  end
52
52
 
53
+ parser.on("-p", "--poll [FREQUENCY]", "Force filesystem polling.") do |freq|
54
+ options.poll = freq || true
55
+ end
56
+
53
57
  parser.on("-h", "--help", "Show this message") do
54
58
  puts parser
55
59
  exit
@@ -171,16 +171,32 @@ module Snooper
171
171
  # Returns the result of the listener
172
172
  def do_listening
173
173
  in_dir @config.base_path do
174
+
175
+ # Notify people if we are using fallback mode
176
+ if @config.force_poll
177
+ puts statusbar "Using polling fallback listener", &:yellow
178
+ end
179
+
174
180
  # Force a change to start with
175
181
  run_command
176
182
 
177
- callback_helper = Proc.new { |*args| self.on_change *args }
178
-
179
- @listener = Listen.to(*@config.paths, latency: 0.5,
180
- filter: @config.filters, ignore: @config.ignored)
181
- @listener.change &callback_helper
183
+ params = {
184
+ latency: 0.5,
185
+ filter: @config.filters, ignore: @config.ignored,
186
+ }
182
187
 
183
- @listener.start!
188
+ if @config.force_poll
189
+ params[:latency] = @config.force_poll
190
+ params[:force_poll] = true
191
+ end
192
+
193
+ @listener = Listen.to(*@config.paths, params) do |*args|
194
+ self.on_change *args
195
+ end
196
+
197
+ t = @listener.start
198
+ Signal.trap("INT", "DEFAULT")
199
+ t.join
184
200
  end
185
201
  end
186
202
 
@@ -10,5 +10,5 @@ module Snooper
10
10
  #
11
11
  # This should conform to SemVer. If this is changed it should be the only
12
12
  # thing that changes in the comit.
13
- VERSION = '2.1.1'
13
+ VERSION = '2.1.3'
14
14
  end
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "SNOOPER\-CONFIG" "7" "July 2013" "" ""
4
+ .TH "SNOOPER\-CONFIG" "7" "October 2013" "" ""
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBsnooper\-config\fR \- Configure for Espionage
@@ -17,7 +17,7 @@ String options
17
17
  .
18
18
  .TP
19
19
  \fBbase_path:\fR \fIdirectory\fR
20
- Specifies the \fIdirectory\fR that \fBsnooper\fR should base all relative paths from\. This is also the working directory that commands will inherit\.
20
+ Specifies the \fIdirectory\fR that \fBsnooper\fR should base all relative paths from\. This is also the working directory that commands and hooks will inherit\.
21
21
  .
22
22
  .TP
23
23
  \fBcommand:\fR \fIcommand_string\fR
@@ -35,9 +35,26 @@ Specifies a list of \fIdirectories\fR to watch\. Directories can be either relat
35
35
  Specifies a list of regular expressions \fIfilters\fR to use to filter the changes\. These should be in a format understood by ruby(1)\'s Regex\.new method\. If none are given then all changes in watched directories trigger testing\.
36
36
  .
37
37
  .IP
38
+ A file change satisfies these filters if the file path matches any of the regular expressions in \fBfilters\fR and none of those in \fBignored\fR\.
39
+ .
40
+ .IP
38
41
  \fINote\fR: as these are regular expressions \fB\e\.c\fR will match both \fBfoo\.c\fR and \fBbar\.cfg\fR, \fB\e\.c$\fR will only match \fB\.c\fR files\.
39
42
  .
40
43
  .P
44
+ Polling
45
+ .
46
+ .IP "\(bu" 4
47
+ \fBforce_poll\fR: \fIpoll\fR Specifies if the polling fallback mode should be used and controls the polling frequency in seconds\. Include this option if you want to use polling but don\'t want to have to specify it on the command line\. Defaults to false\.
48
+ .
49
+ .IP "" 0
50
+ .
51
+ .P
52
+ This mode can be slower and more buggy but is useful for working around bugs in third party applications that hide filesystem events\. Known to be required when you are snooping on VirtualBox shared folders, or in Dropbox folders\.
53
+ .
54
+ .P
55
+ \fINote\fR: This option can be overridden from the command line with the \fB\-\-poll\fR option\.
56
+ .
57
+ .P
41
58
  Hooks
42
59
  .
43
60
  .P
@@ -105,7 +105,7 @@ may also be given a single value.</p>
105
105
 
106
106
  <dl>
107
107
  <dt><code>base_path:</code> <var>directory</var></dt><dd><p>Specifies the <var>directory</var> that <code>snooper</code> should base all relative paths from.
108
- This is also the working directory that commands will inherit.</p></dd>
108
+ This is also the working directory that commands and hooks will inherit.</p></dd>
109
109
  <dt><code>command:</code> <var>command_string</var></dt><dd><p>Specifies the command string to execute when a file change is detected.</p></dd>
110
110
  </dl>
111
111
 
@@ -121,11 +121,26 @@ changes. These should be in a format understood by <span class="man-ref">ruby<sp
121
121
  method. If none are given then all changes in watched directories trigger
122
122
  testing.</p>
123
123
 
124
+ <p>A file change satisfies these filters if the file path matches any of the
125
+ regular expressions in <code>filters</code> and none of those in <code>ignored</code>.</p>
126
+
124
127
  <p><em>Note</em>: as these are regular expressions <code>\.c</code> will match both
125
128
  <code>foo.c</code> and <code>bar.cfg</code>, <code>\.c$</code> will only match <code>.c</code> files.</p></dd>
126
129
  </dl>
127
130
 
128
131
 
132
+ <p>Polling</p>
133
+
134
+ <ul>
135
+ <li><code>force_poll</code>: <var>poll</var>
136
+ Specifies if the polling fallback mode should be used and controls the polling frequency in seconds. Include this option if you want to use polling but don't want to have to specify it on the command line. Defaults to false.</li>
137
+ </ul>
138
+
139
+
140
+ <p> This mode can be slower and more buggy but is useful for working around bugs in third party applications that hide filesystem events. Known to be required when you are snooping on VirtualBox shared folders, or in Dropbox folders.</p>
141
+
142
+ <p><em>Note</em>: This option can be overridden from the command line with the <code>--poll</code> option.</p>
143
+
129
144
  <p>Hooks</p>
130
145
 
131
146
  <p>Hooks are useful to pefrom special commads upon a subset of the file-change
@@ -162,7 +177,7 @@ as the global <code>command:</code> key.</p></li>
162
177
 
163
178
  <ol class='man-decor man-foot man foot'>
164
179
  <li class='tl'></li>
165
- <li class='tc'>July 2013</li>
180
+ <li class='tc'>October 2013</li>
166
181
  <li class='tr'>snooper-config(7)</li>
167
182
  </ol>
168
183
 
@@ -17,7 +17,7 @@ String options
17
17
 
18
18
  * `base_path:` <directory>:
19
19
  Specifies the <directory> that `snooper` should base all relative paths from.
20
- This is also the working directory that commands will inherit.
20
+ This is also the working directory that commands and hooks will inherit.
21
21
 
22
22
  * `command:` <command_string>:
23
23
  Specifies the command string to execute when a file change is detected.
@@ -35,9 +35,21 @@ String Array options
35
35
  method. If none are given then all changes in watched directories trigger
36
36
  testing.
37
37
 
38
+ A file change satisfies these filters if the file path matches any of the
39
+ regular expressions in `filters` and none of those in `ignored`.
40
+
38
41
  _Note_: as these are regular expressions `\.c` will match both
39
42
  `foo.c` and `bar.cfg`, `\.c$` will only match `.c` files.
40
43
 
44
+ Polling
45
+
46
+ * `force_poll`: <poll>
47
+ Specifies if the polling fallback mode should be used and controls the polling frequency in seconds. Include this option if you want to use polling but don't want to have to specify it on the command line. Defaults to false.
48
+
49
+ This mode can be slower and more buggy but is useful for working around bugs in third party applications that hide filesystem events. Known to be required when you are snooping on VirtualBox shared folders, or in Dropbox folders.
50
+
51
+ _Note_: This option can be overridden from the command line with the `--poll` option.
52
+
41
53
  Hooks
42
54
 
43
55
  Hooks are useful to pefrom special commads upon a subset of the file-change
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "SNOOPER" "1" "June 2013" "" ""
4
+ .TH "SNOOPER" "1" "October 2013" "" ""
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBsnooper\fR \- Spy on Tests
@@ -17,7 +17,11 @@ Most configuration takes place in the snooper\-config(7) file\. You can however
17
17
  .
18
18
  .TP
19
19
  \fB\-c\fR, \fB\-\-config\fR \fIconfigfile\fR
20
- Specify the configuration file to use\. The default is \fB\.snooper\.yaml\fR in the current directory\.
20
+ Specify the configuration file to use\. The default is \fB\.snooper\.yaml\fR in the current directory, or any of it\'s parent directories\.
21
+ .
22
+ .TP
23
+ \fB\-p\fR, \fB\-\-poll\fR [\fIfrequency\fR]
24
+ Force polling, optionally setting the frequency\. Polling frequency is measured in seconds\. Use this if there seem to be bugs in your builtin OS file notification system\. \fIWarning\fR: using this option may slow down snooper\'s reaction to file changes and increase resource usage\.
21
25
  .
22
26
  .TP
23
27
  \fIcommand_line\fR
@@ -110,7 +110,10 @@ subsection of a project that has it's own tests.</p>
110
110
 
111
111
  <dl>
112
112
  <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
- current directory.</p></dd>
113
+ 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 is measured in seconds. Use this if there seem to be bugs in your builtin OS file
115
+ notification system. <em>Warning</em>: using this option may slow down snooper's
116
+ reaction to file changes and increase resource usage.</p></dd>
114
117
  <dt><var>command_line</var></dt><dd><p>One or more <var>command_line</var>s to execute when source files change. Overides any
115
118
  commands specified in the configuration file.</p></dd>
116
119
  </dl>
@@ -142,7 +145,7 @@ when files change.</p>
142
145
 
143
146
  <ol class='man-decor man-foot man foot'>
144
147
  <li class='tl'></li>
145
- <li class='tc'>June 2013</li>
148
+ <li class='tc'>October 2013</li>
146
149
  <li class='tr'>snooper(1)</li>
147
150
  </ol>
148
151
 
@@ -9,7 +9,7 @@ snooper(1) -- Spy on Tests
9
9
 
10
10
  **Snooper** is a lightweight test automation tool, it monitors files and
11
11
  folders while you work and re-runs your tests when you change something.
12
- Snooper doesn't care what language you're using or what framework you are
12
+ Snooper doesn't care what language you're using or what framework you are
13
13
  testing with, it's all configureable.
14
14
 
15
15
  ## OPTIONS
@@ -20,7 +20,12 @@ subsection of a project that has it's own tests.
20
20
 
21
21
  * `-c`, `--config` <configfile>:
22
22
  Specify the configuration file to use. The default is `.snooper.yaml` in the
23
- current directory.
23
+ current directory, or any of it's parent directories.
24
+
25
+ * `-p`, `--poll` [<frequency>]:
26
+ Force polling, optionally setting the frequency. Polling frequency is measured in seconds. Use this if there seem to be bugs in your builtin OS file
27
+ notification system. _Warning_: using this option may slow down snooper's
28
+ reaction to file changes and increase resource usage.
24
29
 
25
30
  * <command_line>:
26
31
  One or more <command_line>s to execute when source files change. Overides any
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.1
4
+ version: 2.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Will Speak
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-27 00:00:00.000000000 Z
11
+ date: 2014-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colored
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: listen
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: '1.2'
33
+ version: '2.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
- version: '1.2'
40
+ version: '2.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: ruby-terminfo
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -78,11 +78,8 @@ extensions: []
78
78
  extra_rdoc_files: []
79
79
  files:
80
80
  - lib/snooper/config.rb
81
- - lib/snooper/config.rb~
82
81
  - lib/snooper/hook.rb
83
- - lib/snooper/hook.rb~
84
82
  - lib/snooper/options.rb
85
- - lib/snooper/options.rb~
86
83
  - lib/snooper/snoop.rb
87
84
  - lib/snooper/version.rb
88
85
  - lib/snooper.rb
@@ -1,88 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- # Author:: Will Speak (@willspeak)
3
- # Copyright:: Copyright (c) 2013 Will Speak
4
- # License:: Snooper is open source! See LICENCE.md for more details.
5
-
6
- module Snooper
7
-
8
- ##
9
- # Public: Snooper Configuration
10
- #
11
- # This object contains the configuration information that is
12
- class Config
13
-
14
- ##
15
- # Public: create a new config object
16
- #
17
- # base_path - The String representing the path from which all the other
18
- # paths should be resolved. Nil to use the current directory.
19
- # command - The command to execute when a change satisfies all the
20
- # predicates.
21
- # options - The hash containing all of the optinal parameters.
22
- # :paths - The Array of the paths to watch, relative to the
23
- # base. Nil or empty to watch the whole directory.
24
- # :filters - THe Array of Regex-like inclusion filters. Nil or
25
- # empty to trigger on all changes.
26
- # :ignored - The Array of Regex-like ignore filters. Nil or
27
- # empty to ignore no changes.
28
- # :hooks - The Array of Hook objects to call when a change
29
- # satisifies all the predicates and before the
30
- # command is run. Nil or empty for no hooks.
31
- end
32
-
33
- =begin
34
- ##
35
- # Public: Load the config from disk
36
- #
37
- # path - The String containing the path of the config file
38
- #
39
- # Returns a new Config.
40
- def self.new(path)
41
-
42
- # Load the config file begin yamopts = YAML.load_file path
43
- rescue Exception => e puts "Error loading the config: #{e}" exit
44
- 1 end if not yamopts.is_a? Hash puts "Invalid options file" exit
45
- 1 end
46
- # default config
47
- config = {
48
- :base_path => '.',
49
- :command => nil,
50
- :filters => [],
51
- :ignored => [],
52
- :paths => [],
53
- :hooks => []
54
- }
55
-
56
- yamopts.each do |option, argument|
57
- case option
58
- when 'base_path', 'command'
59
- config[option.to_sym] = argument.to_s
60
-
61
- when 'paths', 'filters', 'ignored'
62
- argument = argument.split if argument.is_a? String
63
- config[option.to_sym] += Array(argument)
64
-
65
- when 'hooks'
66
- argument.each do |hook|
67
- config[:hooks] << hook
68
- end
69
-
70
- else
71
- puts "Ignoring unknown option #{option}".red
72
- end
73
- end
74
-
75
- [:filters, :ignored].each do |index|
76
- config[index].map! { |r| Regexp.try_convert(r) || Regexp.new(r) }
77
- end
78
-
79
- if config[:base_path]
80
- base = File.expand_path config[:base_path], File.dirname(path)
81
- config[:paths].map! { |p| File.expand_path p, base }
82
- config[:base_path] = base
83
- end
84
-
85
- config
86
- end
87
- =end
88
- end
@@ -1,17 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- # Author:: Will Speak (@willspeak)
3
- # Copyright:: Copyright (c) 2013 Will Speak
4
- # License:: Snoop is open source! See LICENCE.md for more details.
5
-
6
- module Snooper
7
-
8
- ##
9
- # File Change Hook
10
- #
11
- # Hooks represent a command that is fired when a given file changes.
12
-
13
- class Hook
14
-
15
- end
16
-
17
- end
@@ -1,71 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- # Author:: Will Speak (@willspeak)
3
- # Copyright:: Copyright (c) 2013 Will Speak
4
- # License:: Snooper is open source! See LICENCE.md for more details.
5
-
6
- module Snooper
7
-
8
- module Options
9
- ##
10
- # Public: Command Line Options
11
- ParsedOptions = Struct.new :config_path, :command
12
-
13
- ##
14
- # Public: Parse the command line
15
- #
16
- # arguments - The list of string arguments to be parsed
17
- #
18
- # Returns an Options struct containing :base_path and :command
19
- def parse(arguments)
20
-
21
- helptext = <<END
22
-
23
- Snooper is a lightweight test automation tool, it monitors files and folders
24
- while you work and re-runs your tests when you change something. Snooper
25
- doesn't care what language you're using or what framework you are testing with,
26
- it's all configureable.
27
-
28
- For more information see snooper(1).
29
- END
30
-
31
- options = ParsedOptions.new
32
- options.config_path = '.snooper.yaml'
33
-
34
- parser = OptionParser.new do |parser|
35
- parser.banner =
36
- "Useage: #{File.basename __FILE__} [--config <CONFIG> | --help] " +
37
- "[<COMMAND>]*"
38
-
39
- parser.separator helptext
40
-
41
- parser.on '-c', '--config CONFIGFILE', 'YAML configuration file' do |path|
42
- config_path = path
43
- end
44
-
45
- parser.on("--version", "show version information") do
46
- puts "Snooper v#{Snooper::VERSION}"
47
- exit
48
- end
49
-
50
- parser.on("-h", "--help", "Show this message") do
51
- puts parser
52
- exit
53
- end
54
- end
55
-
56
- # Parse the arguments
57
- begin
58
- parser.parse! arguments
59
- rescue OptionParser::InvalidOption, \
60
- OptionParser::MissingArgument, \
61
- OptionParser::InvalidArgument => e
62
- puts e
63
- puts parser
64
- exit 1
65
- end
66
-
67
- options.command = arguments.join " " if not arguments.empty?
68
- options
69
- end
70
- end
71
- end