forked from dontenwill/DUDS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
duds.export.modules.CSV.pas
73 lines (59 loc) · 1.87 KB
/
duds.export.modules.CSV.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
unit duds.export.modules.CSV;
interface
uses
System.SysUtils, System.Classes,
Xml.XMLDoc, Xml.XMLIntf,
duds.common.Types,
duds.common.Strings,
duds.common.Classes,
duds.common.Files,
duds.common.Language,
duds.common.Log,
duds.common.Interfaces,
duds.common.modules,
duds.common.modulesSerializer,
duds.analyzer.model;
type
TExportModulesToCSV = class
private
FModel: TDudsModel;
fProjectSettings: TProjectSettings;
FOnLog: TLogProcedure;
fFileName: string;
public
procedure ExportModules;
property Model: TDudsModel read FModel write FModel;
property OnLog: TLogProcedure read FOnLog write FOnLog;
property ProjectSettings: TProjectSettings read fProjectSettings write fProjectSettings;
property FileName: string read fFileName write fFileName;
end;
implementation
{ TExportModulesToCSV }
procedure TExportModulesToCSV.ExportModules;
var
Lines: TStringList;
CurrentLine: String;
aModule: TModule;
const
cCSVSep = ';';
begin
Lines := TStringList.Create;
try
Lines.Add('module_name;origin;usage;files;files_not_in_path;lines_of_code');
for aModule in fModel.Modules.OrderedModules do
begin
CurrentLine := '';
AddToken(CurrentLine, aModule.Name, cCSVSep);
AddToken(CurrentLine, TModulesSerializer.cModuleOriginJSONEnumValues[aModule.Origin], cCSVSep);
AddToken(CurrentLine, TModulesSerializer.cModuleUsageJSONEnumValues[aModule.Usage], cCSVSep);
AddToken(CurrentLine, IntToStr(aModule.AnalysisData.NumberOfFiles), cCSVSep);
AddToken(CurrentLine, IntToStr(aModule.AnalysisData.NumberOfFilesNotInPath), cCSVSep);
AddToken(CurrentLine, IntToStr(aModule.AnalysisData.LinesOfCode), cCSVSep);
Lines.Add(CurrentLine);
end;
Lines.SaveToFile(Filename);
finally
FreeAndNil(Lines);
end;
end;
end.