Skip to content

Add --gem-source to "hanami new" - #357

Merged
timriley merged 1 commit into
mainfrom
356-gem-server
Oct 29, 2025
Merged

timriley merged 1 commit into
mainfrom
356-gem-server

Conversation

@svoop

@svoop svoop commented Oct 27, 2025

Copy link
Copy Markdown
Member

This adds --gem-server to hanami new which facilitates the use of an alternative or private gem server:

hanami new --gem-server=https://gem.coop bookshelf

Closes #356

@timriley

Copy link
Copy Markdown
Member

@svoop Thanks for doing this! Looks like you've included one of my earlier commits by accident?

@timriley

Copy link
Copy Markdown
Member

Also, bit of feedback: we should make this so that --gem-server=gem.coop is a valid argument. The feels a lot better than having to type the full https:// in front. So: if there's a URI scheme given, accept it, otherwise prefix the given argument with https://. Does that sound OK?

@svoop

svoop commented Oct 28, 2025 •

Copy link
Copy Markdown
Member Author

@timriley

Thanks for doing this! Looks like you've included one of my earlier commits by accident?

Ah, classic, one small click for a man, a giant mess for the PR. No problem though, I'll fix this.

we should make this so that --gem-server=gem.coop is a valid argument

You're right, particularly since the CLI arg is called --gem-server, the protocol is not really needed there. I included it to accommodate probably purely theoretical situations in which someone runs a private gem server or mirror locally without SSL. But in this case, the CLI arg had better be named --gem-source. I usually prefer alignment (e.g. --gem-source maps to source in the Gemfile) for transparency, but I'm indifferent on this one, even more so since it will eventually be replaced by interactive prompts, so I'll change that as well.

All that right after some inevitable morning exercise and a good cup of coffee. 😄 Thanks for the feedback!

@timriley

Copy link
Copy Markdown
Member

@svoop oh yes, let's go with --gem-source. This was the name I had envisioned earlier, but I typed the wrong then when I created this ticket.

@timriley timriley changed the title Add --gem-server to "hanami new" Add --gem-source to "hanami new" Oct 28, 2025
@timriley

Copy link
Copy Markdown
Member

(Updated the ticket title to reflect this)

@svoop

svoop commented Oct 28, 2025

Copy link
Copy Markdown
Member Author

Alright, just to confirm, that's --gem-source but without the protocol, isn't it?

@timriley

timriley commented Oct 28, 2025 •

Copy link
Copy Markdown
Member

@svoop I think we should allow both (in the spirit of Postel's law):

--gem-source=gem.coop
--gem-source=https://gem.coop

We should document the first. It's nicer looking and easier to type :)

@svoop

svoop commented Oct 28, 2025

Copy link
Copy Markdown
Member Author

@timriley Here you go: CLI arg is now --gem-source with or without scheme. Btw: My initial test was flawed, I've fixed that as well. However, I'm not using kwargs (but merge into it) in the newly added tests in new_spec.rb because by doing so I wouldn't be able to test the default gem source "rubygems.org".

@timriley

Copy link
Copy Markdown
Member

Thanks @svoop, this is great! The testing approach seems sensible to me too.

@timriley
timriley merged commit 667c409 into main Oct 29, 2025
12 checks passed
@timriley
timriley deleted the 356-gem-server branch October 29, 2025 06:24
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.

Add --gem-source to hanami new, allowing e.g. --gem-source=gem.coop

2 participants