Sha256: eb75fdb22c71061583eee081b1577abd96fda350ca6f8ef8f130d4bd47a27ef7
Contents?: true
Size: 1.17 KB
Versions: 3
Compression:
Stored size: 1.17 KB
Contents
require 'erb' module GemWrappers class Installer attr_reader :environment_file def initialize(environment_file) @environment_file = environment_file end def self.wrappers_path Gem.configuration && Gem.configuration[:wrappers_path] || File.join(Gem.dir, 'wrappers') end def wrappers_path @wrappers_path ||= self.class.wrappers_path end def ensure FileUtils.mkdir_p(wrappers_path) unless File.exist?(wrappers_path) # exception based on Gem::Installer.generate_bin raise Gem::FilePermissionError.new(wrappers_path) unless File.writable?(wrappers_path) end def install(executable) content = ERB.new(template).result(binding) file_name = File.join(wrappers_path, executable) File.open(file_name, 'w') do |file| file.write(content) end File.chmod(0755, file_name) end def template @template ||= <<-TEMPLATE #!/usr/bin/env bash if [[ -s "<%= environment_file %>" ]] then source "<%= environment_file %>" exec <%= executable %> "$@" else echo "ERROR: Missing RVM environment file: '<%= environment_file %>'" >&2 exit 1 fi TEMPLATE end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
gem-wrappers-1.0.0 | lib/gem-wrappers/installer.rb |
gem-wrappers-0.9.2 | lib/gem-wrappers/installer.rb |
gem-wrappers-0.9.1 | lib/gem-wrappers/installer.rb |