The how (sow) tool requires the gem name called project as the (only) input and (auto-)derives all other names. Example:
- klass =>
Hello
- test_klass =>
TestHello
- file_name =>
hello
- ext_name =>
hello
- test_file_name =>
test_hello
- bin_file_name =>
hello
- modules =>
lib/hello.rb
:
class Hello
...
end
test/test_hello.rb
:
class TestHello < Minitest::Test
...
end
- klass =>
Pack::Hello
- test_klass =>
TestPack::TestHello
- file_name =>
pack/hello
- ext_name =>
hello
- test_file_name =>
pack/test_hello
- bin_file_name =>
pack_hello
- modules =>
Pack
lib/pack/hello.rb
:
module Pack ; end
class Pack::Hello
...
end
test/pack/test_hello.rb
:
module TestPack ; end
class TestPack::TestHello < Minitest::Test
...
end
- klass =>
Pack::Subpack::HelloWorld
- test_klass =>
TestPack::TestSubpack::TestHelloWorld
- file_name =>
pack/subpack/hello_world
- ext_name =>
hello
- test_file_name =>
pack/subpack/test_hello_world
- bin_file_name =>
pack_subpack_hello_world
- modules =>
Pack
,Subpack
lib/pack/subpack/hello_world.rb
:
module Pack ; end
module Pack::Subpack ; end
class Pack::Subpack::HelloWorld
...
end
test/pack/subpack/test_hello_world.rb
:
module TestPack ; end
module TestPack::TestSubpack ; end
class Testpack::Testsubpack::TestHelloWorld < Minitest::Test
...
end
See the hoe/template folder in the hoe source repo for the original template.
See the hoe/bin/sow bin(ary) command line tool source for the original "hand-coded" built-in template merger machinery.
Formula for Deriving Names
project = project.gsub(/([A-Z])/, '_\1').downcase.sub(/^_/, "")
klass = project.gsub(/(?:^|_)([a-z])/) { $1.upcase }
klass = klass. gsub(/(?:^|-)([a-z])/) { "::#{$1.upcase}" }
test_klass = klass. gsub(/(^|::)([A-Z])/) { "#{$1}Test#{$2}" }
file_name = project.gsub(/-/, "/")
Comments from the source:
Project names are lowercase with
_
separating package parts and-
separating extension parts.File names are lowercase with
_
separating package parts and/
separating extension parts.net-http-persistent
becomesnet/http/persistent
.Klass names are
CamelCase
with::
separating extension parts.Test klass names are same as Klass with Test prepended to each part.
add some more hoe links here
- set file mode for files in /bin/ e.g. chmod a+x
- check if file mode gets lost in unpacking of zip ??
- possible to ship zip archive w/ file mode set ???