class Bundler::Plumber::Advisory

Public Class Methods

load(path) click to toggle source

Loads the advisory from a YAML file.

@param [String] path

The path to the advisory YAML file.

@return [Advisory]

@api semipublic

# File lib/bundler/plumber/advisory.rb, line 45
def self.load(path)
  id   = File.basename(path).chomp('.yml')
  data = YAML.load_file(path)

  unless data.kind_of?(Hash)
    raise("advisory data in #{path.dump} was not a Hash")
  end

  parse_versions = lambda { |versions|
    Array(versions).map do |version|
      Gem::Requirement.new(*version.split(', '))
    end
  }

  return new(
    data['gem'],
    path,
    id,
    data['url'],
    data['title'],
    data['date'],
    data['description'],
    parse_versions[data['unaffected_versions']],
    parse_versions[data['patched_versions']]
  )
end

Public Instance Methods

leaky?(version) click to toggle source

Checks whether the version is leaky to the advisory.

@param [Gem::Version] version

The version to compare against {#patched_versions}.

@return [Boolean]

Specifies whether the version is leaky to the advisory or not.
# File lib/bundler/plumber/advisory.rb, line 115
def leaky?(version)
  !patched?(version) && !unaffected?(version)
end
patched?(version) click to toggle source

Checks whether the version is patched against the advisory.

@param [Gem::Version] version

The version to compare against {#patched_versions}.

@return [Boolean]

Specifies whether the version is patched against the advisory.

@since 0.2.0

# File lib/bundler/plumber/advisory.rb, line 100
def patched?(version)
  patched_versions.any? do |patched_version|
    patched_version === version
  end
end
unaffected?(version) click to toggle source

Checks whether the version is not affected by the advisory.

@param [Gem::Version] version

The version to compare against {#unaffected_versions}.

@return [Boolean]

Specifies whether the version is not affected by the advisory.

@since 0.2.0

# File lib/bundler/plumber/advisory.rb, line 83
def unaffected?(version)
  unaffected_versions.any? do |unaffected_version|
    unaffected_version === version
  end
end