-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathDN.Package.Github.pas
59 lines (48 loc) · 1.73 KB
/
DN.Package.Github.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
{
#########################################################
# Copyright by Alexander Benikowski #
# This unit is part of the Delphinus project hosted on #
# https://github.com/Memnarch/Delphinus #
#########################################################
}
unit DN.Package.Github;
interface
uses
Classes,
Types,
DN.Types,
DN.Package;
type
TDNGitHubPackage = class;
TGetLicenseCallback = function(const APackage: TDNGithubPackage; const ALicense: TDNLicense): string of object;
TDNGitHubPackage = class(TDNPackage)
private
FDefaultBranch: string;
FRepositoryName: string;
FOnGetLicense: TGetLicenseCallback;
FRepositoryType: string;
FRepository: string;
FRepositoryUser: string;
protected
function GetLicenseText(const AValue: TDNLicense): string; override;
public
property DefaultBranch: string read FDefaultBranch write FDefaultBranch;
property RepositoryName: string read FRepositoryName write FRepositoryName;
property RepositoryType: string read FRepositoryType write FRepositoryType;
property RepositoryUser: string read FRepositoryUser write FRepositoryUser;
property Repository: string read FRepository write FRepository;
property OnGetLicense: TGetLicenseCallback read FOnGetLicense write FOnGetLicense;
end;
implementation
{ TDNGitHubPackage }
{ TDNGitHubPackage }
function TDNGitHubPackage.GetLicenseText(const AValue: TDNLicense): string;
begin
Result := inherited;
if (Result = '') and not FLicenseTexts.ContainsKey(AValue.LicenseFile) and Assigned(FOnGetLicense) then
begin
Result := FOnGetLicense(Self, AValue);
LicenseText[AValue] := Result;
end;
end;
end.