starting_blocks 0.0.7 → 0.0.8
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.
- data/bin/sb +11 -49
- data/lib/starting_blocks/runner.rb +19 -0
- data/lib/starting_blocks/version.rb +1 -1
- data/lib/starting_blocks/watcher.rb +46 -0
- data/lib/starting_blocks.rb +2 -0
- metadata +5 -3
data/bin/sb
CHANGED
@@ -1,64 +1,26 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require '
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/../lib/starting_blocks.rb')
|
4
|
+
|
5
|
+
options = {}
|
4
6
|
|
5
7
|
def display value
|
6
8
|
end
|
7
9
|
|
8
10
|
if ARGV.include? '--verbose'
|
9
|
-
|
10
|
-
puts value
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def run_all_specs
|
15
|
-
specs = Dir['**/*_spec.rb*'].select { |f| File.file?(f) }.map do |x|
|
16
|
-
File.expand_path(x)
|
17
|
-
end
|
18
|
-
|
19
|
-
run_these_specs specs
|
20
|
-
end
|
21
|
-
|
22
|
-
def run_these_specs specs
|
23
|
-
requires = specs.map { |x| "require '#{x}'" }.join("\n")
|
24
|
-
display "Specs to run: #{specs.inspect}"
|
25
|
-
puts `ruby -e "#{requires}"`
|
11
|
+
options[:verbose] = true
|
26
12
|
end
|
27
13
|
|
14
|
+
def run_all_specs options
|
15
|
+
specs = Dir['**/*_spec.rb*'].
|
16
|
+
select { |f| File.file?(f) }.
|
17
|
+
map { |x| File.expand_path(x) }
|
28
18
|
|
29
|
-
|
30
|
-
return if file.index('.git') == 0
|
31
|
-
display "Adding: #{file}"
|
32
|
-
files << file
|
33
|
-
end
|
34
|
-
|
35
|
-
def run_it(file, files)
|
36
|
-
filename = file.downcase.split('/')[-1].gsub('_spec', '')
|
37
|
-
display "File to run is: #{file}"
|
38
|
-
display "Filename: #{filename}"
|
39
|
-
matches = files.select { |x| x.gsub('_spec.rb', '.rb').include?(filename) && x != file }
|
40
|
-
matches << file
|
41
|
-
specs = matches.select { |x| x.include?('_spec') && File.file?(x) }.map { |x| File.expand_path x }
|
42
|
-
display "Matches: #{specs.inspect}"
|
43
|
-
run_these_specs specs
|
44
|
-
end
|
45
|
-
|
46
|
-
def delete_it(file, files)
|
47
|
-
return if file.index('.git') == 0
|
48
|
-
display "Deleting: #{file}"
|
49
|
-
files.delete(file)
|
19
|
+
StartingBlocks::Runner.new(options).run_files specs
|
50
20
|
end
|
51
21
|
|
52
22
|
if ARGV.include? '--watch'
|
53
|
-
|
54
|
-
segments = File.expand_path(Dir['*'].first).split('/')
|
55
|
-
segments.pop
|
56
|
-
location = segments.join('/')
|
57
|
-
FSSM.monitor(location, '**/*') do
|
58
|
-
update {|base, relative| run_it relative, files }
|
59
|
-
delete {|base, relative| delete_it relative, files }
|
60
|
-
create {|base, relative| add_it relative, files }
|
61
|
-
end
|
23
|
+
StartingBlocks::Watcher.start_watching Dir, options
|
62
24
|
else
|
63
|
-
run_all_specs
|
25
|
+
run_all_specs options
|
64
26
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module StartingBlocks
|
2
|
+
class Runner
|
3
|
+
def initialize options
|
4
|
+
@verbose = options[:verbose]
|
5
|
+
end
|
6
|
+
|
7
|
+
def run_files specs
|
8
|
+
requires = specs.map { |x| "require '#{x}'" }.join("\n")
|
9
|
+
display "Specs to run: #{specs.inspect}"
|
10
|
+
puts `ruby -e "#{requires}"`
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def display message
|
16
|
+
puts message if @verbose
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'fssm'
|
2
|
+
|
3
|
+
module StartingBlocks
|
4
|
+
module Watcher
|
5
|
+
class << self
|
6
|
+
def start_watching(dir, options)
|
7
|
+
location = dir.getwd
|
8
|
+
files = Dir['**/*']
|
9
|
+
FSSM.monitor(location, '**/*') do
|
10
|
+
update {|base, relative| StartingBlocks::Watcher.run_it relative, files, options }
|
11
|
+
delete {|base, relative| StartingBlocks::Watcher.delete_it relative, files, options }
|
12
|
+
create {|base, relative| StartingBlocks::Watcher.add_it relative, files, options }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def add_it(file, files, options)
|
17
|
+
return if file.index('.git') == 0
|
18
|
+
display "Adding: #{file}"
|
19
|
+
files << file
|
20
|
+
end
|
21
|
+
|
22
|
+
def run_it(file, files, options)
|
23
|
+
filename = file.downcase.split('/')[-1].gsub('_spec', '')
|
24
|
+
display "File to run is: #{file}"
|
25
|
+
display "Filename: #{filename}"
|
26
|
+
matches = files.select { |x| x.gsub('_spec.rb', '.rb').include?(filename) && x != file }
|
27
|
+
matches << file
|
28
|
+
specs = matches.select { |x| x.include?('_spec') && File.file?(x) }.map { |x| File.expand_path x }
|
29
|
+
display "Matches: #{specs.inspect}"
|
30
|
+
StartingBlocks::Runner.new(options).run_files specs
|
31
|
+
end
|
32
|
+
|
33
|
+
def delete_it(file, files, options)
|
34
|
+
return if file.index('.git') == 0
|
35
|
+
display "Deleting: #{file}"
|
36
|
+
files.delete(file)
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def display message
|
42
|
+
puts message if @verbose
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/lib/starting_blocks.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: starting_blocks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -74,7 +74,9 @@ files:
|
|
74
74
|
- Rakefile
|
75
75
|
- bin/sb
|
76
76
|
- lib/starting_blocks.rb
|
77
|
+
- lib/starting_blocks/runner.rb
|
77
78
|
- lib/starting_blocks/version.rb
|
79
|
+
- lib/starting_blocks/watcher.rb
|
78
80
|
- starting_blocks.gemspec
|
79
81
|
homepage: ''
|
80
82
|
licenses:
|
@@ -91,7 +93,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
91
93
|
version: '0'
|
92
94
|
segments:
|
93
95
|
- 0
|
94
|
-
hash: -
|
96
|
+
hash: -3323215234002932118
|
95
97
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
98
|
none: false
|
97
99
|
requirements:
|
@@ -100,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
102
|
version: '0'
|
101
103
|
segments:
|
102
104
|
- 0
|
103
|
-
hash: -
|
105
|
+
hash: -3323215234002932118
|
104
106
|
requirements: []
|
105
107
|
rubyforge_project:
|
106
108
|
rubygems_version: 1.8.25
|