Class: Bundler::Plumber::Advisory

Inherits:
Struct
  • Object
show all
Defined in:
lib/bundler/plumber/advisory.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dateObject

Returns the value of attribute date

Returns:

  • (Object)

    the current value of date


23
24
25
# File 'lib/bundler/plumber/advisory.rb', line 23

def date
  @date
end

#descriptionObject

Returns the value of attribute description

Returns:

  • (Object)

    the current value of description


23
24
25
# File 'lib/bundler/plumber/advisory.rb', line 23

def description
  @description
end

#idObject Also known as: to_s

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id


23
24
25
# File 'lib/bundler/plumber/advisory.rb', line 23

def id
  @id
end

#patched_versionsObject

Returns the value of attribute patched_versions

Returns:

  • (Object)

    the current value of patched_versions


23
24
25
# File 'lib/bundler/plumber/advisory.rb', line 23

def patched_versions
  @patched_versions
end

#pathObject

Returns the value of attribute path

Returns:

  • (Object)

    the current value of path


23
24
25
# File 'lib/bundler/plumber/advisory.rb', line 23

def path
  @path
end

#titleObject

Returns the value of attribute title

Returns:

  • (Object)

    the current value of title


23
24
25
# File 'lib/bundler/plumber/advisory.rb', line 23

def title
  @title
end

#unaffected_versionsObject

Returns the value of attribute unaffected_versions

Returns:

  • (Object)

    the current value of unaffected_versions


23
24
25
# File 'lib/bundler/plumber/advisory.rb', line 23

def unaffected_versions
  @unaffected_versions
end

#urlObject

Returns the value of attribute url

Returns:

  • (Object)

    the current value of url


23
24
25
# File 'lib/bundler/plumber/advisory.rb', line 23

def url
  @url
end

Class Method Details

.load(path) ⇒ Advisory

Loads the advisory from a YAML file.

Parameters:

  • path (String)

    The path to the advisory YAML file.

Returns:


42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/bundler/plumber/advisory.rb', line 42

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(
    path,
    id,
    data['url'],
    data['title'],
    data['date'],
    data['description'],
    parse_versions[data['unaffected_versions']],
    parse_versions[data['patched_versions']]
  )
end

Instance Method Details

#leaky?(version) ⇒ Boolean

Checks whether the version is leaky to the advisory.

Parameters:

Returns:

  • (Boolean)

    Specifies whether the version is leaky to the advisory or not.


111
112
113
# File 'lib/bundler/plumber/advisory.rb', line 111

def leaky?(version)
  !patched?(version) && !unaffected?(version)
end

#patched?(version) ⇒ Boolean

Checks whether the version is patched against the advisory.

Parameters:

Returns:

  • (Boolean)

    Specifies whether the version is patched against the advisory.

Since:

  • 0.2.0


96
97
98
99
100
# File 'lib/bundler/plumber/advisory.rb', line 96

def patched?(version)
  patched_versions.any? do |patched_version|
    patched_version === version
  end
end

#unaffected?(version) ⇒ Boolean

Checks whether the version is not affected by the advisory.

Parameters:

Returns:

  • (Boolean)

    Specifies whether the version is not affected by the advisory.

Since:

  • 0.2.0


79
80
81
82
83
# File 'lib/bundler/plumber/advisory.rb', line 79

def unaffected?(version)
  unaffected_versions.any? do |unaffected_version|
    unaffected_version === version
  end
end