Skip to content

Commit

Permalink
Merge pull request #19 from sportngin/user_gemrc
Browse files Browse the repository at this point in the history
Fix support for user home gemrc configuration
  • Loading branch information
bbergstrom committed Sep 16, 2015
2 parents f4e8284 + 3a77c87 commit 5a53e1a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .octopolo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
github_repo: sportngin/brew-gem
semantic_versioning: true
branches_to_keep:
- master
9 changes: 8 additions & 1 deletion bin/brew-gem
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ end
version = ARGV[2] || $1

klass = name.capitalize.gsub(/[-_.\s]([a-zA-Z0-9])/) { $1.upcase }.gsub('+', 'x')
user_gemrc = "#{ENV['HOME']}/.gemrc"

require 'erb'
template = ERB.new(File.read(__FILE__).split(/^__END__$/, 2)[1].strip)
Expand All @@ -35,6 +36,7 @@ end

__END__
require 'formula'
require 'fileutils'

class RubyGemsDownloadStrategy < AbstractDownloadStrategy
def fetch
Expand All @@ -58,6 +60,12 @@ class <%= klass %> < Formula
version "<%= version %>"

def install
# Copy user's RubyGems config to temporary build home.
buildpath_gemrc = "#{ENV['HOME']}/.gemrc"
if File.exists?('<%= user_gemrc %>') && !File.exists?(buildpath_gemrc)
FileUtils.cp('<%= user_gemrc %>', buildpath_gemrc)
end

# set GEM_HOME and GEM_PATH to make sure we package all the dependent gems
# together without accidently picking up other gems on the gem path since
# they might not be there if, say, we change to a different rvm gemset
Expand Down Expand Up @@ -102,4 +110,3 @@ load "#{file}"
end
end
end

0 comments on commit 5a53e1a

Please sign in to comment.