Repository navigation
fix: reject plugin names that cannot be a Ruby constant - #80
Merged
Merged
Conversation
A plugin name becomes three things: a require path, a directory name and a Ruby
constant. Only the last is fussy, and Thor's `camel_case` folds underscores but
not hyphens -- so a perfectly reasonable `busser plugin create my-junit`
produced this:
```ruby
module Busser
module My-junit
VERSION = "0.1.0.dev"
end
end
```
That is not parseable Ruby. The generator reported every file it wrote, ran
`git init`, exited 0, and left a project that could not be loaded at all. The
author only found out when they tried to use it.
The name is now validated before anything is written, and the error suggests a
name that would work:
```text
$ busser plugin create my-junit
'my-junit' is not a usable plugin name. A name becomes a Ruby constant, so it
must start with a lowercase letter and contain only lowercase letters, digits
and underscores. Try 'my_junit'.
```
Eleven specs cover it: five names that must keep working, six that are rejected
-- hyphen, uppercase start, leading digit, space, empty and a path fragment --
plus that nothing is written on rejection and that the suggestion is usable.
Signed-off-by: Tim Smith <tsmith84@proton.me>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix: reject plugin names that cannot be a Ruby constant
A plugin name becomes three things: a require path, a directory name and a Ruby
constant. Only the last is fussy, and Thor's
camel_casefolds underscores butnot hyphens -- so a perfectly reasonable
busser plugin create my-junitproduced this:
That is not parseable Ruby. The generator reported every file it wrote, ran
git init, exited 0, and left a project that could not be loaded at all. Theauthor only found out when they tried to use it.
The name is now validated before anything is written, and the error suggests a
name that would work:
Eleven specs cover it: five names that must keep working, six that are rejected
-- hyphen, uppercase start, leading digit, space, empty and a path fragment --
plus that nothing is written on rejection and that the suggestion is usable.