Included Modules

Files

Class/Module Index [+]

Quicksearch

Chef::Provider::Package::Rubygems::AlternateGemEnvironment

Constants

JRUBY_PLATFORM

Attributes

gem_binary_location[R]

Public Class Methods

gempath_cache() click to toggle source
# File lib/chef/provider/package/rubygems.rb, line 236
def self.gempath_cache
  @gempath_cache ||= {}
end
new(gem_binary_location) click to toggle source
# File lib/chef/provider/package/rubygems.rb, line 248
def initialize(gem_binary_location)
  @gem_binary_location = gem_binary_location
end
platform_cache() click to toggle source
# File lib/chef/provider/package/rubygems.rb, line 240
def self.platform_cache
  @platform_cache ||= {}
end

Public Instance Methods

candidate_version_from_remote(gem_dependency, *sources) click to toggle source
# File lib/chef/provider/package/rubygems.rb, line 313
def candidate_version_from_remote(gem_dependency, *sources)
  with_gem_sources(*sources) do
    with_gem_platforms(*gem_platforms) do
      find_newest_remote_version(gem_dependency, *sources)
    end
  end
end
gem_paths() click to toggle source
# File lib/chef/provider/package/rubygems.rb, line 252
def gem_paths
  if self.class.gempath_cache.key?(@gem_binary_location)
    self.class.gempath_cache[@gem_binary_location]
  else
    # shellout! is a fork/exec which won't work on windows
    shell_style_paths = shell_out!("#{@gem_binary_location} env gempath").stdout
    # on windows, the path separator is (usually? always?) semicolon
    paths = shell_style_paths.split(::File::PATH_SEPARATOR).map { |path| path.strip }
    self.class.gempath_cache[@gem_binary_location] = paths
  end
end
gem_platforms() click to toggle source

Attempt to detect the correct platform settings for the target gem environment.

In practice, this only makes a difference if different versions are available depending on platform, and only if the target gem environment has a radically different platform (i.e., jruby), so we just try to detect jruby and fall back to the current platforms (Gem.platforms) if we don't detect it.

Returns

String|Gem::Platform

returns an array of Gem::Platform-compatible

objects, i.e., Strings that are valid for Gem::Platform or actual Gem::Platform objects.

# File lib/chef/provider/package/rubygems.rb, line 291
def gem_platforms
  if self.class.platform_cache.key?(@gem_binary_location)
    self.class.platform_cache[@gem_binary_location]
  else
    gem_environment = shell_out!("#{@gem_binary_location} env").stdout
    if jruby = gem_environment[JRUBY_PLATFORM]
      self.class.platform_cache[@gem_binary_location] = ['ruby', Gem::Platform.new(jruby)]
    else
      self.class.platform_cache[@gem_binary_location] = Gem.platforms
    end
  end
end
gem_source_index() click to toggle source
# File lib/chef/provider/package/rubygems.rb, line 264
def gem_source_index
  @source_index ||= Gem::SourceIndex.from_gems_in(*gem_paths.map { |p| p + '/specifications' })
end
gem_specification() click to toggle source
# File lib/chef/provider/package/rubygems.rb, line 268
def gem_specification
  # Only once, dirs calls a reset
  unless @specification
    Gem::Specification.dirs = gem_paths
    @specification = Gem::Specification
  end
  @specification
end
with_gem_platforms(*alt_gem_platforms) click to toggle source
# File lib/chef/provider/package/rubygems.rb, line 304
def with_gem_platforms(*alt_gem_platforms)
  alt_gem_platforms.flatten!
  original_gem_platforms = Gem.platforms
  Gem.platforms = alt_gem_platforms
  yield
ensure
  Gem.platforms = original_gem_platforms
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.