Skip to content

Commit

Permalink
#41; Changed variadic parameters to array of arrays (this is because …
Browse files Browse the repository at this point in the history
…variadic parameters cannot be passed down to other functions, and was needed to implement param with default value at protocol level).

Changed parameters with default value to overload with protocol extension, needed to use protocol when changing implementation of generator..
first draft for ExcelStatsReportFromDateGenerator. Now need to modify both generator to do the complete job from generating the report and the file to attach (HTML -> PDF or Excel).
few options:
1- keep the HTML to PDF conversion outside the report generator (the conversion need UI which seems to be incompatible with UnitTesting)
2- use call back instead of returning a string (allow for any intermediate process)
3- remove the HTML and HTML to PDF processes since that might not be necessary anymore once we can generate and attach an Excel file.
(or a combo of few above options)
  • Loading branch information
huguesf committed Nov 1, 2019
1 parent dda34bf commit 2f0fdde
Show file tree
Hide file tree
Showing 3 changed files with 188 additions and 163 deletions.
37 changes: 30 additions & 7 deletions Core Classes/HtmlStatsReportFromDate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@ struct ReportCell

enum VAlign: String { case bottom, top, middle }

protocol StatsReportFromDate
protocol StatsReportFromDateGenerator
{
var startDate : Date { get }
var endDate : Date { get }
var siteSpecific : Bool { get }

init(_ startDate: Date, toDate endDate: Date, _ siteSpecific: Bool)

func addTitle(_ title : String)
Expand All @@ -36,17 +40,36 @@ protocol StatsReportFromDate
func addLineOfInfoText(_ info : String)
func addLineOfText(_ text : String)
func addText(_ text : String)

func startTable(_ columnsSet : [ReportColumn]..., withAlternatingRowColor : Bool, withInformationText : String?)

func startTable(_ columnsSet : [[ReportColumn]])
func startTable(_ columnsSet : [[ReportColumn]], withAlternatingRowColor : Bool)
func startTable(_ columnsSet : [[ReportColumn]], withAlternatingRowColor : Bool, withInformationText : String?)
func addTableRow(_ cells : [ReportCell])
func addTotalRow(_ cells : [ReportCell])
func endTable()

func result() -> String
}

extension StatsReportFromDateGenerator
{
// init(_ startDate: Date, toDate endDate: Date, _ siteSpecific: Bool = false)
// {
// self(startDate, endDate, siteSpecific)
// }

func startTable(_ columnsSet : [[ReportColumn]])
{
self.startTable(columnsSet, withAlternatingRowColor: false, withInformationText: nil)
}

func startTable(_ columnsSet : [[ReportColumn]], withAlternatingRowColor : Bool)
{
self.startTable(columnsSet, withAlternatingRowColor: withAlternatingRowColor, withInformationText: nil)
}
}

class HtmlStatsReportFromDate: StatsReportFromDate
class HtmlStatsReportFromDate: StatsReportFromDateGenerator
{
let BG_ALTERNATECOLOR = "#E3E3E3"
let BG_FILLEDCELL = "#000000"
Expand Down Expand Up @@ -99,7 +122,7 @@ class HtmlStatsReportFromDate: StatsReportFromDate
report += text
}

func startTable(_ columnsSet : [ReportColumn]..., withAlternatingRowColor : Bool = false, withInformationText : String? = nil)
func startTable(_ columnsSet : [[ReportColumn]], withAlternatingRowColor : Bool, withInformationText : String?)
{
isAlternatingRowColor = withAlternatingRowColor
isGray = false
Expand Down Expand Up @@ -205,7 +228,7 @@ class HtmlStatsReportFromDate: StatsReportFromDate
}
}

class ExcelStatsReportFromDate: StatsReportFromDate
class ExcelStatsReportFromDate: StatsReportFromDateGenerator
{
let BG_ALTERNATECOLOR = "#E3E3E3"
let BG_FILLEDCELL = "#000000"
Expand Down Expand Up @@ -271,7 +294,7 @@ class ExcelStatsReportFromDate: StatsReportFromDate
rowsOnCurrentSheet.append(ExcelRow(cells))
}

func startTable(_ columnsSet: [ReportColumn]..., withAlternatingRowColor: Bool, withInformationText: String? = nil)
func startTable(_ columnsSet: [[ReportColumn]], withAlternatingRowColor: Bool, withInformationText: String?)
{
isAlternatingRowColor = withAlternatingRowColor
isGray = false
Expand Down
Loading

0 comments on commit 2f0fdde

Please sign in to comment.