Parent

Included Modules

Class/Module Index [+]

Quicksearch

Isolate::Entry

An isolated Gem, with requirement, environment restrictions, and installation options. Generally intended for internal use. This class exposes lifecycle events for extension, see Isolate::Events for more information.

Attributes

environments[R]

Which environments does this entry care about? Generally an Array of Strings. An empty array means “all”, not “none”.

name[R]

What’s the name of this entry? Generally the name of a gem.

options[R]

Extra information or hints for installation. See initialize for well-known keys.

requirement[R]

What version of this entry is required? Expressed as a Gem::Requirement, which see.

Public Class Methods

new(sandbox, name, *requirements) click to toggle source

Create a new entry. Takes sandbox (currently an instance of Isolate::Sandbox), name (as above), and any number of optional version requirements (generally strings). Options can be passed as a trailing hash. Well-known keys:

:args

Command-line build arguments. Passed to the gem at installation time.

:source

An alternative RubyGems source for this gem.

# File lib/isolate/entry.rb, line 47
def initialize sandbox, name, *requirements
  @environments = []
  @file         = nil
  @name         = name
  @options      = {}
  @requirement  = Gem::Requirement.default
  @sandbox      = sandbox

  if /\.gem$/ =~ @name && File.file?(@name)
    @file = File.expand_path @name

    @name = File.basename(@file, ".gem").
      gsub(/-#{Gem::Version::VERSION_PATTERN}$/, "")
  end

  update(*requirements)
end

Public Instance Methods

activate() click to toggle source

Activate this entry. Fires :activating and :activated.

# File lib/isolate/entry.rb, line 68
def activate
  fire :activating, :activated do
    spec = self.specification
    raise Gem::LoadError, "Couldn't resolve: #{self}" unless spec
    spec.activate
  end
end
inspect() click to toggle source
Alias for: to_s
install() click to toggle source

Install this entry in the sandbox. Fires :installing and :installed.

# File lib/isolate/entry.rb, line 79
def install
  old = Gem.sources.dup

  begin
    fire :installing, :installed do

      installer =
        Gem::DependencyInstaller.new(:development   => false,
                                     :generate_rdoc => false,
                                     :generate_ri   => false,
                                     :install_dir   => @sandbox.path)

      Gem.sources += Array(options[:source]) if options[:source]
      Gem::Command.build_args = Array(options[:args]) if options[:args]

      installer.install @file || name, requirement
    end
  ensure
    Gem.sources = old
    Gem::Command.build_args = nil
  end
end
matches?(environment) click to toggle source

Is this entry interested in environment?

# File lib/isolate/entry.rb, line 104
def matches? environment
  environments.empty? || environments.include?(environment)
end
matches_spec?(spec) click to toggle source

Is this entry satisfied by spec (generally a Gem::Specification)?

# File lib/isolate/entry.rb, line 111
def matches_spec? spec
  name == spec.name and requirement.satisfied_by? spec.version
end
specification() click to toggle source

The Gem::Specification for this entry or nil if it isn’t resolveable.

# File lib/isolate/entry.rb, line 117
def specification
  Gem::Specification.find_by_name(name, requirement)
rescue Gem::LoadError
  nil
end
to_s() click to toggle source
# File lib/isolate/entry.rb, line 137
def to_s
  "Entry[#{name.inspect}, #{requirement.to_s.inspect}]"
end
Also aliased as: inspect
update(*reqs) click to toggle source

Updates this entry’s environments, options, and requirement. Environments and options are merged, requirement is replaced. Fires :updating and :updated.

# File lib/isolate/entry.rb, line 127
def update *reqs
  fire :updating, :updated do
    @environments |= @sandbox.environments
    @options.merge! reqs.pop if Hash === reqs.last
    @requirement = Gem::Requirement.new reqs unless reqs.empty?
  end

  self
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.