rubygems / rfcs

RubyGems + Bundler RFCs
45 stars 40 forks source link

Named Sources #11

Closed seanhandley closed 6 years ago

seanhandley commented 6 years ago

Originally here: https://github.com/bundler/bundler/issues/6298

I'd like to propose a new feature that allows naming of gem sources.

Before I start wrestling with the DSL code, I'd like to get some feedback from the community.

What we currently have

source "https://rubygems.org"

gem "other_gem"

gem "my_private_gem", source: "https://my-gem-server.org"

OR

source "https://rubygems.org"

gem "other_gem"

source "https://my-gem-server.org" do
  gem "my_private_gem"
end

What I'm proposing

source "https://my-gem-server.org", name: :my_gem_server

gem "other_gem"
gem "my_private_gem", source: :my_gem_server

OR

source "https://rubygems.org"
source "https://my-gem-server.org", name: :my_gem_server

gem "other_gem"

source :my_gem_server do
  gem "my_private_gem"
end

Why?

Because I'd like to be able to change the source URL in one place and have it update in other places within the Gemfile automatically, keeping things DRY and easy to maintain.

I also feel there's value in being able to see a list of gem server sources at the top of the file instead of trawling through the whole file looking for source URLs.

@indirect @segiddins @hsbt Thoughts?

segiddins commented 6 years ago

At work, we just store sources in variables and use those.

Eg binary_url = “...” gem “foo”, source: binary_url

seanhandley commented 6 years ago

Ah awesome @segiddins. I forgot that a Gemfile is still Ruby code. Thanks!