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)


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

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 not defined? ::Bundler
end

.new(*args) ⇒ Object



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

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.



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

def source
  if has_rubygems?
    Gems18Source
  else
    NoGemsSource
  end
end