Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix gem exe used by RubyGemsDownloadStrategy #51

Merged
merged 2 commits into from
Nov 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions lib/brew/gem/formula.rb.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
require 'formula'
require 'fileutils'

BREWGEM_RUBYBINDIR = '<%= use_homebrew_ruby ? "#{homebrew_prefix}/bin" : "/usr/bin" %>'
BREWGEM_GEM_PATH = "#{BREWGEM_RUBYBINDIR}/gem"
BREWGEM_RUBY_PATH = "#{BREWGEM_RUBYBINDIR}/ruby"

class RubyGemsDownloadStrategy < AbstractDownloadStrategy
def fetch
ohai "Fetching <%= name %> from gem source"
HOMEBREW_CACHE.cd do
ENV['GEM_SPEC_CACHE'] = "#{HOMEBREW_CACHE}/gem_spec_cache"
system "gem", "fetch", "<%= name %>", "--version", resource.version
system BREWGEM_GEM_PATH, "fetch", "<%= name %>", "--version", resource.version
end
end

Expand Down Expand Up @@ -38,10 +42,7 @@ class <%= klass %> < Formula
ENV['GEM_HOME']="#{prefix}"
ENV['GEM_PATH']="#{prefix}"

rubybindir = '<%= use_homebrew_ruby ? "#{homebrew_prefix}/bin" : "/usr/bin" %>'
gem_path = "#{rubybindir}/gem"
ruby_path = "#{rubybindir}/ruby"
system gem_path, "install", cached_download,
system BREWGEM_GEM_PATH, "install", cached_download,
"--no-ri",
"--no-rdoc",
"--no-wrapper",
Expand Down Expand Up @@ -74,7 +75,7 @@ class <%= klass %> < Formula
file = Pathname.new("#{brew_gem_prefix}/#{gemspec.bindir}/#{exe}")
(bin+file.basename).open('w') do |f|
f << <<-RUBY
#!#{ruby_path} --disable-gems
#!#{BREWGEM_RUBY_PATH} --disable-gems
ENV['GEM_HOME']="#{prefix}"
ENV['GEM_PATH']="#{prefix}"
require 'rubygems'
Expand Down
4 changes: 2 additions & 2 deletions spec/brew/gem/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
it { is_expected.to match(/class GemFooBar < Formula/) }

it { is_expected.to match(/version "1\.2\.3"/) }
it { is_expected.to match("rubybindir = '/usr/bin'") }
it { is_expected.to match("BREWGEM_RUBYBINDIR = '/usr/bin'") }

context "homebrew-ruby" do
subject(:formula) { described_class.expand_formula("foo-bar", "1.2.3", true) }
it { is_expected.to match("rubybindir = '/usr/local/bin'") }
it { is_expected.to match("BREWGEM_RUBYBINDIR = '/usr/local/bin'") }
end
end

Expand Down