snooper 0.0.1
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.
- checksums.yaml +7 -0
- data/LICENCE.md +21 -0
- data/bin/snooper +26 -0
- data/lib/snooper.rb +18 -0
- data/lib/snooper/snoop.rb +64 -0
- metadata +90 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5b17047b1a8079dcfab7eb6a6360e5ebf4464354
|
4
|
+
data.tar.gz: 6b726f039518b7e0e5b4f9170ed2d3c18f126b96
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c34d1cd520480339978ad9c737a9a5d10bbe38b3370778c075e282b8ac2bbd53d4757827de83bc74d511c3dc50868b5a8a86c767cb8263c31bc142a1d31486c8
|
7
|
+
data.tar.gz: 9b3e531d6238fa0a57400aebf5cee5eb0082cb1df6a03c07accd06a4ea859a4afa3148ef126909644211f88e778a7ec0c3a151b85511c08b671bc6515f81c43c
|
data/LICENCE.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
#Snooper is Open Source!
|
2
|
+
|
3
|
+
Copyright (c) 2010 Will Speak
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/bin/snooper
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'snooper'
|
4
|
+
require 'colored'
|
5
|
+
|
6
|
+
def test_loop(options)
|
7
|
+
begin
|
8
|
+
dirs = options[:dirs] ? options[:dirs] : './'
|
9
|
+
Snooper.watch dirs, options
|
10
|
+
rescue Interrupt
|
11
|
+
puts # This is where the ^C is on unix
|
12
|
+
puts "Done".yellow
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# TODO: load the options from the arguments
|
17
|
+
options = {
|
18
|
+
:base_dir => ARGV.shift,
|
19
|
+
:command => (ARGV.shift or "echo 'no tests to run :-)'"),
|
20
|
+
:filters => %w{\.c \.h \.mk},
|
21
|
+
:exclude => %w{build/ bin/}
|
22
|
+
}
|
23
|
+
|
24
|
+
Dir.chdir options[:base_dir] if options[:base_dir]
|
25
|
+
|
26
|
+
test_loop options
|
data/lib/snooper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# This program runs in the background watching for file changes. When a file
|
2
|
+
# change is dtected a command is run. It is intended to watch repos for changes
|
3
|
+
# and run unit tests automatically when source files are changed.
|
4
|
+
#
|
5
|
+
# Author:: Will Speak (@willspeak)
|
6
|
+
# Copyright:: Copyright (c) 2013 Will Speak
|
7
|
+
# License:: Snoop is open source! See LICENCE.md for more details.
|
8
|
+
|
9
|
+
#
|
10
|
+
module Snooper
|
11
|
+
|
12
|
+
require 'snooper/snoop'
|
13
|
+
|
14
|
+
def self.watch(*args)
|
15
|
+
george = Snoop.new *args
|
16
|
+
george.run
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module Snooper
|
2
|
+
class Snoop
|
3
|
+
|
4
|
+
require 'listen'
|
5
|
+
require 'colored'
|
6
|
+
require 'terminfo'
|
7
|
+
|
8
|
+
def initialize(path, args = {})
|
9
|
+
to_regex = Proc.new { |r| Regexp.new r if not r.is_a?(Regexp) }
|
10
|
+
|
11
|
+
@paths = Array(path)
|
12
|
+
@filters = args[:filters]
|
13
|
+
@filters = Array(args[:filters]).map(&to_regex) if @filters
|
14
|
+
@ignored = args[:ignored]
|
15
|
+
@ignored = Array(args[:exclude]).map(&to_regex) if @ignored
|
16
|
+
@command = args[:command]
|
17
|
+
end
|
18
|
+
|
19
|
+
def on_change(modified, added, removed)
|
20
|
+
begin
|
21
|
+
# Puase the listener to make sure any build output doesn't mess with things
|
22
|
+
@listener.pause if @listener
|
23
|
+
|
24
|
+
# summarise the changes made
|
25
|
+
changes = modified + added + removed
|
26
|
+
|
27
|
+
puts
|
28
|
+
puts "#{changes.length.to_s.magenta.bold} changes, retesting..."
|
29
|
+
|
30
|
+
# run the test suite and check the result
|
31
|
+
if system @command then
|
32
|
+
puts statusbar "All tests passed", &:white_on_green
|
33
|
+
else
|
34
|
+
puts self.statusbar "Tests failed", &:white_on_red
|
35
|
+
end
|
36
|
+
|
37
|
+
# return to listening
|
38
|
+
@listener.unpause if @listener
|
39
|
+
rescue Exception => e
|
40
|
+
puts e.message
|
41
|
+
puts e.backtrace
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def statusbar(message)
|
46
|
+
message = message.to_s.center TermInfo.screen_width
|
47
|
+
block_given? ? yield(message) : message
|
48
|
+
end
|
49
|
+
|
50
|
+
def run
|
51
|
+
|
52
|
+
# Force a change to start with
|
53
|
+
self.on_change [], [], []
|
54
|
+
|
55
|
+
callback_helper = Proc.new {|*args| self.on_change *args }
|
56
|
+
|
57
|
+
@listener = Listen.to(*@paths, :latency => 0.5, :filter => @filters, \
|
58
|
+
:ignore => @ignored)
|
59
|
+
@listener.change &callback_helper
|
60
|
+
|
61
|
+
@listener.start
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: snooper
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Will Speak
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-03-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: colored
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: listen
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.7'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: ruby-terminfo
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.1'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.1'
|
55
|
+
description: A simple language and test system agnostic continuous test runner.
|
56
|
+
email: lithiumflame@gmail.com
|
57
|
+
executables:
|
58
|
+
- snooper
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- lib/snooper.rb
|
63
|
+
- lib/snooper/snoop.rb
|
64
|
+
- bin/snooper
|
65
|
+
- LICENCE.md
|
66
|
+
homepage: http://github.com/iwillspeak/snooper
|
67
|
+
licenses:
|
68
|
+
- Snooper is Open Source! See the LICENCE.md for more information.
|
69
|
+
metadata: {}
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options: []
|
72
|
+
require_paths:
|
73
|
+
- lib
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - '>='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
requirements: []
|
85
|
+
rubyforge_project:
|
86
|
+
rubygems_version: 2.0.0
|
87
|
+
signing_key:
|
88
|
+
specification_version: 4
|
89
|
+
summary: Spying on Tests
|
90
|
+
test_files: []
|