Class: Puppet::Util::RubyGems::Source

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/util/rubygems.rb

Overview

Base/factory class for rubygems source. These classes introspec into rubygems to in order to list where the rubygems system will look for files to load.

Direct Known Subclasses

Gems18Source, NoGemsSource

Class Method Summary collapse

Class Method Details

.has_rubygems?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


12
13
14
15
16
17
18
19
20
# File 'lib/puppet/util/rubygems.rb', line 12

def has_rubygems?
  # Gems are not actually available when Bundler is loaded, even
  # though the Gem constant is defined. This is because Bundler
  # loads in rubygems, but then removes the custom require that
  # rubygems installs. So when Bundler is around we have to act
  # as though rubygems is not, e.g. we shouldn't be able to load
  # a gem that Bundler doesn't want us to see.
  defined? ::Gem and !defined? ::Bundler
end

.new(*args) ⇒ Object



31
32
33
34
35
# File 'lib/puppet/util/rubygems.rb', line 31

def new(*args)
  object = source.allocate
  object.send(:initialize, *args)
  object
end

.sourceObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



23
24
25
26
27
28
29
# File 'lib/puppet/util/rubygems.rb', line 23

def source
  if has_rubygems?
    Gems18Source
  else
    NoGemsSource
  end
end