Class: KBuilder::Dotnet::Dependency

Inherits:
Object
  • Object
show all
Defined in:
lib/k_builder/dotnet/dependency.rb

Overview

Represents any NuGet package or project reference dependencies

How this information is used:

Add a nuget package to the project in current folder

- dotnet add package <PACKAGE_NAME>

Add project to a solution

- dotnet sln <SOLUTION_NAME>.sln add <PROJECT_NAME>.csproj

Add project reference to a project in the current folder

- dotnet <PROJECT_NAME>.csproj

Constant Summary collapse

VALID_TYPES =
%i[nuget reference].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, type) ⇒ Dependency

Returns a new instance of Dependency.



30
31
32
33
34
35
36
# File 'lib/k_builder/dotnet/dependency.rb', line 30

def initialize(name, type)
  @name = name
  @type = type

  raise KBuilder::Dotnet::Error, 'Name is required' if name.nil? || name.to_s == ''
  raise KBuilder::Dotnet::Error, 'Unknown dependency type. Valid types: [:nuget, :reference]' unless VALID_TYPES.include?(type)
end

Instance Attribute Details

#nameObject

Name of dependency



23
24
25
# File 'lib/k_builder/dotnet/dependency.rb', line 23

def name
  @name
end

#typeObject

Type of dependency

- :nuget         NuGet package
- :reference     Project reference


28
29
30
# File 'lib/k_builder/dotnet/dependency.rb', line 28

def type
  @type
end