Sha256: 6043c793deaf8da890d17eb622a102651fae98b5f22b1cea0a414a23bb7dd019
Contents?: true
Size: 1.12 KB
Versions: 13
Compression:
Stored size: 1.12 KB
Contents
class RubyEnv def self.bundler?(project_path) gem_exists?("bundler") && File.exists?("#{project_path}/Gemfile") end def self.gem_exists?(gem) if Gem::Specification.respond_to?(:find_by_name) Gem::Specification.find_by_name(gem) else # older depricated method Gem.available?(gem) end rescue Gem::LoadError false end def self.ruby_command(project_path, opts = {}) ruby_interpreter = opts[:ruby_interpreter] || "ruby" if opts[:script] && File.exists?("#{project_path}/#{opts[:script]}") command = opts[:script] elsif opts[:bin] command = opts[:bin] else command = nil end if bundler?(project_path) "#{rvm_prefix(project_path)} #{ruby_interpreter} -S bundle exec #{command}".strip else "#{rvm_prefix(project_path)} #{ruby_interpreter} -S #{command}".strip end end def self.rvm_prefix(project_path) if rvm? rvmrc_path = File.join project_path, ".rvmrc" if File.exists?(rvmrc_path) File.read(rvmrc_path).to_s.strip + " exec" end end end def self.rvm? system("rvm info") != nil end end
Version data entries
13 entries across 13 versions & 2 rubygems