Sha256: a598e83204ca08b9d8a56b99dcd8642043f48eac68148d1b630c8e2655d8b071

Contents?: true

Size: 809 Bytes

Versions: 5

Compression:

Stored size: 809 Bytes

Contents

class Gem::Specification
  def self.deactivate(name)
    Gem.loaded_specs[name]&.deactivate
  end

  def deactivate
    loaded_paths.each do |path|
      $:.delete(path)
    end

    Gem.loaded_specs.delete(name)
  end

  def activation
    self.class.deactivate(name)
    activate
  rescue Gem::ConflictError => error
    abort error.to_s
  end

  private

  def loaded_paths(spec = self, prev = [])
    return root_loaded_path unless loaded_into_path?
    return root_loaded_path if prev == root_loaded_path

    root_loaded_path + dependent_specs.map do |spec|
      loaded_paths(spec, root_loaded_path)
    end.flatten
  end

  def loaded_into_path?
    @lip ||= root_loaded_path.any? do |path|
      $:.include?(path)
    end
  end

  def root_loaded_path
    @root ||= Dir.glob(lib_dirs_glob)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rfix-1.4.1 lib/rfix/loader/spec.rb
rfix-1.4.0.pre.201 lib/rfix/loader/spec.rb
rfix-1.4.0 lib/rfix/loader/spec.rb
rfix-1.3.0.pre.199 lib/rfix/loader/spec.rb
rfix-1.2.6.pre.198 lib/rfix/loader/spec.rb