Add new analytics parameters pathSuffix
Some checks failed
openium/resgen.swift/pipeline/head There was a failure building this commit
Some checks failed
openium/resgen.swift/pipeline/head There was a failure building this commit
This commit is contained in:
@@ -6,16 +6,16 @@ extension ColorYolo {
|
||||
|
||||
/// Color red is #FF0000 (light) or #FF0000 (dark)"
|
||||
public var red: Color {
|
||||
Color("red")
|
||||
Color("red", bundle: Bundle.main)
|
||||
}
|
||||
|
||||
/// Color green_alpha_50 is #A000FF00 (light) or #A000FF00 (dark)"
|
||||
public var green_alpha_50: Color {
|
||||
Color("green_alpha_50")
|
||||
Color("green_alpha_50", bundle: Bundle.main)
|
||||
}
|
||||
|
||||
/// Color blue_light_dark is #0000FF (light) or #0000AA (dark)"
|
||||
public var blue_light_dark: Color {
|
||||
Color("blue_light_dark")
|
||||
Color("blue_light_dark", bundle: Bundle.main)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,16 +6,16 @@ extension UIColorYolo {
|
||||
|
||||
/// Color red is #FF0000 (light) or #FF0000 (dark)"
|
||||
@objc public var red: UIColor {
|
||||
UIColor(named: "red")!
|
||||
UIColor(named: "red", in: Bundle.main, compatibleWith: nil)!
|
||||
}
|
||||
|
||||
/// Color green_alpha_50 is #A000FF00 (light) or #A000FF00 (dark)"
|
||||
@objc public var green_alpha_50: UIColor {
|
||||
UIColor(named: "green_alpha_50")!
|
||||
UIColor(named: "green_alpha_50", in: Bundle.main, compatibleWith: nil)!
|
||||
}
|
||||
|
||||
/// Color blue_light_dark is #0000FF (light) or #0000AA (dark)"
|
||||
@objc public var blue_light_dark: UIColor {
|
||||
UIColor(named: "blue_light_dark")!
|
||||
UIColor(named: "blue_light_dark", in: Bundle.main, compatibleWith: nil)!
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,26 +6,26 @@ import SwiftUI
|
||||
extension ImageYolo {
|
||||
|
||||
public var article_notification_pull_detail: Image {
|
||||
Image("article_notification_pull_detail")
|
||||
Image("article_notification_pull_detail", bundle: Bundle.main)
|
||||
}
|
||||
|
||||
public var article_notification_pull: Image {
|
||||
Image("article_notification_pull")
|
||||
Image("article_notification_pull", bundle: Bundle.main)
|
||||
}
|
||||
|
||||
public var new_article: Image {
|
||||
Image("new_article")
|
||||
Image("new_article", bundle: Bundle.main)
|
||||
}
|
||||
|
||||
public var welcome_background: Image {
|
||||
Image("welcome_background")
|
||||
Image("welcome_background", bundle: Bundle.main)
|
||||
}
|
||||
|
||||
public var article_trash: Image {
|
||||
Image("article_trash")
|
||||
Image("article_trash", bundle: Bundle.main)
|
||||
}
|
||||
|
||||
public var ic_close_article: Image {
|
||||
Image("ic_close_article")
|
||||
Image("ic_close_article", bundle: Bundle.main)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,26 +6,26 @@ import UIKit
|
||||
extension UIImageYolo {
|
||||
|
||||
public var article_notification_pull_detail: UIImage {
|
||||
UIImage(named: "article_notification_pull_detail")!
|
||||
UIImage(named: "article_notification_pull_detail", in: Bundle.main, with: nil)!
|
||||
}
|
||||
|
||||
public var article_notification_pull: UIImage {
|
||||
UIImage(named: "article_notification_pull")!
|
||||
UIImage(named: "article_notification_pull", in: Bundle.main, with: nil)!
|
||||
}
|
||||
|
||||
public var new_article: UIImage {
|
||||
UIImage(named: "new_article")!
|
||||
UIImage(named: "new_article", in: Bundle.main, with: nil)!
|
||||
}
|
||||
|
||||
public var welcome_background: UIImage {
|
||||
UIImage(named: "welcome_background")!
|
||||
UIImage(named: "welcome_background", in: Bundle.main, with: nil)!
|
||||
}
|
||||
|
||||
public var article_trash: UIImage {
|
||||
UIImage(named: "article_trash")!
|
||||
UIImage(named: "article_trash", in: Bundle.main, with: nil)!
|
||||
}
|
||||
|
||||
public var ic_close_article: UIImage {
|
||||
UIImage(named: "ic_close_article")!
|
||||
UIImage(named: "ic_close_article", in: Bundle.main, with: nil)!
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ fileprivate let kStringsFileName = "sampleStrings"
|
||||
|
||||
extension String {
|
||||
|
||||
internal enum KeyGenAllScript: String {
|
||||
public enum KeyGenAllScript: String {
|
||||
case param_lang = "param_lang"
|
||||
case generic_back = "generic_back"
|
||||
case generic_loading_data = "generic_loading_data"
|
||||
@@ -14,7 +14,7 @@ extension String {
|
||||
case test_equal_symbol = "test_equal_symbol"
|
||||
case placeholders_test_one = "placeholders_test_one"
|
||||
|
||||
internal var keyPath: KeyPath<String, String> {
|
||||
public var keyPath: KeyPath<String, String> {
|
||||
switch self {
|
||||
case .param_lang: return \String.param_lang
|
||||
case .generic_back: return \String.generic_back
|
||||
@@ -33,7 +33,7 @@ extension String {
|
||||
///
|
||||
/// Comment :
|
||||
/// No comment
|
||||
internal var param_lang: String {
|
||||
public var param_lang: String {
|
||||
NSLocalizedString("param_lang", tableName: kStringsFileName, bundle: Bundle.main, value: "en", comment: "")
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ extension String {
|
||||
///
|
||||
/// Comment :
|
||||
/// No comment
|
||||
internal var generic_back: String {
|
||||
public var generic_back: String {
|
||||
NSLocalizedString("generic_back", tableName: kStringsFileName, bundle: Bundle.main, value: "Back", comment: "")
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ extension String {
|
||||
///
|
||||
/// Comment :
|
||||
/// No comment
|
||||
internal var generic_loading_data: String {
|
||||
public var generic_loading_data: String {
|
||||
NSLocalizedString("generic_loading_data", tableName: kStringsFileName, bundle: Bundle.main, value: "Loading\ndata...", comment: "")
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ extension String {
|
||||
///
|
||||
/// Comment :
|
||||
/// No comment
|
||||
internal var generic_welcome_firstname_format: String {
|
||||
public var generic_welcome_firstname_format: String {
|
||||
NSLocalizedString("generic_welcome_firstname_format", tableName: kStringsFileName, bundle: Bundle.main, value: "Welcome \"%@\" !", comment: "")
|
||||
}
|
||||
/// Translation in en :
|
||||
@@ -70,7 +70,7 @@ extension String {
|
||||
///
|
||||
/// Comment :
|
||||
/// No comment
|
||||
internal func generic_welcome_firstname_format(arg0: String) -> String {
|
||||
public func generic_welcome_firstname_format(arg0: String) -> String {
|
||||
String(format: self.generic_welcome_firstname_format, arg0)
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ extension String {
|
||||
///
|
||||
/// Comment :
|
||||
/// No comment
|
||||
internal var test_equal_symbol: String {
|
||||
public var test_equal_symbol: String {
|
||||
NSLocalizedString("test_equal_symbol", tableName: kStringsFileName, bundle: Bundle.main, value: "1€ = 1 point !", comment: "")
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ extension String {
|
||||
///
|
||||
/// Comment :
|
||||
/// No comment
|
||||
internal var placeholders_test_one: String {
|
||||
public var placeholders_test_one: String {
|
||||
NSLocalizedString("placeholders_test_one", tableName: kStringsFileName, bundle: Bundle.main, value: "You %%: %2$@ %1$@ Age: %3$d", comment: "")
|
||||
}
|
||||
/// Translation in en :
|
||||
@@ -100,7 +100,7 @@ extension String {
|
||||
///
|
||||
/// Comment :
|
||||
/// No comment
|
||||
internal func placeholders_test_one(arg0: String, arg1: String, arg2: Int) -> String {
|
||||
public func placeholders_test_one(arg0: String, arg1: String, arg2: Int) -> String {
|
||||
String(format: self.placeholders_test_one, arg0, arg1, arg2)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Generated by ResgenSwift.Analytics 2.2.0
|
||||
|
||||
import Foundation
|
||||
import MatomoTracker
|
||||
import FirebaseAnalytics
|
||||
import os
|
||||
|
||||
@@ -24,6 +25,72 @@ internal protocol AnalyticsManagerProtocol {
|
||||
func setEnable(_ enable: Bool)
|
||||
}
|
||||
|
||||
// MARK: - Matomo
|
||||
|
||||
class MatomoAnalyticsManager: AnalyticsManagerProtocol {
|
||||
|
||||
// MARK: - Properties
|
||||
|
||||
private var tracker: MatomoTracker
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
init(siteId: String, url: String) {
|
||||
debugPrint("[Matomo service] Server URL: \(url)")
|
||||
debugPrint("[Matomo service] Site ID: \(siteId)")
|
||||
tracker = MatomoTracker(
|
||||
siteId: siteId,
|
||||
baseURL: URL(string: url)!
|
||||
)
|
||||
|
||||
#if DEBUG
|
||||
tracker.dispatchInterval = 5
|
||||
#endif
|
||||
|
||||
#if DEBUG
|
||||
tracker.logger = DefaultLogger(minLevel: .verbose)
|
||||
#endif
|
||||
|
||||
debugPrint("[Matomo service] Configured with content base: \(tracker.contentBase?.absoluteString ?? "-")")
|
||||
debugPrint("[Matomo service] Opt out: \(tracker.isOptedOut)")
|
||||
}
|
||||
|
||||
// MARK: - Methods
|
||||
|
||||
func logScreen(
|
||||
name: String,
|
||||
path: String,
|
||||
params: [String: Any]?
|
||||
) {
|
||||
guard let trackerUrl = tracker.contentBase?.absoluteString else { return }
|
||||
|
||||
let urlString = URL(string: "\(trackerUrl)" + "/" + "\(path)" + "yolo"
|
||||
tracker.track(
|
||||
view: [name],
|
||||
url: urlString
|
||||
)
|
||||
}
|
||||
|
||||
func logEvent(
|
||||
name: String,
|
||||
action: String,
|
||||
category: String,
|
||||
params: [String: Any]?
|
||||
) {
|
||||
tracker.track(
|
||||
eventWithCategory: category,
|
||||
action: action,
|
||||
name: name,
|
||||
number: nil,
|
||||
url: nil
|
||||
)
|
||||
}
|
||||
|
||||
func setEnable(_ enable: Bool) {
|
||||
tracker.isOptedOut = !enable
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Firebase
|
||||
|
||||
class FirebaseAnalyticsManager: AnalyticsManagerProtocol {
|
||||
@@ -40,7 +107,7 @@ class FirebaseAnalyticsManager: AnalyticsManagerProtocol {
|
||||
]
|
||||
|
||||
if path.isEmpty == false {
|
||||
parameters["path"] = path + "/iOS" as NSObject
|
||||
parameters["path"] = path + "/yolo" as NSObject
|
||||
}
|
||||
|
||||
if let supplementaryParameters = params {
|
||||
@@ -106,6 +173,7 @@ class FirebaseAnalyticsManager: AnalyticsManagerProtocol {
|
||||
|
||||
internal enum TrackerType: CaseIterable {
|
||||
|
||||
case matomo
|
||||
case firebase
|
||||
}
|
||||
|
||||
@@ -113,6 +181,7 @@ internal enum TrackerType: CaseIterable {
|
||||
|
||||
internal class AnalyticsManager {
|
||||
|
||||
@MainActor
|
||||
internal static var shared = AnalyticsManager()
|
||||
|
||||
private init() {}
|
||||
@@ -153,8 +222,12 @@ internal class AnalyticsManager {
|
||||
setAnalytics(enable: false, analytics)
|
||||
}
|
||||
|
||||
internal func configure(isDebugMode: Bool = false) {
|
||||
internal func configure(siteId: String, url: String, isDebugMode: Bool = false) {
|
||||
self.isDebugMode = isDebugMode
|
||||
managers[TrackerType.matomo] = MatomoAnalyticsManager(
|
||||
siteId: siteId,
|
||||
url: url
|
||||
)
|
||||
managers[TrackerType.firebase] = FirebaseAnalyticsManager()
|
||||
}
|
||||
|
||||
@@ -269,7 +342,7 @@ internal class AnalyticsManager {
|
||||
internal func logScreenS2DefOne() {
|
||||
logScreen(
|
||||
name: "s2 def one",
|
||||
path: "s2_def_one/",
|
||||
path: "s2_def_one",
|
||||
params: nil
|
||||
)
|
||||
}
|
||||
|
||||
29
SampleFiles/Tags/R.swift
Normal file
29
SampleFiles/Tags/R.swift
Normal file
@@ -0,0 +1,29 @@
|
||||
// Generated by ResgenSwift.Generate 2.2.0
|
||||
|
||||
class R: Sendable {
|
||||
static let images = R2Image()
|
||||
static let strings = R2String()
|
||||
static let fonts = R2Font()
|
||||
static let images = R2Image()
|
||||
static let ui = R2UI()
|
||||
}
|
||||
|
||||
final class R2Image: Sendable {}
|
||||
|
||||
final class R2String: Sendable {}
|
||||
|
||||
final class R2Font: Sendable {}
|
||||
|
||||
final class R2Image: Sendable {}
|
||||
|
||||
class R2UI: Sendable {
|
||||
let images = R2UIImage()
|
||||
let fonts = R2UIFont()
|
||||
let images = R2UIImage()
|
||||
}
|
||||
|
||||
final class R2UIImage: Sendable {}
|
||||
|
||||
final class R2UIFont: Sendable {}
|
||||
|
||||
final class R2UIImage: Sendable {}
|
||||
@@ -33,7 +33,7 @@ categories:
|
||||
screens:
|
||||
- id: s2_def_one
|
||||
name: s2 def one
|
||||
path: s2_def_one/
|
||||
path: s2_def_one///
|
||||
tags: ios
|
||||
|
||||
events:
|
||||
|
||||
@@ -54,8 +54,9 @@ FORCE_FLAG="$1"
|
||||
#
|
||||
## Analytics
|
||||
swift run -c release ResgenSwift analytics -f "./Tags/sampleTags.yml" \
|
||||
--target "firebase" \
|
||||
--output-file "./Tags/Generated/Analytics+GenAllScript.swift"
|
||||
--target "firebase matomo" \
|
||||
--output-file "./Tags/Generated/Analytics+GenAllScript.swift" \
|
||||
--path-suffix "sampleApp"
|
||||
#
|
||||
#echo "\n-------------------------\n"
|
||||
#
|
||||
|
||||
@@ -91,6 +91,7 @@ analytics:
|
||||
target: "matomo firebase"
|
||||
outputFile: ./Tags/Generated/Analytics+GenAllScript.swift
|
||||
visibility: internal
|
||||
pathSuffix: "yolo"
|
||||
|
||||
|
||||
#
|
||||
|
||||
@@ -39,7 +39,10 @@ struct Analytics: ParsableCommand {
|
||||
print("[\(Self.toolName)] Will generate analytics")
|
||||
|
||||
// Parse input file
|
||||
let sections = AnalyticsFileParser().parse(options.inputFile, target: options.target)
|
||||
let sections = AnalyticsFileParser().parse(
|
||||
options.inputFile,
|
||||
target: options.target
|
||||
)
|
||||
|
||||
// Generate extension
|
||||
AnalyticsGenerator.writeExtensionFiles(
|
||||
@@ -48,7 +51,8 @@ struct Analytics: ParsableCommand {
|
||||
tags: ["ios", "iosonly"],
|
||||
isStatic: options.staticMembers,
|
||||
outputFile: options.outputFile,
|
||||
visibility: options.extensionVisibility
|
||||
visibility: options.extensionVisibility,
|
||||
pathSuffix: options.pathSuffix
|
||||
)
|
||||
|
||||
print("[\(Self.toolName)] Analytics generated")
|
||||
|
||||
@@ -44,4 +44,9 @@ struct AnalyticsOptions: ParsableArguments {
|
||||
completion: .list(["public", "private", "package", "internal"])
|
||||
)
|
||||
var extensionVisibility: ExtensionVisibility = .internal
|
||||
|
||||
@Option(
|
||||
help: "Suffix to add to every path parameters. Default is 'iOS'."
|
||||
)
|
||||
var pathSuffix: String = "iOS"
|
||||
}
|
||||
|
||||
@@ -24,7 +24,8 @@ enum AnalyticsGenerator {
|
||||
tags: [String],
|
||||
isStatic: Bool,
|
||||
outputFile: String,
|
||||
visibility: ExtensionVisibility
|
||||
visibility: ExtensionVisibility,
|
||||
pathSuffix: String
|
||||
) {
|
||||
// Get target type from enum
|
||||
let targetsString: [String] = target.components(separatedBy: " ")
|
||||
@@ -44,7 +45,8 @@ enum AnalyticsGenerator {
|
||||
sections: sections,
|
||||
tags: tags,
|
||||
isStatic: isStatic,
|
||||
visibility: visibility
|
||||
visibility: visibility,
|
||||
pathSuffix: pathSuffix
|
||||
)
|
||||
|
||||
// Write content
|
||||
@@ -65,13 +67,15 @@ enum AnalyticsGenerator {
|
||||
sections: [AnalyticsCategory],
|
||||
tags: [String],
|
||||
isStatic: Bool,
|
||||
visibility: ExtensionVisibility
|
||||
visibility: ExtensionVisibility,
|
||||
pathSuffix: String
|
||||
) -> String {
|
||||
[
|
||||
getHeader(
|
||||
targets: targets,
|
||||
isStatic: isStatic,
|
||||
visibility: visibility
|
||||
visibility: visibility,
|
||||
pathSuffix: pathSuffix
|
||||
),
|
||||
getProperties(
|
||||
sections: sections,
|
||||
@@ -89,14 +93,15 @@ enum AnalyticsGenerator {
|
||||
private static func getHeader(
|
||||
targets: [TrackerType],
|
||||
isStatic: Bool,
|
||||
visibility: ExtensionVisibility
|
||||
visibility: ExtensionVisibility,
|
||||
pathSuffix: String
|
||||
) -> String {
|
||||
"""
|
||||
// Generated by ResgenSwift.\(Analytics.toolName) \(ResgenSwiftVersion)
|
||||
|
||||
\(Self.getImport(targets: targets))
|
||||
|
||||
\(Self.getAnalyticsProtocol(targets: targets, visibility: visibility))
|
||||
\(Self.getAnalyticsProtocol(targets: targets, visibility: visibility, pathSuffix: pathSuffix))
|
||||
|
||||
\(Self.getTrackerTypeEnum(targets: targets, visibility: visibility))
|
||||
|
||||
@@ -317,7 +322,8 @@ enum AnalyticsGenerator {
|
||||
|
||||
private static func getAnalyticsProtocol(
|
||||
targets: [TrackerType],
|
||||
visibility: ExtensionVisibility
|
||||
visibility: ExtensionVisibility,
|
||||
pathSuffix: String
|
||||
) -> String {
|
||||
let proto = """
|
||||
// MARK: - Protocol
|
||||
@@ -344,11 +350,11 @@ enum AnalyticsGenerator {
|
||||
var result: [String] = [proto]
|
||||
|
||||
if targets.contains(TrackerType.matomo) {
|
||||
result.append(MatomoGenerator.service)
|
||||
result.append(MatomoGenerator.service(pathSuffix: pathSuffix))
|
||||
}
|
||||
|
||||
if targets.contains(TrackerType.firebase) {
|
||||
result.append(FirebaseGenerator.service)
|
||||
result.append(FirebaseGenerator.service(pathSuffix: pathSuffix))
|
||||
}
|
||||
|
||||
return result.joined(separator: "\n\n")
|
||||
|
||||
@@ -11,10 +11,10 @@ import Foundation
|
||||
|
||||
enum FirebaseGenerator {
|
||||
|
||||
static var service: String {
|
||||
static func service(pathSuffix: String) -> String {
|
||||
[
|
||||
Self.header,
|
||||
Self.logScreen,
|
||||
Self.logScreen(pathSuffix: pathSuffix),
|
||||
Self.logEvent,
|
||||
Self.enable,
|
||||
Self.footer
|
||||
@@ -35,8 +35,14 @@ enum FirebaseGenerator {
|
||||
"""
|
||||
}
|
||||
|
||||
private static var logScreen: String {
|
||||
"""
|
||||
private static func logScreen(pathSuffix: String) -> String {
|
||||
let pathSuffixCode: String = if pathSuffix.isEmpty == false {
|
||||
" + \"/\(pathSuffix)\""
|
||||
} else {
|
||||
""
|
||||
}
|
||||
|
||||
return """
|
||||
func logScreen(
|
||||
name: String,
|
||||
path: String,
|
||||
@@ -47,7 +53,7 @@ enum FirebaseGenerator {
|
||||
]
|
||||
|
||||
if path.isEmpty == false {
|
||||
parameters["path"] = path + "/iOS" as NSObject
|
||||
parameters["path"] = path\(pathSuffixCode) as NSObject
|
||||
}
|
||||
|
||||
if let supplementaryParameters = params {
|
||||
|
||||
@@ -11,11 +11,11 @@ import Foundation
|
||||
|
||||
enum MatomoGenerator {
|
||||
|
||||
static var service: String {
|
||||
static func service(pathSuffix: String) -> String {
|
||||
[
|
||||
Self.header,
|
||||
Self.setup,
|
||||
Self.logScreen,
|
||||
Self.logScreen(pathSuffix: pathSuffix),
|
||||
Self.logEvent,
|
||||
Self.enable,
|
||||
Self.footer
|
||||
@@ -67,8 +67,14 @@ enum MatomoGenerator {
|
||||
"""
|
||||
}
|
||||
|
||||
private static var logScreen: String {
|
||||
"""
|
||||
private static func logScreen(pathSuffix: String) -> String {
|
||||
let pathSuffixCode: String = if pathSuffix.isEmpty == false {
|
||||
" + \"/\(pathSuffix)\""
|
||||
} else {
|
||||
""
|
||||
}
|
||||
|
||||
return """
|
||||
func logScreen(
|
||||
name: String,
|
||||
path: String,
|
||||
@@ -76,7 +82,7 @@ enum MatomoGenerator {
|
||||
) {
|
||||
guard let trackerUrl = tracker.contentBase?.absoluteString else { return }
|
||||
|
||||
let urlString = URL(string: "\\(trackerUrl)" + "/" + "\\(path)" + "iOS")
|
||||
let urlString = URL(string: "\\(trackerUrl)" + "/" + "\\(path)"\(pathSuffixCode)
|
||||
tracker.track(
|
||||
view: [name],
|
||||
url: urlString
|
||||
|
||||
@@ -169,7 +169,6 @@ class AnalyticsFileParser {
|
||||
|
||||
if target.contains(TrackerType.matomo.value) {
|
||||
// Path
|
||||
|
||||
guard let path = screen.path else {
|
||||
let error = AnalyticsError.missingElement("screen path")
|
||||
print(error.description)
|
||||
@@ -181,6 +180,10 @@ class AnalyticsFileParser {
|
||||
definition.path = path
|
||||
}
|
||||
|
||||
while definition.path.last == "/" {
|
||||
definition.path = String(definition.path.dropLast())
|
||||
}
|
||||
|
||||
return definition
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,19 +89,22 @@ struct AnalyticsConfiguration: Codable, CustomDebugStringConvertible {
|
||||
let outputFile: String
|
||||
let visibility: String?
|
||||
let staticMembers: Bool?
|
||||
let pathSuffix: String?
|
||||
|
||||
internal init(
|
||||
inputFile: String,
|
||||
target: String,
|
||||
outputFile: String,
|
||||
visibility: String?,
|
||||
staticMembers: Bool?
|
||||
staticMembers: Bool?,
|
||||
pathSuffix: String?
|
||||
) {
|
||||
self.inputFile = inputFile
|
||||
self.target = target
|
||||
self.outputFile = outputFile
|
||||
self.visibility = visibility
|
||||
self.staticMembers = staticMembers
|
||||
self.pathSuffix = pathSuffix
|
||||
}
|
||||
|
||||
var debugDescription: String {
|
||||
@@ -112,6 +115,7 @@ struct AnalyticsConfiguration: Codable, CustomDebugStringConvertible {
|
||||
- Output file: \(outputFile)
|
||||
- Visiblity: \(visibility ?? "default")
|
||||
- Static members: \(staticMembers != nil ? "\(String(describing: staticMembers))" : "default")
|
||||
- Path suffix: \(pathSuffix != nil ? "\(String(describing: pathSuffix))" : "default")
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,8 @@ extension AnalyticsConfiguration: Runnable {
|
||||
// Add optional parameters
|
||||
[
|
||||
("--visibility", visibility),
|
||||
("--static-members", staticMembers?.description)
|
||||
("--static-members", staticMembers?.description),
|
||||
("--path-suffix", pathSuffix)
|
||||
].forEach { argumentName, argumentValue in
|
||||
if let argumentValue {
|
||||
args += [
|
||||
|
||||
@@ -234,7 +234,8 @@ final class AnalyticsGeneratorTests: XCTestCase {
|
||||
sections: [sectionOne, sectionTwo, sectionThree],
|
||||
tags: ["ios", "iosonly"],
|
||||
isStatic: false,
|
||||
visibility: .internal
|
||||
visibility: .internal,
|
||||
pathSuffix: "iOS"
|
||||
)
|
||||
|
||||
// Expect Analytics
|
||||
@@ -448,7 +449,8 @@ final class AnalyticsGeneratorTests: XCTestCase {
|
||||
sections: [sectionOne, sectionTwo, sectionThree],
|
||||
tags: ["ios", "iosonly"],
|
||||
isStatic: false,
|
||||
visibility: .internal
|
||||
visibility: .internal,
|
||||
pathSuffix: "iOS"
|
||||
)
|
||||
// Expect Analytics
|
||||
let expect = """
|
||||
@@ -664,7 +666,8 @@ final class AnalyticsGeneratorTests: XCTestCase {
|
||||
sections: [sectionOne, sectionTwo, sectionThree],
|
||||
tags: ["ios", "iosonly"],
|
||||
isStatic: false,
|
||||
visibility: .internal
|
||||
visibility: .internal,
|
||||
pathSuffix: "iOS"
|
||||
)
|
||||
|
||||
// Expect Analytics
|
||||
|
||||
@@ -20,7 +20,8 @@ final class AnalyticsConfigurationTests: XCTestCase {
|
||||
target: "matomo firebase",
|
||||
outputFile: "Analytics/Generated/AnalyticsManager.swift",
|
||||
visibility: nil,
|
||||
staticMembers: nil
|
||||
staticMembers: nil,
|
||||
pathSuffix: nil
|
||||
)
|
||||
|
||||
// When
|
||||
@@ -48,7 +49,8 @@ final class AnalyticsConfigurationTests: XCTestCase {
|
||||
target: "matomo firebase",
|
||||
outputFile: "Analytics/Generated/AnalyticsManager.swift",
|
||||
visibility: "public",
|
||||
staticMembers: false
|
||||
staticMembers: false,
|
||||
pathSuffix: "mySuffix"
|
||||
)
|
||||
|
||||
// When
|
||||
@@ -68,7 +70,9 @@ final class AnalyticsConfigurationTests: XCTestCase {
|
||||
"--visibility",
|
||||
"public",
|
||||
"--static-members",
|
||||
"false"
|
||||
"false",
|
||||
"--path-suffix",
|
||||
"mySuffix"
|
||||
]
|
||||
|
||||
XCTAssertEqual(arguments, expectedArguments)
|
||||
|
||||
Reference in New Issue
Block a user