Module: Gem
- Defined in:
- lib/gel/compatibility/rubygems.rb
Defined Under Namespace
Modules: Command Classes: Dependency, DependencyInstaller, Specification
Constant Summary collapse
- Version =
Gel::Support::GemVersion
- Requirement =
Gel::Support::GemRequirement
- LoadError =
Class.new(::LoadError)
Class Method Summary collapse
- .activate_bin_path(gem_name, bin_name, version = nil) ⇒ Object
- .bin_path(gem_name, bin_name, version = nil) ⇒ Object
- .default_dir ⇒ Object
- .find_files(pattern) ⇒ Object
- .loaded_specs ⇒ Object
- .path ⇒ Object
- .refresh ⇒ Object
- .ruby ⇒ Object
- .try_activate(file) ⇒ Object
- .win_platform? ⇒ Boolean
Class Method Details
.activate_bin_path(gem_name, bin_name, version = nil) ⇒ Object
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/gel/compatibility/rubygems.rb', line 129 def self.activate_bin_path(gem_name, bin_name, version = nil) if gem_name == "bundler" && bin_name == "bundle" # Extra-special case: this is the bundler binstub, we need to # re-exec to hand over. ENV["RUBYLIB"] = Gel::Environment.original_rubylib exec RbConfig.ruby, "--", $0, *ARGV end if g = Gel::Environment.activated_gems[gem_name] Gel::Environment.gem g.name, version if version elsif g = Gel::Environment.find_gem(gem_name, *version) do |g| g.executables.include?(bin_name) end Gel::Environment.gem g.name, g.version elsif g = Gel::Environment.find_gem(gem_name, *version) raise "#{g.name} (#{g.version}) doesn't contain executable #{bin_name.inspect}" elsif version && Gel::Environment.find_gem(gem_name) raise "#{gem_name} (#{version}) not available" else raise "Unknown gem #{gem_name.inspect}" end Gel::Environment.find_executable(bin_name, g.name, g.version) rescue => ex # This method may be our entry-point, if we're being invoked by a # rubygems binstub. Detect that situation, and provide nicer error # reporting. raise unless locations = caller_locations(2, 2) raise unless locations.size == 1 raise unless path = locations.first.absolute_path raise unless File.exist?(path) && File.readable?(path) raise unless File.open(path, "rb") { |f| f.read(1024).include?("\n# This file was generated by RubyGems.\n") } require_relative "../command" Gel::Command.handle_error(ex) end |
.bin_path(gem_name, bin_name, version = nil) ⇒ Object
169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/gel/compatibility/rubygems.rb', line 169 def self.bin_path(gem_name, bin_name, version = nil) if g = Gel::Environment.activated_gems[gem_name] Gel::Environment.gem g.name, version if version Gel::Environment.find_executable(bin_name, g.name, g.version) elsif Gel::Environment.find_gem(gem_name) raise "Gem #{gem_name.inspect} is not active" else raise "Unknown gem #{gem_name.inspect}" end end |
.default_dir ⇒ Object
125 126 127 |
# File 'lib/gel/compatibility/rubygems.rb', line 125 def self.default_dir path.first end |
.find_files(pattern) ⇒ Object
111 112 113 114 115 |
# File 'lib/gel/compatibility/rubygems.rb', line 111 def self.find_files(pattern) Gel::Environment.store.each. flat_map(&:require_paths). flat_map { |dir| Dir[File.join(dir, pattern)] } end |
.loaded_specs ⇒ Object
103 104 105 106 107 108 109 |
# File 'lib/gel/compatibility/rubygems.rb', line 103 def self.loaded_specs result = {} Gel::Environment.activated_gems.each do |name, store_gem| result[name] = Gem::Specification.new(store_gem) end result end |
.path ⇒ Object
121 122 123 |
# File 'lib/gel/compatibility/rubygems.rb', line 121 def self.path Gel::Environment.store.paths end |
.refresh ⇒ Object
117 118 119 |
# File 'lib/gel/compatibility/rubygems.rb', line 117 def self.refresh # no-op end |
.ruby ⇒ Object
95 96 97 |
# File 'lib/gel/compatibility/rubygems.rb', line 95 def self.ruby RbConfig.ruby end |
.try_activate(file) ⇒ Object
89 90 91 92 93 |
# File 'lib/gel/compatibility/rubygems.rb', line 89 def self.try_activate(file) Gel::Environment.resolve_gem_path(file) != file rescue LoadError false end |
.win_platform? ⇒ Boolean
99 100 101 |
# File 'lib/gel/compatibility/rubygems.rb', line 99 def self.win_platform? false end |