Last active
May 7, 2019 02:29
-
-
Save stevenhaddox/8850903 to your computer and use it in GitHub Desktop.
Dynamic Gemfile Sources
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
--- | |
gem_sources: | |
- 'https://rubygems.org' | |
- 'http://rubygems.org' |
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
# Dynamically load gem sources from YAML config file | |
require 'yaml' | |
# See if we have a custom gem_sources.yml file, if not use the .example default. | |
if File.exist? File.expand_path("../config/gem_sources.yml", __FILE__) | |
gem_sources_file = File.expand_path("../config/gem_sources.yml", __FILE__) | |
puts "NOTE: Using the following gem sources from `config/gem_sources.yml`:" | |
@custom_gem_source = true | |
else | |
gem_sources_file = File.expand_path("../config/gem_sources.yml.example", __FILE__) | |
end | |
sources_yaml = YAML::load(File.read(gem_sources_file)) | |
sources_yaml['gem_sources'].each do |source_str| | |
puts source_str if @custom_gem_source | |
source source_str | |
end | |
# Put your gems below as usual |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment