-
Notifications
You must be signed in to change notification settings - Fork 388
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #78 from patros/multiple-report-formats
Add support for multiple output formats separated by a comma
- Loading branch information
Showing
3 changed files
with
51 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,25 @@ | ||
using System.Linq; | ||
using System.Collections.Generic; | ||
|
||
namespace Coverlet.Core.Reporters | ||
{ | ||
public class ReporterFactory | ||
{ | ||
private string _format; | ||
private IEnumerable<string> _formats; | ||
private IReporter[] _reporters; | ||
|
||
public ReporterFactory(string format) | ||
public ReporterFactory(string formats) | ||
{ | ||
_format = format; | ||
_formats = formats.Split(','); | ||
_reporters = new IReporter[] { | ||
new JsonReporter(), new LcovReporter(), | ||
new OpenCoverReporter(), new CoberturaReporter() | ||
}; | ||
} | ||
|
||
public IReporter CreateReporter() | ||
=> _reporters.FirstOrDefault(r => r.Format == _format); | ||
public IEnumerable<IReporter> CreateReporters() | ||
{ | ||
return _reporters.Where(r => _formats.Contains(r.Format)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters