Skip to content

Pull request: Fix a bug in setting gemspec license#93

Open
rleber wants to merge 3 commits intopiotrmurach:masterfrom
rleber:master
Open

Pull request: Fix a bug in setting gemspec license#93
rleber wants to merge 3 commits intopiotrmurach:masterfrom
rleber:master

Conversation

@rleber
Copy link
Copy Markdown

@rleber rleber commented Jun 10, 2025

Describe the change

Corrects an error I experienced trying to run teletype new: the count of spaces to add in padding the license for the gemspec was negative. I fixed this by ensuring that the padding count is always >= 0.

I also added .envrc to the .gitignore file, since I use direnv locally, but I don't think my settings should be included in the repository.

Why are we doing this?

This bug caused teletype new to fail.

Benefits

This makes the tool more reliable.

Drawbacks

None

Requirements

  • Tests written & passing locally?
  • Code style checked?
  • Rebased with master branch?
  • Documentation updated?
  • Changelog updated?

Note: Several test fail -- but they were already failing when I cloned the repo, before I made any changes.

gem_license = " " * gemspec.pre_var_indent
gem_license << "#{gemspec.var_name}.license"
gem_license << " " * (gemspec.post_var_indent - ".license".size)
gem_license << " " * [(gemspec.post_var_indent - ".license".size), 0].max
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Performance/FixedSize: Do not compute the size of statically sized objects.
Metrics/LineLength: Line is too long. [83/80]

gem_license = " " * gemspec.pre_var_indent
gem_license << "#{gemspec.var_name}.license"
gem_license << " " * (gemspec.post_var_indent - ".license".size)
gem_license << " " * [(gemspec.post_var_indent - ".license".size), 0].max
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
gem_license << " " * [(gemspec.post_var_indent - ".license".size), 0].max
gem_license << " " * [(gemspec.post_var_indent - ".license".size), 1].max

Using 0 as the minimum would produce spec.license= "MIT" (no space before =), which is inconsistent with the format bundler generates for other attributes (e.g. spec.name = "sandbox"). A minimum of 1 ensures the output matches the surrounding style.

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants