spectator 1.2.6 → 1.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +2 -0
- data/lib/spectator.rb +42 -32
- data/lib/spectator/control.rb +57 -16
- data/lib/spectator/specs.rb +1 -1
- data/lib/spectator/version.rb +1 -1
- data/spectator.gemspec +5 -4
- metadata +43 -31
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5c72941ed2f2136eca2366723b7942f51ceb7f8b
|
4
|
+
data.tar.gz: 5807a32aeb0a36890c8329376d08d8c1305bc94b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a6309a9b3167ccc4b92b280c6637beaa3e4b07a3ffc29bfc98af9df82980644056bd0df2893807a701e8dfc7d1fbb66b0052a48cb271df9a88b52226d1a0a903
|
7
|
+
data.tar.gz: 4bdae2d7f3005dbcfa613f1cd33662855291e957dfc6969fb4ce78d4d3a83d26a88fcd140aec19c51c4a18c456cba29bc433c69a0ab82e0a9297066f8083473b
|
data/README.md
CHANGED
data/lib/spectator.rb
CHANGED
@@ -17,29 +17,35 @@ module Spectator
|
|
17
17
|
include CommandLine
|
18
18
|
include Specs
|
19
19
|
include Control
|
20
|
-
|
20
|
+
|
21
21
|
def matchers
|
22
22
|
@matchers ||= []
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
def queue
|
26
26
|
@queue ||= Queue.new
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
def watch_paths!
|
30
|
-
listener
|
31
|
-
listener.filter %r{^(app|spec|lib|script)/}
|
32
|
-
listener.change do |modified, added, removed|
|
33
|
-
[modified, added].flatten.each { |relative| queue.push relative }
|
34
|
-
end
|
35
|
-
listener.start(false)
|
30
|
+
listener.start
|
36
31
|
sleep
|
37
32
|
end
|
38
|
-
|
33
|
+
|
34
|
+
def listener
|
35
|
+
@listener ||= begin
|
36
|
+
listener = Listen.to(Dir.pwd, :relative_paths => true)
|
37
|
+
listener = listener.filter %r{^(app|spec|lib|script)/}
|
38
|
+
listener = listener.change do |modified, added, removed|
|
39
|
+
[modified, added].flatten.each { |relative| queue.push relative }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
|
39
45
|
def puts *args
|
40
46
|
print args.join("\n")+"\n"
|
41
47
|
end
|
42
|
-
|
48
|
+
|
43
49
|
def run_specs specs
|
44
50
|
rules.each do |(regexp, action)|
|
45
51
|
regexp = Regexp.new(regexp)
|
@@ -49,37 +55,41 @@ module Spectator
|
|
49
55
|
end
|
50
56
|
end
|
51
57
|
end
|
52
|
-
|
58
|
+
|
53
59
|
def wait_for_changes
|
54
60
|
puts '--- Waiting for changes...'.cyan
|
55
|
-
|
61
|
+
|
56
62
|
loop do
|
57
|
-
sleep 0.1 while queue.empty?
|
58
|
-
|
63
|
+
sleep 0.1 while queue.empty? or interrupted?
|
64
|
+
|
59
65
|
files = []
|
60
66
|
queue.size.times do
|
61
67
|
files << queue.pop
|
62
68
|
end
|
63
|
-
|
69
|
+
|
64
70
|
files.compact!
|
65
71
|
redo if files.empty?
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
72
|
+
|
73
|
+
rspec_files(*specs_for(files))
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def specs_for files
|
78
|
+
specs = Set.new
|
79
|
+
files = [files] unless files.respond_to? :each
|
80
|
+
files.each do |file|
|
81
|
+
matched = matchers.map do |matcher|
|
82
|
+
file.scan(matcher).flatten.first.to_s.gsub(/\.rb$/,'')
|
83
|
+
end.flatten.reject(&:empty?)
|
84
|
+
specs += matched.uniq.map { |m| specs_for_file(m) }.flatten
|
76
85
|
end
|
86
|
+
specs.to_a
|
77
87
|
end
|
78
|
-
|
88
|
+
|
79
89
|
def initialize &block
|
80
90
|
yield self if block_given?
|
81
|
-
|
82
|
-
|
91
|
+
|
92
|
+
|
83
93
|
matchers << %r{^spec/(.*)_spec\.rb$}
|
84
94
|
matchers << %r{^(?:app|lib|script)/(.*)(?:\.rb|\.\w+|)$}
|
85
95
|
|
@@ -89,9 +99,9 @@ module Spectator
|
|
89
99
|
watch_paths!
|
90
100
|
end
|
91
101
|
end
|
92
|
-
|
93
|
-
|
94
|
-
|
102
|
+
|
103
|
+
|
104
|
+
|
95
105
|
def self.run
|
96
106
|
Runner.new
|
97
107
|
end
|
data/lib/spectator/control.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'thread'
|
2
|
+
|
1
3
|
module Spectator
|
2
4
|
module Control
|
3
5
|
def exit
|
@@ -13,28 +15,67 @@ module Spectator
|
|
13
15
|
|
14
16
|
def trap_int!
|
15
17
|
# Ctrl-C
|
16
|
-
|
17
18
|
@interrupted ||= false
|
19
|
+
@signal_queue = []
|
20
|
+
@signals_handler = Thread.new do
|
21
|
+
loop do
|
22
|
+
sleep(0.3)
|
23
|
+
if signal_queue.any?
|
24
|
+
listener.pause
|
25
|
+
ask_what_to_do!
|
26
|
+
listener.unpause
|
27
|
+
Thread.pass
|
28
|
+
signal_queue.shift
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
18
32
|
|
19
33
|
Signal.trap('INT') do
|
34
|
+
abort! if exiting?
|
35
|
+
start_exit if interrupted?
|
36
|
+
signal_queue << :int
|
20
37
|
puts ' (Interrupted with CTRL+C)'.red
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
attr_reader :signal_queue
|
42
|
+
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def interrupted?
|
47
|
+
signal_queue.any?
|
48
|
+
end
|
49
|
+
|
50
|
+
def ask_what_to_do!
|
51
|
+
if @exiting
|
52
|
+
abort!
|
53
|
+
else
|
54
|
+
answer = ask('--- What to do now? (q=quit, a=all-specs): ')
|
55
|
+
case answer
|
56
|
+
when 'q' then start_exit
|
57
|
+
when 'a' then rspec_all
|
58
|
+
else puts '--- Bad input, ignored.'.yellow
|
35
59
|
end
|
60
|
+
puts '--- Waiting for changes...'.cyan
|
36
61
|
end
|
37
62
|
end
|
38
|
-
|
63
|
+
|
64
|
+
def start_exit
|
65
|
+
return if exiting?
|
66
|
+
@exiting = true
|
67
|
+
exit
|
68
|
+
end
|
69
|
+
|
70
|
+
def exiting?
|
71
|
+
@exiting
|
72
|
+
end
|
73
|
+
|
74
|
+
def ask question
|
75
|
+
print question.yellow
|
76
|
+
$stdout.flush
|
77
|
+
STDIN.gets.chomp.strip.downcase
|
78
|
+
end
|
79
|
+
|
39
80
|
end
|
40
81
|
end
|
data/lib/spectator/specs.rb
CHANGED
@@ -32,7 +32,7 @@ module Spectator
|
|
32
32
|
rspec files.join(' ')
|
33
33
|
end
|
34
34
|
|
35
|
-
def
|
35
|
+
def specs_for_file(path)
|
36
36
|
print "--- Searching specs for #{path.inspect}...".yellow
|
37
37
|
specs = match_specs path, Dir['spec/**/*_spec.rb']
|
38
38
|
puts specs.empty? ? ' nothing found.'.red : " #{specs.size} matched.".green
|
data/lib/spectator/version.rb
CHANGED
data/spectator.gemspec
CHANGED
@@ -19,10 +19,11 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
20
20
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
21
21
|
s.require_paths = %w[lib]
|
22
|
-
|
23
|
-
s.add_dependency 'listen'
|
24
|
-
s.add_dependency 'term-ansicolor'
|
25
|
-
s.add_dependency 'notify'
|
22
|
+
|
23
|
+
s.add_dependency 'listen', '~> 1.3.0'
|
24
|
+
s.add_dependency 'term-ansicolor', '~> 1.2.2'
|
25
|
+
s.add_dependency 'notify', '~> 0.5.2'
|
26
|
+
|
26
27
|
s.add_development_dependency 'rake', '~> 0.9'
|
27
28
|
s.add_development_dependency 'bundler', '~> 1.0'
|
28
29
|
end
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spectator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
5
|
-
prerelease:
|
4
|
+
version: 1.2.8
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Elia
|
@@ -10,63 +9,78 @@ authors:
|
|
10
9
|
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date:
|
12
|
+
date: 2013-08-27 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: listen
|
17
|
-
requirement:
|
18
|
-
none: false
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
19
17
|
requirements:
|
20
|
-
- -
|
18
|
+
- - ~>
|
21
19
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
20
|
+
version: 1.3.0
|
23
21
|
type: :runtime
|
24
22
|
prerelease: false
|
25
|
-
version_requirements:
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ~>
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 1.3.0
|
26
28
|
- !ruby/object:Gem::Dependency
|
27
29
|
name: term-ansicolor
|
28
|
-
requirement:
|
29
|
-
none: false
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
30
31
|
requirements:
|
31
|
-
- -
|
32
|
+
- - ~>
|
32
33
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
34
|
+
version: 1.2.2
|
34
35
|
type: :runtime
|
35
36
|
prerelease: false
|
36
|
-
version_requirements:
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ~>
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 1.2.2
|
37
42
|
- !ruby/object:Gem::Dependency
|
38
43
|
name: notify
|
39
|
-
requirement:
|
40
|
-
none: false
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
41
45
|
requirements:
|
42
|
-
- -
|
46
|
+
- - ~>
|
43
47
|
- !ruby/object:Gem::Version
|
44
|
-
version:
|
48
|
+
version: 0.5.2
|
45
49
|
type: :runtime
|
46
50
|
prerelease: false
|
47
|
-
version_requirements:
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ~>
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 0.5.2
|
48
56
|
- !ruby/object:Gem::Dependency
|
49
57
|
name: rake
|
50
|
-
requirement:
|
51
|
-
none: false
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
52
59
|
requirements:
|
53
60
|
- - ~>
|
54
61
|
- !ruby/object:Gem::Version
|
55
62
|
version: '0.9'
|
56
63
|
type: :development
|
57
64
|
prerelease: false
|
58
|
-
version_requirements:
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0.9'
|
59
70
|
- !ruby/object:Gem::Dependency
|
60
71
|
name: bundler
|
61
|
-
requirement:
|
62
|
-
none: false
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
63
73
|
requirements:
|
64
74
|
- - ~>
|
65
75
|
- !ruby/object:Gem::Version
|
66
76
|
version: '1.0'
|
67
77
|
type: :development
|
68
78
|
prerelease: false
|
69
|
-
version_requirements:
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ~>
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '1.0'
|
70
84
|
description: Watches specs for a Ruby (1.8 or 1.9) or Rails (2 or 3) project
|
71
85
|
email:
|
72
86
|
- elia@schito.me
|
@@ -90,27 +104,25 @@ files:
|
|
90
104
|
homepage: ''
|
91
105
|
licenses:
|
92
106
|
- MIT
|
107
|
+
metadata: {}
|
93
108
|
post_install_message:
|
94
109
|
rdoc_options: []
|
95
110
|
require_paths:
|
96
111
|
- lib
|
97
112
|
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
-
none: false
|
99
113
|
requirements:
|
100
|
-
- -
|
114
|
+
- - '>='
|
101
115
|
- !ruby/object:Gem::Version
|
102
116
|
version: '0'
|
103
117
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
-
none: false
|
105
118
|
requirements:
|
106
|
-
- -
|
119
|
+
- - '>='
|
107
120
|
- !ruby/object:Gem::Version
|
108
121
|
version: '0'
|
109
122
|
requirements: []
|
110
123
|
rubyforge_project: rspec-rails-watchr
|
111
|
-
rubygems_version:
|
124
|
+
rubygems_version: 2.0.3
|
112
125
|
signing_key:
|
113
|
-
specification_version:
|
126
|
+
specification_version: 4
|
114
127
|
summary: Watches specs for a Ruby or Rails project
|
115
128
|
test_files: []
|
116
|
-
has_rdoc:
|