batcave 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/Makefile +5 -1
- data/batcave.gemspec +1 -1
- data/lib/batcave/command/test.rb +59 -0
- data/lib/batcave/main.rb +4 -0
- data/things/ruby/self/Makefile +5 -1
- metadata +11 -5
data/Makefile
CHANGED
@@ -35,7 +35,7 @@ $(GEM):
|
|
35
35
|
test-package: $(GEM)
|
36
36
|
# Sometimes 'gem build' makes a faulty gem.
|
37
37
|
gem unpack $(GEM)
|
38
|
-
rm -rf
|
38
|
+
rm -rf $(NAME)-$(VERSION)/
|
39
39
|
|
40
40
|
.PHONY: publish
|
41
41
|
publish: test-package
|
@@ -44,3 +44,7 @@ publish: test-package
|
|
44
44
|
.PHONY: install
|
45
45
|
install: $(GEM)
|
46
46
|
gem install $(GEM)
|
47
|
+
|
48
|
+
.PHONY: clean
|
49
|
+
clean:
|
50
|
+
-rm -rf .yardoc $(GEM) $(NAME)-$(VERSION)/
|
data/batcave.gemspec
CHANGED
@@ -2,7 +2,7 @@ Gem::Specification.new do |spec|
|
|
2
2
|
files = %x{git ls-files}.split("\n")
|
3
3
|
|
4
4
|
spec.name = "batcave"
|
5
|
-
spec.version = "0.0.
|
5
|
+
spec.version = "0.0.7"
|
6
6
|
spec.summary = "Experiments in tools, boilerplatery, debugging, etc."
|
7
7
|
spec.description = spec.summary
|
8
8
|
spec.add_dependency("clamp")
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require "clamp"
|
2
|
+
require "batcave/namespace"
|
3
|
+
|
4
|
+
class BatCave::Command::Test < Clamp::Command
|
5
|
+
parameter "FILES ...", "Files to test", :attribute_name => :files
|
6
|
+
|
7
|
+
private
|
8
|
+
|
9
|
+
def gitroot(dir=Dir.pwd)
|
10
|
+
Dir.chdir(dir) do
|
11
|
+
return `git rev-parse --show-toplevel 2> /dev/null`.split("\n").first
|
12
|
+
end
|
13
|
+
end # def root
|
14
|
+
|
15
|
+
def execute
|
16
|
+
# Assume all files are in the same project.
|
17
|
+
project_root = gitroot(File.dirname(files.first)) + "/"
|
18
|
+
|
19
|
+
relative_paths = files.collect { |a| File.realpath(a).gsub(project_root, "") }
|
20
|
+
success = true
|
21
|
+
Dir.chdir(project_root) do
|
22
|
+
commands = relative_paths.collect { |p| path_test_command(p) }.select { |p| !p.nil? }
|
23
|
+
commands.each do |command|
|
24
|
+
system(*command)
|
25
|
+
success &&= $?.success?
|
26
|
+
end # commands.each
|
27
|
+
end
|
28
|
+
return success ? 0 : 1
|
29
|
+
end # def execute
|
30
|
+
|
31
|
+
def path_test_command(path)
|
32
|
+
if path =~ /^lib\//
|
33
|
+
# Try {spec,test}/path/to/thing.rb for lib/project/path/to/thing.rb
|
34
|
+
with(path.gsub(/^lib\/[^\/]+\//, "spec/")) { |p| path = p if File.exists?(p) }
|
35
|
+
with(path.gsub(/^lib\/[^\/]+\//, "test/")) { |p| path = p if File.exists?(p) }
|
36
|
+
|
37
|
+
# Try {spec,test}/path/to/thing.rb for lib/path/to/thing.rb
|
38
|
+
with(path.gsub(/^lib\//, "spec/")) { |p| path = p if File.exists?(p) }
|
39
|
+
with(path.gsub(/^lib\//, "test/")) { |p| path = p if File.exists?(p) }
|
40
|
+
end
|
41
|
+
|
42
|
+
case path
|
43
|
+
when /^spec\/.*\.rb$/ ; return ["rspec", path]
|
44
|
+
when /^test\/.*\.rb$/ ; return ["ruby", path]
|
45
|
+
when /\.rb$/ ; return [ "ruby", "-c", path]
|
46
|
+
when /\.sh$/ ; return [ "sh", "-n", path]
|
47
|
+
when /\.pp$/ ; return [ "puppet", "parser", "validate", path ]
|
48
|
+
else ; logger.warn("Don't know how to test", :path => path)
|
49
|
+
end
|
50
|
+
|
51
|
+
return nil
|
52
|
+
end # def tests_for_path
|
53
|
+
|
54
|
+
def with(value, &block)
|
55
|
+
return block.call(value)
|
56
|
+
end # def with
|
57
|
+
|
58
|
+
public(:execute)
|
59
|
+
end
|
data/lib/batcave/main.rb
CHANGED
@@ -2,6 +2,7 @@ require "clamp"
|
|
2
2
|
require "batcave/namespace"
|
3
3
|
require "batcave/command/add"
|
4
4
|
require "batcave/command/update"
|
5
|
+
require "batcave/command/test"
|
5
6
|
require "cabin"
|
6
7
|
|
7
8
|
class BatCave::Main < Clamp::Command
|
@@ -18,4 +19,7 @@ class BatCave::Main < Clamp::Command
|
|
18
19
|
# Update the batcave from upstream. This will keep you updated with
|
19
20
|
# the latest in gadgets and useful tools.
|
20
21
|
subcommand "update", "Update the things in your bat cave.", BatCave::Command::Update
|
22
|
+
|
23
|
+
# Run a file's tests.
|
24
|
+
subcommand "test", "Run the tests for a given file", BatCave::Command::Test
|
21
25
|
end
|
data/things/ruby/self/Makefile
CHANGED
@@ -35,7 +35,7 @@ $(GEM):
|
|
35
35
|
test-package: $(GEM)
|
36
36
|
# Sometimes 'gem build' makes a faulty gem.
|
37
37
|
gem unpack $(GEM)
|
38
|
-
rm -rf
|
38
|
+
rm -rf $(NAME)-$(VERSION)/
|
39
39
|
|
40
40
|
.PHONY: publish
|
41
41
|
publish: test-package
|
@@ -44,3 +44,7 @@ publish: test-package
|
|
44
44
|
.PHONY: install
|
45
45
|
install: $(GEM)
|
46
46
|
gem install $(GEM)
|
47
|
+
|
48
|
+
.PHONY: clean
|
49
|
+
clean:
|
50
|
+
-rm -rf .yardoc $(GEM) $(NAME)-$(VERSION)/
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: batcave
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-10-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: clamp
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,12 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
25
30
|
description: Experiments in tools, boilerplatery, debugging, etc.
|
26
31
|
email: jls@semicomplete.com
|
27
32
|
executables:
|
@@ -38,6 +43,7 @@ files:
|
|
38
43
|
- bin/dk
|
39
44
|
- lib/batcave/action/add.rb
|
40
45
|
- lib/batcave/command/add.rb
|
46
|
+
- lib/batcave/command/test.rb
|
41
47
|
- lib/batcave/command/update.rb
|
42
48
|
- lib/batcave/dsl.rb
|
43
49
|
- lib/batcave/main.rb
|
@@ -77,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
83
|
version: '0'
|
78
84
|
requirements: []
|
79
85
|
rubyforge_project:
|
80
|
-
rubygems_version: 1.8.
|
86
|
+
rubygems_version: 1.8.24
|
81
87
|
signing_key:
|
82
88
|
specification_version: 3
|
83
89
|
summary: Experiments in tools, boilerplatery, debugging, etc.
|