starting_blocks 1.1.3 → 1.2.0
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 +4 -4
- data/lib/starting_blocks/version.rb +1 -1
- data/lib/starting_blocks/watcher.rb +20 -0
- data/lib/starting_blocks.rb +4 -10
- data/spec/starting_blocks/watcher_spec.rb +62 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1462b26d4b584409f66efc4d657de2a05ecf0e0d
|
4
|
+
data.tar.gz: cd075e1c73f7c8d7ce013624679675b6b2a670d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76503a6ffbd9583c06bedfdc11a9f0ea02f70ec14130c773041864e5e7e1694909f5033232e313f9482085d8855ab801d4178f0e7b97fc3e2eced3b815ecc36d
|
7
|
+
data.tar.gz: 26fef9f5f5a0dda1c8861ff7fe20bf443465bfa28ce77780ed6dbc29989a07049078370fe217d0b30835be7b5e49b3827a2c27814fa36f8ef5b30265fe538d8f
|
@@ -5,6 +5,23 @@ module StartingBlocks
|
|
5
5
|
|
6
6
|
@last_failed_run = nil
|
7
7
|
|
8
|
+
def self.filter_files_according_to_the_contract files, contract
|
9
|
+
extensions = contract.extensions.map { |x| x.gsub('.', '').downcase }
|
10
|
+
files.select do |file|
|
11
|
+
splits = file.split('/')[-1].split('.')
|
12
|
+
(splits.count == 1 && extensions.include?('')) ||
|
13
|
+
(extensions.include?(splits[-1].downcase))
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.filter_files_by_file_clues files, clues
|
18
|
+
files.select do |file|
|
19
|
+
file_without_path = file.split('/')[-1]
|
20
|
+
matches = clues.select { |clue| file_without_path.include? clue }
|
21
|
+
matches.count > 0
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
8
25
|
class << self
|
9
26
|
def start_watching(dir, options)
|
10
27
|
StartingBlocks.display("Start watching #{dir.getwd} with #{options.inspect}")
|
@@ -21,6 +38,9 @@ module StartingBlocks
|
|
21
38
|
StartingBlocks::Watcher.add_it(added[0]) if added.count > 0
|
22
39
|
StartingBlocks::Watcher.delete_it(removed[0]) if removed.count > 0
|
23
40
|
next if @running
|
41
|
+
|
42
|
+
modified = StartingBlocks::Watcher.filter_files_according_to_the_contract modified, @contract
|
43
|
+
|
24
44
|
StartingBlocks::Watcher.run_it(modified[0]) if modified.count > 0
|
25
45
|
end
|
26
46
|
|
data/lib/starting_blocks.rb
CHANGED
@@ -82,16 +82,10 @@ module StartingBlocks
|
|
82
82
|
def run_all_specs
|
83
83
|
->() do
|
84
84
|
contract = StartingBlocks::Contract.for StartingBlocks.options
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
end.flatten
|
90
|
-
files = file_specs.map do |d|
|
91
|
-
Dir[d].
|
92
|
-
select { |f| File.file?(f) }.
|
93
|
-
map { |x| File.expand_path(x) }
|
94
|
-
end.flatten
|
85
|
+
files = Dir['**/*'].select { |f| File.file? f }
|
86
|
+
.map { |x| File.expand_path x }.flatten
|
87
|
+
files = StartingBlocks::Watcher.filter_files_by_file_clues files, contract.file_clues
|
88
|
+
files = StartingBlocks::Watcher.filter_files_according_to_the_contract files, contract
|
95
89
|
StartingBlocks::Runner.new(StartingBlocks.options).run_files files
|
96
90
|
end
|
97
91
|
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe StartingBlocks::Watcher do
|
4
|
+
|
5
|
+
describe "filter files according to the contract" do
|
6
|
+
|
7
|
+
[
|
8
|
+
[['.rb'], ['apple.rb', 'orange.py'], ['apple.rb']],
|
9
|
+
[['.rb'], ['apple.py', 'orange.rb'], ['orange.rb']],
|
10
|
+
[['.txt'], ['/test/something.txt', 'another.txt'], ['/test/something.txt', 'another.txt']],
|
11
|
+
[['.txt'], ['/test/something.TXT', 'another.Txt'], ['/test/something.TXT', 'another.Txt']],
|
12
|
+
[['.txt', '.rb'], ['a.txt', 'b.rb', 'c.cs'], ['a.txt', 'b.rb']],
|
13
|
+
[['txt', 'rb'], ['a.txt', 'b.rb', 'c.cs'], ['a.txt', 'b.rb']],
|
14
|
+
[[''], ['a.txt', 'Gemfile'], ['Gemfile']],
|
15
|
+
].map { |a| Struct.new(:extensions, :files, :expected_results).new(*a) }.each do |example|
|
16
|
+
|
17
|
+
describe "multiple examples" do
|
18
|
+
|
19
|
+
it "should filter the files" do
|
20
|
+
|
21
|
+
contract = Struct.new(:extensions).new example.extensions
|
22
|
+
results = StartingBlocks::Watcher.filter_files_according_to_the_contract example.files, contract
|
23
|
+
|
24
|
+
results.must_equal example.expected_results
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "filtering files according to file clues" do
|
35
|
+
|
36
|
+
[
|
37
|
+
[
|
38
|
+
['one_test.txt'], ['_test'], ['one_test.txt']
|
39
|
+
],
|
40
|
+
[
|
41
|
+
['one_spec.txt'], ['_test'], [],
|
42
|
+
],
|
43
|
+
[
|
44
|
+
['two_spec.txt', 'three_test.txt'], ['_spec', '_test'], ['two_spec.txt', 'three_test.txt'],
|
45
|
+
],
|
46
|
+
[
|
47
|
+
['another', 'two_spec.txt', 'three_test.txt'], ['_spec', '_test'], ['two_spec.txt', 'three_test.txt'],
|
48
|
+
],
|
49
|
+
].map { |x| Struct.new(:files, :clues, :expected).new(*x) }.each do |example|
|
50
|
+
|
51
|
+
describe "multiple examples" do
|
52
|
+
it "should return the expected results" do
|
53
|
+
results = StartingBlocks::Watcher.filter_files_by_file_clues example.files, example.clues
|
54
|
+
results.must_equal example.expected
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: starting_blocks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Darren Cauthon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -123,6 +123,7 @@ files:
|
|
123
123
|
- spec/starting_blocks/result_parser_spec.rb
|
124
124
|
- spec/starting_blocks/result_text_parser_spec.rb
|
125
125
|
- spec/starting_blocks/runner_spec.rb
|
126
|
+
- spec/starting_blocks/watcher_spec.rb
|
126
127
|
- starting_blocks.gemspec
|
127
128
|
homepage: http://www.github.com/darrencauthon/starting_blocks
|
128
129
|
licenses:
|
@@ -154,3 +155,4 @@ test_files:
|
|
154
155
|
- spec/starting_blocks/result_parser_spec.rb
|
155
156
|
- spec/starting_blocks/result_text_parser_spec.rb
|
156
157
|
- spec/starting_blocks/runner_spec.rb
|
158
|
+
- spec/starting_blocks/watcher_spec.rb
|