Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix gem_build template on Windows #243

Merged
merged 1 commit into from
Oct 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: Fix build template on Windows
dazuma committed Oct 17, 2023
commit 82858039b8c9930f834021db5afa6bce3fb861c0
11 changes: 7 additions & 4 deletions toys/lib/toys/templates/gem_build.rb
Original file line number Diff line number Diff line change
@@ -186,13 +186,16 @@ def name
#
def gem_name(context_dir = nil)
return @gem_name if @gem_name
glob = "*.gemspec"
glob = ::File.join(context_dir, glob) if context_dir
candidates = ::Dir.glob(glob)
candidates =
if context_dir
Compat.glob_in_dir("*.gemspec", context_dir)
else
::Dir.glob("*.gemspec")
end
if candidates.empty?
raise ToolDefinitionError, "Could not find a gemspec"
end
candidates.first.sub(/\.gemspec$/, "")
::File.basename(candidates.first, ".gemspec")
end

##
8 changes: 8 additions & 0 deletions toys/test/test_gem_build.rb
Original file line number Diff line number Diff line change
@@ -27,6 +27,14 @@
assert_equal("toys", template.gem_name)
end

it "handles the gem_name field with a context dir" do
assert_equal("toys", template.gem_name(toys_dir))
template.gem_name = "toys-core"
assert_equal("toys-core", template.gem_name(toys_dir))
template.gem_name = nil
assert_equal("toys", template.gem_name(toys_dir))
end

it "handles the output field" do
assert_nil(template.output)
template.output = "/path/to/somewhere"