Class: Dependabot::Nuget::NativeWorkspaceDiscovery

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path:, projects:, directory_packages_props:, global_json:, dotnet_tools_json:) ⇒ NativeWorkspaceDiscovery

Returns a new instance of NativeWorkspaceDiscovery.



47
48
49
50
51
52
53
# File 'lib/dependabot/nuget/native_discovery/native_workspace_discovery.rb', line 47

def initialize(path:, projects:, directory_packages_props:, global_json:, dotnet_tools_json:)
  @path = path
  @projects = projects
  @directory_packages_props = directory_packages_props
  @global_json = global_json
  @dotnet_tools_json = dotnet_tools_json
end

Instance Attribute Details

#directory_packages_propsObject (readonly)

Returns the value of attribute directory_packages_props.



62
63
64
# File 'lib/dependabot/nuget/native_discovery/native_workspace_discovery.rb', line 62

def directory_packages_props
  @directory_packages_props
end

#dotnet_tools_jsonObject (readonly)

Returns the value of attribute dotnet_tools_json.



68
69
70
# File 'lib/dependabot/nuget/native_discovery/native_workspace_discovery.rb', line 68

def dotnet_tools_json
  @dotnet_tools_json
end

#global_jsonObject (readonly)

Returns the value of attribute global_json.



65
66
67
# File 'lib/dependabot/nuget/native_discovery/native_workspace_discovery.rb', line 65

def global_json
  @global_json
end

#pathObject (readonly)

Returns the value of attribute path.



56
57
58
# File 'lib/dependabot/nuget/native_discovery/native_workspace_discovery.rb', line 56

def path
  @path
end

#projectsObject (readonly)

Returns the value of attribute projects.



59
60
61
# File 'lib/dependabot/nuget/native_discovery/native_workspace_discovery.rb', line 59

def projects
  @projects
end

Class Method Details

.from_json(json) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/dependabot/nuget/native_discovery/native_workspace_discovery.rb', line 16

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

  path = T.let(json.fetch("Path"), String)
  path = "/" + path unless path.start_with?("/")
  projects = T.let(json.fetch("Projects"), T::Array[T::Hash[String, T.untyped]]).filter_map do |project|
    NativeProjectDiscovery.from_json(project, path)
  end
  directory_packages_props = NativeDirectoryPackagesPropsDiscovery
                             .from_json(T.let(json.fetch("DirectoryPackagesProps"),
                                              T.nilable(T::Hash[String, T.untyped])), path)
  global_json = NativeDependencyFileDiscovery
                .from_json(T.let(json.fetch("GlobalJson"), T.nilable(T::Hash[String, T.untyped])), path)
  dotnet_tools_json = NativeDependencyFileDiscovery
                      .from_json(T.let(json.fetch("DotNetToolsJson"),
                                       T.nilable(T::Hash[String, T.untyped])), path)

  NativeWorkspaceDiscovery.new(path: path,
                               projects: projects,
                               directory_packages_props: directory_packages_props,
                               global_json: global_json,
                               dotnet_tools_json: dotnet_tools_json)
end