Class: Dependabot::Nuget::DependencyAnalysis

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/nuget/analysis/dependency_analysis.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(updated_version:, can_update:, version_comes_from_multi_dependency_property:, updated_dependencies:) ⇒ DependencyAnalysis

Returns a new instance of DependencyAnalysis.



40
41
42
43
44
45
46
# File 'lib/dependabot/nuget/analysis/dependency_analysis.rb', line 40

def initialize(updated_version:, can_update:, version_comes_from_multi_dependency_property:,
               updated_dependencies:)
  @updated_version = updated_version
  @can_update = can_update
  @version_comes_from_multi_dependency_property = version_comes_from_multi_dependency_property
  @updated_dependencies = updated_dependencies
end

Instance Attribute Details

#can_updateObject (readonly)

Returns the value of attribute can_update.



52
53
54
# File 'lib/dependabot/nuget/analysis/dependency_analysis.rb', line 52

def can_update
  @can_update
end

#updated_dependenciesObject (readonly)

Returns the value of attribute updated_dependencies.



58
59
60
# File 'lib/dependabot/nuget/analysis/dependency_analysis.rb', line 58

def updated_dependencies
  @updated_dependencies
end

#updated_versionObject (readonly)

Returns the value of attribute updated_version.



49
50
51
# File 'lib/dependabot/nuget/analysis/dependency_analysis.rb', line 49

def updated_version
  @updated_version
end

#version_comes_from_multi_dependency_propertyObject (readonly)

Returns the value of attribute version_comes_from_multi_dependency_property.



55
56
57
# File 'lib/dependabot/nuget/analysis/dependency_analysis.rb', line 55

def version_comes_from_multi_dependency_property
  @version_comes_from_multi_dependency_property
end

Class Method Details

.from_json(json) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/dependabot/nuget/analysis/dependency_analysis.rb', line 14

def self.from_json(json)
  Dependabot::Nuget::NativeHelpers.ensure_no_errors(json)

  updated_version = T.let(json.fetch("UpdatedVersion"), String)
  can_update = T.let(json.fetch("CanUpdate"), T::Boolean)
  version_comes_from_multi_dependency_property = T.let(json.fetch("VersionComesFromMultiDependencyProperty"),
                                                       T::Boolean)
  updated_dependencies = T.let(json.fetch("UpdatedDependencies"),
                               T::Array[T::Hash[String, T.untyped]]).map do |dep|
    NativeDependencyDetails.from_json(dep)
  end

  DependencyAnalysis.new(
    updated_version: updated_version,
    can_update: can_update,
    version_comes_from_multi_dependency_property: version_comes_from_multi_dependency_property,
    updated_dependencies: updated_dependencies
  )
end

Instance Method Details

#numeric_updated_versionObject



61
62
63
# File 'lib/dependabot/nuget/analysis/dependency_analysis.rb', line 61

def numeric_updated_version
  @numeric_updated_version ||= T.let(Version.new(updated_version), T.nilable(Dependabot::Nuget::Version))
end