Skip to content

Commit 22aa0d8

Browse files
committed
generate subdirs by creating a version.rb file
1 parent 8ad8ba9 commit 22aa0d8

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

mrblib/mruby-cli/setup.rb

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ def run
2121
create_dir("mrblib")
2222
write_file("mrblib/#{@name}.rb", mrblib)
2323

24+
create_dir("mrblib/#{@name}")
25+
write_file("mrblib/#{@name}/version.rb", version)
26+
2427
create_dir("bintest")
2528
write_file("bintest/#{@name}.rb", bintest)
2629

@@ -83,6 +86,13 @@ def bintest
8386
assert_true status.success?, "Process did not exit cleanly"
8487
assert_include output, "Hello World"
8588
end
89+
90+
assert('version') do
91+
output, status = Open3.capture2(BIN_PATH, "version")
92+
93+
assert_true status.success?, "Process did not exit cleanly"
94+
assert_include output, "v0.0.1"
95+
end
8696
BINTEST
8797
end
8898

@@ -246,11 +256,23 @@ def tools
246256
def mrblib
247257
<<TOOLS
248258
def __main__(argv)
249-
puts "Hello World"
259+
if argv[1] == "version"
260+
puts "v\#{#{Util.camelize(@name)}::VERSION}"
261+
else
262+
puts "Hello World"
263+
end
250264
end
251265
TOOLS
252266
end
253267

268+
def version
269+
<<VERSION
270+
module #{Util.camelize(@name)}
271+
VERSION = "0.0.1"
272+
end
273+
VERSION
274+
end
275+
254276
def dockerfile
255277
<<DOCKERFILE
256278
FROM hone/mruby-cli

0 commit comments

Comments
 (0)