batcave 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.
- data/.gitignore +1 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +10 -0
- data/README.md +28 -0
- data/batcave.gemspec +17 -0
- data/bin/dk +8 -0
- data/lib/batcave/command/add.rb +63 -0
- data/lib/batcave/command/update.rb +8 -0
- data/lib/batcave/main.rb +13 -0
- data/lib/batcave/namespace.rb +5 -0
- data/lib/batcave/support/git.rb +11 -0
- data/things/go/self/THING +0 -0
- data/things/go/self/src/{name}/{name}.go +10 -0
- data/things/ruby/self/Gemfile +1 -0
- data/things/ruby/self/THING +1 -0
- data/things/ruby/self/test/all.rb +24 -0
- data/things/ruby/self/test/docs.rb +40 -0
- data/things/ruby/self/test/testing.rb +14 -0
- metadata +75 -0
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
.*.swp
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/README.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# batcave
|
2
|
+
|
3
|
+
Wikipedia on "Batcave" uses:
|
4
|
+
|
5
|
+
> Upon his initial foray into crime-fighting, Wayne used the caves as a sanctum
|
6
|
+
> and to store his then-minimal equipment. As time went on, Wayne found the place
|
7
|
+
> ideal to create a stronghold for his war against crime, and has incorporated a
|
8
|
+
> plethora of equipment as well as expanding the cave for specific uses.
|
9
|
+
|
10
|
+
As in coding, you start with some minimal tools and gradually find better
|
11
|
+
tools, better flows, etc.
|
12
|
+
|
13
|
+
This project is an experiment to try and make batcave construction possible.
|
14
|
+
|
15
|
+
Maybe, for example, I'm writing an HTTP library in Ruby, and I want to:
|
16
|
+
|
17
|
+
* run whatever services I need to test this code (like a webserver)
|
18
|
+
* run tests whenever I modify the code.
|
19
|
+
* make sure all methods have docstrings (with YARD)
|
20
|
+
* have some useful debugging tools.
|
21
|
+
|
22
|
+
But new projects should be easier:
|
23
|
+
|
24
|
+
* create a 'go' project with a layout that works well with 'goinstall'
|
25
|
+
* create a 'ruby' project with a standard layout, Gemfile, gemspec, etc
|
26
|
+
* etc.
|
27
|
+
|
28
|
+
Release management should be easier, too.
|
data/batcave.gemspec
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
files = %x{git ls-files}.split("\n")
|
3
|
+
|
4
|
+
spec.name = "batcave"
|
5
|
+
spec.version = "0.0.1"
|
6
|
+
spec.summary = "Experiments in tools, boilerplatery, debugging, etc."
|
7
|
+
spec.summary = spec.description
|
8
|
+
spec.add_dependency("clamp")
|
9
|
+
spec.files = files
|
10
|
+
spec.bindir = "bin"
|
11
|
+
spec.executables << "dk"
|
12
|
+
|
13
|
+
spec.author = "Jordan Sissel"
|
14
|
+
spec.email = "jls@semicomplete.com"
|
15
|
+
spec.homepage = "https://github.com/jordansissel/batcave"
|
16
|
+
end
|
17
|
+
|
data/bin/dk
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
require "clamp"
|
2
|
+
require "batcave/namespace"
|
3
|
+
require "batcave/support/git"
|
4
|
+
require "fileutils"
|
5
|
+
|
6
|
+
class BatCave::Command::Add < Clamp::Command
|
7
|
+
include BatCave::Support::Git
|
8
|
+
|
9
|
+
option ["-n", "--name"], "NAME",
|
10
|
+
"the application or library name", :attribute_name => :name
|
11
|
+
|
12
|
+
parameter "THING",
|
13
|
+
"The thing to add to your batcave", :attribute_name => :thing
|
14
|
+
|
15
|
+
def execute
|
16
|
+
# TODO(sissel): Move this stuff into a proper batcave library
|
17
|
+
|
18
|
+
found = false
|
19
|
+
# look for the 'thing/' or if it's a directory try 'thing/self/'
|
20
|
+
[ @thing, File.join(@thing, "self") ].each do |thing|
|
21
|
+
path = File.join(BatCave::THINGSDIR, thing)
|
22
|
+
config = File.join(path, "THING")
|
23
|
+
if File.exists?(config)
|
24
|
+
found = true
|
25
|
+
use(path)
|
26
|
+
break
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
if !found
|
31
|
+
puts "Could not find any thing '#{@thing}'"
|
32
|
+
end
|
33
|
+
end # def execute
|
34
|
+
|
35
|
+
def use(dir)
|
36
|
+
config = File.join(dir, "THING")
|
37
|
+
paths = Dir.glob(File.join(dir, "**", "*"))
|
38
|
+
|
39
|
+
paths.each do |path|
|
40
|
+
next if path == config # skip the 'THING' file
|
41
|
+
localpath = File.join(project_root, path[dir.length + 1 .. -1])
|
42
|
+
|
43
|
+
if localpath.include?("{name}")
|
44
|
+
if @name.nil?
|
45
|
+
raise "Path requires '--name' flag to be set: #{localpath.inspect}"
|
46
|
+
end
|
47
|
+
localpath.gsub!("{name}", @name)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Replace '{...}' in localpath
|
51
|
+
|
52
|
+
# TODO(sissel): if this is a directory, create it.
|
53
|
+
# TODO(sissel): if this a file, copy it.
|
54
|
+
if File.directory?(path)
|
55
|
+
FileUtils.mkdir_p(localpath) unless File.directory?(localpath)
|
56
|
+
else
|
57
|
+
localdir = File.dirname(localpath)
|
58
|
+
FileUtils.mkdir_p(localdir) unless File.directory?(localdir)
|
59
|
+
FileUtils.cp(path, localpath)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
data/lib/batcave/main.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require "clamp"
|
2
|
+
require "batcave/namespace"
|
3
|
+
require "batcave/command/add"
|
4
|
+
require "batcave/command/update"
|
5
|
+
|
6
|
+
class BatCave::Main < Clamp::Command
|
7
|
+
# Add something to your bat cave.
|
8
|
+
subcommand "add", "Add something to your batcave", BatCave::Command::Add
|
9
|
+
|
10
|
+
# Update the batcave from upstream. This will keep you updated with
|
11
|
+
# the latest in gadgets and useful tools.
|
12
|
+
subcommand "update", "Update the things in your bat cave.", BatCave::Command::Update
|
13
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require "batcave/namespace"
|
2
|
+
|
3
|
+
module BatCave::Support::Git
|
4
|
+
def project_root
|
5
|
+
root = %x{git rev-parse --show-toplevel}.chomp
|
6
|
+
if $?.exitstatus != 0
|
7
|
+
raise "'git rev-parse --show-toplevel' failed. No project root found. Is this in a git clone?"
|
8
|
+
end
|
9
|
+
return root
|
10
|
+
end # def project_root
|
11
|
+
end # class BatCave::Support::Git
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
source :rubygems
|
@@ -0,0 +1 @@
|
|
1
|
+
boilerplate = [ "Gemfile" ]
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "minitest/spec"
|
3
|
+
require "minitest/autorun"
|
4
|
+
|
5
|
+
# Get coverage report
|
6
|
+
require "simplecov"
|
7
|
+
SimpleCov.start
|
8
|
+
|
9
|
+
# Add '../lib' to the require path.
|
10
|
+
$: << File.join(File.dirname(__FILE__), "..", "lib")
|
11
|
+
|
12
|
+
def use(path)
|
13
|
+
puts "Loading tests from #{path}"
|
14
|
+
require File.expand_path(path)
|
15
|
+
end
|
16
|
+
|
17
|
+
dirname = File.dirname(__FILE__)
|
18
|
+
use File.join(dirname, "docs.rb")
|
19
|
+
|
20
|
+
# Load tests from ./*/**/*.rb (usually ./libraryname/....)
|
21
|
+
glob = File.join(dirname, "*", "**", "*.rb")
|
22
|
+
Dir.glob(glob).each do |path|
|
23
|
+
use path
|
24
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "yard"
|
3
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), "testing")
|
4
|
+
|
5
|
+
describe "documentation tests" do
|
6
|
+
before do
|
7
|
+
# Use YARD to parse all ruby files found in '../lib'
|
8
|
+
libdir = File.join(File.dirname(__FILE__), "..", "lib")
|
9
|
+
YARD::Registry.load(Dir.glob(File.join(libdir, "**", "*.rb")))
|
10
|
+
@registry = YARD::Registry.all
|
11
|
+
end
|
12
|
+
|
13
|
+
test "All classes, methods, modules, and constants must be documented" do
|
14
|
+
# Note, the 'find the undocumented things' code here is
|
15
|
+
# copied mostly from: YARD 0.7.5's lib/yard/cli/stats.rb
|
16
|
+
#
|
17
|
+
# Find all undocumented classes, modules, and constants
|
18
|
+
undocumented = @registry.select do |o|
|
19
|
+
[:class, :module, :constant].include?(o.type) && o.docstring.blank?
|
20
|
+
end
|
21
|
+
|
22
|
+
# Find all undocumented methods
|
23
|
+
methods = @registry.select { |m| m.type == :method }
|
24
|
+
methods.reject! { |m| m.is_alias? || !m.is_explicit? }
|
25
|
+
undocumented += methods.select do |m|
|
26
|
+
m.docstring.blank? && !m.overridden_method
|
27
|
+
end
|
28
|
+
|
29
|
+
if (undocumented.length > 0)
|
30
|
+
message = ["The following are not documented"]
|
31
|
+
undocumented.each do |o|
|
32
|
+
message << "* #{o.type.to_s} #{o.to_s} <#{o.file}:#{o.line}>"
|
33
|
+
end
|
34
|
+
|
35
|
+
flunk(message.join("\n"))
|
36
|
+
else
|
37
|
+
pass
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "minitest/spec"
|
3
|
+
|
4
|
+
# Add '../lib' to the require path.
|
5
|
+
$: << File.join(File.dirname(__FILE__), "..", "lib")
|
6
|
+
|
7
|
+
# I don't really like monkeypatching, but whatever, this is probably better
|
8
|
+
# than overriding the 'describe' method.
|
9
|
+
class MiniTest::Spec
|
10
|
+
class << self
|
11
|
+
# 'it' sounds wrong, call it 'test'
|
12
|
+
alias :test :it
|
13
|
+
end
|
14
|
+
end
|
metadata
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: batcave
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jordan Sissel
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-02-14 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: clamp
|
16
|
+
requirement: &17501600 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *17501600
|
25
|
+
description:
|
26
|
+
email: jls@semicomplete.com
|
27
|
+
executables:
|
28
|
+
- dk
|
29
|
+
extensions: []
|
30
|
+
extra_rdoc_files: []
|
31
|
+
files:
|
32
|
+
- .gitignore
|
33
|
+
- Gemfile
|
34
|
+
- Gemfile.lock
|
35
|
+
- README.md
|
36
|
+
- batcave.gemspec
|
37
|
+
- bin/dk
|
38
|
+
- lib/batcave/command/add.rb
|
39
|
+
- lib/batcave/command/update.rb
|
40
|
+
- lib/batcave/main.rb
|
41
|
+
- lib/batcave/namespace.rb
|
42
|
+
- lib/batcave/support/git.rb
|
43
|
+
- things/go/self/THING
|
44
|
+
- things/go/self/src/{name}/{name}.go
|
45
|
+
- things/ruby/self/Gemfile
|
46
|
+
- things/ruby/self/THING
|
47
|
+
- things/ruby/self/test/all.rb
|
48
|
+
- things/ruby/self/test/docs.rb
|
49
|
+
- things/ruby/self/test/testing.rb
|
50
|
+
homepage: https://github.com/jordansissel/batcave
|
51
|
+
licenses: []
|
52
|
+
post_install_message:
|
53
|
+
rdoc_options: []
|
54
|
+
require_paths:
|
55
|
+
- lib
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ! '>='
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
requirements: []
|
69
|
+
rubyforge_project:
|
70
|
+
rubygems_version: 1.8.10
|
71
|
+
signing_key:
|
72
|
+
specification_version: 3
|
73
|
+
summary: ''
|
74
|
+
test_files: []
|
75
|
+
has_rdoc:
|