Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IRunner interface #361

Merged
merged 7 commits into from
Sep 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/cla.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
PERSONAL_ACCESS_TOKEN : ${{ secrets.CLA_ACCESS_TOKEN }}
with:
path-to-signatures: 'CLA/signatures/v1.0/cla.json'
path-to-cla-document: 'https://github.com/corgibytes/freshli/blob/main/CLA/CLA-v1.0.md'
path-to-document: 'https://github.com/corgibytes/freshli/blob/main/CLA/CLA-v1.0.md'
branch: 'main'
allowlist: dependabot[bot]

Expand Down
16 changes: 16 additions & 0 deletions CLA/signatures/v1.0/cla.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,22 @@
"created_at": "2021-02-15T23:32:26Z",
"repoId": 233626880,
"pullRequestNo": 237
},
{
"name": "mfcorgi",
"id": 46997613,
"comment_id": 905742427,
"created_at": "2021-08-25T17:42:41Z",
"repoId": 233626880,
"pullRequestNo": 361
},
{
"name": "mairadanielaferrari",
"id": 3629162,
"comment_id": 905743587,
"created_at": "2021-08-25T17:44:32Z",
"repoId": 233626880,
"pullRequestNo": 361
}
]
}
11 changes: 11 additions & 0 deletions Corgibytes.Freshli.Lib/IRunner.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;

namespace Corgibytes.Freshli.Lib
{
public interface IRunner
{
public IList<ScanResult> Run(string analysisPath, DateTime asOf);
public IList<ScanResult> Run(string analysisPath);
}
}
32 changes: 11 additions & 21 deletions Corgibytes.Freshli.Lib/Runner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@

namespace Corgibytes.Freshli.Lib
{
public class Runner
public class Runner : IRunner
{

private const string ResultsPath = "results";

private static readonly Logger logger = LogManager.GetCurrentClassLogger();
Expand All @@ -25,7 +24,7 @@ public IList<ScanResult> Run(string analysisPath, DateTime asOf)
{
logger.Info($"Run({analysisPath}, {asOf:d})");

var scanResults = new List<ScanResult>();
IList<ScanResult> scanResults = new List<ScanResult>();
var fileHistoryFinder = new FileHistoryFinder(analysisPath);
ManifestFinder = new ManifestFinder(
analysisPath,
Expand Down Expand Up @@ -54,11 +53,13 @@ public IList<ScanResult> Run(string analysisPath, DateTime asOf)
return scanResults;
}

private List<ScanResult> ProcessManifestFiles(
string analysisPath,
DateTime asOf,
FileHistoryFinder fileHistoryFinder
)
public IList<ScanResult> Run(string analysisPath)
{
var asOf = DateTime.Today.ToEndOfDay();
return Run(analysisPath, asOf: asOf);
}

private IList<ScanResult> ProcessManifestFiles(string analysisPath, DateTime asOf, FileHistoryFinder fileHistoryFinder)
{
var scanResults = new List<ScanResult>();
foreach (var mf in ManifestFinder.ManifestFiles)
Expand All @@ -82,12 +83,7 @@ FileHistoryFinder fileHistoryFinder
return scanResults;
}

private MetricsResult ProcessAnalysisDate(
string manifestFile,
LibYearCalculator calculator,
IFileHistory fileHistory,
DateTime currentDate
)
private MetricsResult ProcessAnalysisDate(string manifestFile, LibYearCalculator calculator, IFileHistory fileHistory, DateTime currentDate)
{
var content = fileHistory.ContentsAsOf(currentDate);
calculator.Manifest.Parse(content);
Expand All @@ -109,13 +105,7 @@ DateTime currentDate
return new MetricsResult(currentDate, sha, libYear);
}

public IList<ScanResult> Run(string analysisPath)
{
var asOf = DateTime.Today.ToEndOfDay();
return Run(analysisPath, asOf: asOf);
}

private static void WriteResultsToFile(List<ScanResult> results)
private static void WriteResultsToFile(IList<ScanResult> results)
{
if (!System.IO.Directory.Exists(ResultsPath))
{
Expand Down