Add visibility parameters to control scope of generated extension
Some checks failed
gitea-openium/resgen.swift/pipeline/head There was a failure building this commit
Some checks failed
gitea-openium/resgen.swift/pipeline/head There was a failure building this commit
This commit is contained in:
@ -55,11 +55,11 @@ final class AnalyticsDefinitionTests: XCTestCase {
|
||||
definition.path = "ecran_un/"
|
||||
|
||||
// When
|
||||
let propertyScreen = definition.getProperty()
|
||||
|
||||
let propertyScreen = definition.getProperty(visibility: .internal)
|
||||
|
||||
// Expect
|
||||
let expectScreen = """
|
||||
func logScreenDefinitionName() {
|
||||
internal func logScreenDefinitionName() {
|
||||
logScreen(
|
||||
name: "Ecran un",
|
||||
path: "ecran_un/",
|
||||
@ -76,11 +76,11 @@ final class AnalyticsDefinitionTests: XCTestCase {
|
||||
let definition = AnalyticsDefinition(id: "definition_name", name: "Ecran un", type: .event)
|
||||
|
||||
// When
|
||||
let propertyEvent = definition.getProperty()
|
||||
|
||||
let propertyEvent = definition.getProperty(visibility: .public)
|
||||
|
||||
// Expect
|
||||
let expectEvent = """
|
||||
func logEventDefinitionName() {
|
||||
public func logEventDefinitionName() {
|
||||
logEvent(
|
||||
name: "Ecran un",
|
||||
action: "",
|
||||
@ -99,11 +99,11 @@ final class AnalyticsDefinitionTests: XCTestCase {
|
||||
definition.path = "ecran_un/"
|
||||
|
||||
// When
|
||||
let propertyScreen = definition.getStaticProperty()
|
||||
|
||||
let propertyScreen = definition.getStaticProperty(visibility: .private)
|
||||
|
||||
// Expect
|
||||
let expectScreen = """
|
||||
static func logScreenDefinitionName() {
|
||||
private static func logScreenDefinitionName() {
|
||||
AnalyticsManager.shared.logScreen(
|
||||
name: "Ecran un",
|
||||
path: "ecran_un/",
|
||||
@ -120,11 +120,11 @@ final class AnalyticsDefinitionTests: XCTestCase {
|
||||
let definition = AnalyticsDefinition(id: "definition_name", name: "Ecran un", type: .event)
|
||||
|
||||
// When
|
||||
let propertyEvent = definition.getStaticProperty()
|
||||
|
||||
let propertyEvent = definition.getStaticProperty(visibility: .package)
|
||||
|
||||
// Expect
|
||||
let expectEvent = """
|
||||
static func logEventDefinitionName() {
|
||||
package static func logEventDefinitionName() {
|
||||
AnalyticsManager.shared.logEvent(
|
||||
name: "Ecran un",
|
||||
action: "",
|
||||
|
@ -32,11 +32,11 @@ final class AnalyticsGeneratorTests: XCTestCase {
|
||||
return definition
|
||||
}
|
||||
|
||||
private func protocolString() -> String {
|
||||
private func protocolString(visibility: ExtensionVisibility) -> String {
|
||||
"""
|
||||
// MARK: - Protocol
|
||||
|
||||
protocol AnalyticsManagerProtocol {
|
||||
\(visibility) protocol AnalyticsManagerProtocol {
|
||||
|
||||
func logScreen(
|
||||
name: String,
|
||||
@ -234,7 +234,7 @@ final class AnalyticsGeneratorTests: XCTestCase {
|
||||
sections: [sectionOne, sectionTwo, sectionThree],
|
||||
tags: ["ios", "iosonly"],
|
||||
staticVar: false,
|
||||
extensionName: "GenAnalytics"
|
||||
visibility: .public
|
||||
)
|
||||
|
||||
// Expect Analytics
|
||||
@ -244,22 +244,22 @@ final class AnalyticsGeneratorTests: XCTestCase {
|
||||
import Foundation
|
||||
import FirebaseAnalytics
|
||||
|
||||
\(protocolString())
|
||||
\(protocolString(visibility: .public))
|
||||
|
||||
\(firebaseString())
|
||||
|
||||
// MARK: - Traker Type
|
||||
|
||||
enum TrackerType: CaseIterable {
|
||||
public enum TrackerType: CaseIterable {
|
||||
|
||||
case firebase
|
||||
}
|
||||
|
||||
// MARK: - Manager
|
||||
|
||||
class AnalyticsManager {
|
||||
public class AnalyticsManager {
|
||||
|
||||
static var shared = AnalyticsManager()
|
||||
public static var shared = AnalyticsManager()
|
||||
|
||||
private init() {}
|
||||
|
||||
@ -287,15 +287,15 @@ final class AnalyticsGeneratorTests: XCTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
func enableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) {
|
||||
public func enableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) {
|
||||
setAnalytics(enable: true, analytics)
|
||||
}
|
||||
|
||||
func disableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) {
|
||||
public func disableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) {
|
||||
setAnalytics(enable: false, analytics)
|
||||
}
|
||||
|
||||
func configure() {
|
||||
public func configure() {
|
||||
managers[TrackerType.firebase] = FirebaseAnalyticsManager()
|
||||
}
|
||||
|
||||
@ -337,7 +337,7 @@ final class AnalyticsGeneratorTests: XCTestCase {
|
||||
|
||||
// MARK: - section_one
|
||||
|
||||
func logScreenS1DefOne() {
|
||||
public func logScreenS1DefOne() {
|
||||
logScreen(
|
||||
name: "s1 def one",
|
||||
path: "",
|
||||
@ -345,7 +345,7 @@ final class AnalyticsGeneratorTests: XCTestCase {
|
||||
)
|
||||
}
|
||||
|
||||
func logEventS1DefTwo() {
|
||||
public func logEventS1DefTwo() {
|
||||
logEvent(
|
||||
name: "s1 def two",
|
||||
action: "",
|
||||
@ -356,7 +356,7 @@ final class AnalyticsGeneratorTests: XCTestCase {
|
||||
|
||||
// MARK: - section_two
|
||||
|
||||
func logScreenS2DefOne() {
|
||||
public func logScreenS2DefOne() {
|
||||
logScreen(
|
||||
name: "s2 def one",
|
||||
path: "",
|
||||
@ -399,7 +399,7 @@ final class AnalyticsGeneratorTests: XCTestCase {
|
||||
sections: [sectionOne, sectionTwo, sectionThree],
|
||||
tags: ["ios", "iosonly"],
|
||||
staticVar: false,
|
||||
extensionName: "GenAnalytics"
|
||||
visibility: .package
|
||||
)
|
||||
// Expect Analytics
|
||||
let expect = """
|
||||
@ -408,22 +408,22 @@ final class AnalyticsGeneratorTests: XCTestCase {
|
||||
import Foundation
|
||||
import MatomoTracker
|
||||
|
||||
\(protocolString())
|
||||
\(protocolString(visibility: .package))
|
||||
|
||||
\(matomoString())
|
||||
|
||||
// MARK: - Traker Type
|
||||
|
||||
enum TrackerType: CaseIterable {
|
||||
package enum TrackerType: CaseIterable {
|
||||
|
||||
case matomo
|
||||
}
|
||||
|
||||
// MARK: - Manager
|
||||
|
||||
class AnalyticsManager {
|
||||
package class AnalyticsManager {
|
||||
|
||||
static var shared = AnalyticsManager()
|
||||
package static var shared = AnalyticsManager()
|
||||
|
||||
private init() {}
|
||||
|
||||
@ -451,15 +451,15 @@ final class AnalyticsGeneratorTests: XCTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
func enableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) {
|
||||
package func enableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) {
|
||||
setAnalytics(enable: true, analytics)
|
||||
}
|
||||
|
||||
func disableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) {
|
||||
package func disableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) {
|
||||
setAnalytics(enable: false, analytics)
|
||||
}
|
||||
|
||||
func configure(siteId: String, url: String) {
|
||||
package func configure(siteId: String, url: String) {
|
||||
managers[TrackerType.matomo] = MatomoAnalyticsManager(
|
||||
siteId: siteId,
|
||||
url: url
|
||||
@ -504,7 +504,7 @@ final class AnalyticsGeneratorTests: XCTestCase {
|
||||
|
||||
// MARK: - section_one
|
||||
|
||||
func logScreenS1DefOne() {
|
||||
package func logScreenS1DefOne() {
|
||||
logScreen(
|
||||
name: "s1 def one",
|
||||
path: "s1_def_one/",
|
||||
@ -512,7 +512,7 @@ final class AnalyticsGeneratorTests: XCTestCase {
|
||||
)
|
||||
}
|
||||
|
||||
func logEventS1DefTwo() {
|
||||
package func logEventS1DefTwo() {
|
||||
logEvent(
|
||||
name: "s1 def two",
|
||||
action: "test",
|
||||
@ -523,7 +523,7 @@ final class AnalyticsGeneratorTests: XCTestCase {
|
||||
|
||||
// MARK: - section_two
|
||||
|
||||
func logScreenS2DefOne() {
|
||||
package func logScreenS2DefOne() {
|
||||
logScreen(
|
||||
name: "s2 def one",
|
||||
path: "s2_def_one/",
|
||||
@ -566,7 +566,7 @@ final class AnalyticsGeneratorTests: XCTestCase {
|
||||
sections: [sectionOne, sectionTwo, sectionThree],
|
||||
tags: ["ios", "iosonly"],
|
||||
staticVar: false,
|
||||
extensionName: "GenAnalytics"
|
||||
visibility: .internal
|
||||
)
|
||||
|
||||
// Expect Analytics
|
||||
@ -577,7 +577,7 @@ final class AnalyticsGeneratorTests: XCTestCase {
|
||||
import MatomoTracker
|
||||
import FirebaseAnalytics
|
||||
|
||||
\(protocolString())
|
||||
\(protocolString(visibility: .internal))
|
||||
|
||||
\(matomoString())
|
||||
|
||||
@ -585,7 +585,7 @@ final class AnalyticsGeneratorTests: XCTestCase {
|
||||
|
||||
// MARK: - Traker Type
|
||||
|
||||
enum TrackerType: CaseIterable {
|
||||
internal enum TrackerType: CaseIterable {
|
||||
|
||||
case matomo
|
||||
case firebase
|
||||
@ -593,9 +593,9 @@ final class AnalyticsGeneratorTests: XCTestCase {
|
||||
|
||||
// MARK: - Manager
|
||||
|
||||
class AnalyticsManager {
|
||||
internal class AnalyticsManager {
|
||||
|
||||
static var shared = AnalyticsManager()
|
||||
internal static var shared = AnalyticsManager()
|
||||
|
||||
private init() {}
|
||||
|
||||
@ -623,15 +623,15 @@ final class AnalyticsGeneratorTests: XCTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
func enableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) {
|
||||
internal func enableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) {
|
||||
setAnalytics(enable: true, analytics)
|
||||
}
|
||||
|
||||
func disableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) {
|
||||
internal func disableAnalytics(_ analytics: [TrackerType] = TrackerType.allCases) {
|
||||
setAnalytics(enable: false, analytics)
|
||||
}
|
||||
|
||||
func configure(siteId: String, url: String) {
|
||||
internal func configure(siteId: String, url: String) {
|
||||
managers[TrackerType.matomo] = MatomoAnalyticsManager(
|
||||
siteId: siteId,
|
||||
url: url
|
||||
@ -677,7 +677,7 @@ final class AnalyticsGeneratorTests: XCTestCase {
|
||||
|
||||
// MARK: - section_one
|
||||
|
||||
func logScreenS1DefOne() {
|
||||
internal func logScreenS1DefOne() {
|
||||
logScreen(
|
||||
name: "s1 def one",
|
||||
path: "s1_def_one/",
|
||||
@ -685,7 +685,7 @@ final class AnalyticsGeneratorTests: XCTestCase {
|
||||
)
|
||||
}
|
||||
|
||||
func logEventS1DefTwo() {
|
||||
internal func logEventS1DefTwo() {
|
||||
logEvent(
|
||||
name: "s1 def two",
|
||||
action: "test",
|
||||
@ -696,7 +696,7 @@ final class AnalyticsGeneratorTests: XCTestCase {
|
||||
|
||||
// MARK: - section_two
|
||||
|
||||
func logScreenS2DefOne() {
|
||||
internal func logScreenS2DefOne() {
|
||||
logScreen(
|
||||
name: "s2 def one",
|
||||
path: "s2_def_one/",
|
||||
|
Reference in New Issue
Block a user