Skip to content

Commit 29772c8

Browse files
author
Tarik Eshaq
authored
Fix make script (#43)
* fixes make_tag script to include swift-source * Adds GleanPlumbHelpers.swift
1 parent a276a45 commit 29772c8

File tree

3 files changed

+74
-2
lines changed

3 files changed

+74
-2
lines changed

make_tag.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ else
5252
fi
5353

5454
"$THIS_DIR/generate.sh" $AS_PATH || exit 1
55-
git add "$THIS_DIR/generated"
55+
git add "$THIS_DIR/swift-source"
5656

5757
if [ "false" = $IS_LOCAL ]; then
5858
echo "Removing application services repository after generating bindings"

swift-source/Generated/Metrics/Metrics.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ extension GleanMetrics {
2222
// Intentionally left private, no external user can instantiate a new global object.
2323
}
2424

25-
public static let info = BuildInfo(buildDate: DateComponents(calendar: Calendar.current, timeZone: TimeZone(abbreviation: "UTC"), year: 2022, month: 2, day: 12, hour: 15, minute: 6, second: 39))
25+
public static let info = BuildInfo(buildDate: DateComponents(calendar: Calendar.current, timeZone: TimeZone(abbreviation: "UTC"), year: 2022, month: 2, day: 16, hour: 17, minute: 5, second: 28))
2626
}
2727

2828
enum NimbusEvents {
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
5+
import Foundation
6+
7+
/**
8+
* Instances of this class are useful for implementing a messaging service based upon
9+
* Nimbus.
10+
*
11+
* The message helper is designed to help string interpolation and JEXL evalutaiuon against the context
12+
* of the attrtibutes Nimbus already knows about.
13+
*
14+
* App-specific, additional context can be given at creation time.
15+
*
16+
* The helpers are designed to evaluate multiple messages at a time, however: since the context may change
17+
* over time, the message helper should not be stored for long periods.
18+
*/
19+
public protocol GleanPlumbProtocol {
20+
func createMessageHelper() throws -> GleanPlumbMessageHelper
21+
func createMessageHelper(additionalContext: [String: Any]) throws -> GleanPlumbMessageHelper
22+
func createMessageHelper<T: Encodable>(additionalContext: T) throws -> GleanPlumbMessageHelper
23+
}
24+
25+
/**
26+
* A helper object to make working with Strings uniform across multiple implementations of the messaging
27+
* system.
28+
*
29+
* This object provides access to a JEXL evaluator which runs against the same context as provided by
30+
* Nimbus targeting.
31+
*
32+
* It should also provide a similar function for String substitution, though this scheduled for EXP-2159.
33+
*/
34+
public class GleanPlumbMessageHelper {
35+
private let targetingHelper: NimbusTargetingHelperProtocol
36+
private let stringHelper: NimbusStringHelperProtocol
37+
38+
init(targetingHelper: NimbusTargetingHelperProtocol, stringHelper: NimbusStringHelperProtocol) {
39+
self.targetingHelper = targetingHelper
40+
self.stringHelper = stringHelper
41+
}
42+
43+
public func evalJexl(expression: String) throws -> Bool {
44+
try targetingHelper.evalJexl(expression: expression)
45+
}
46+
47+
public func getUuid(template: String) -> String? {
48+
stringHelper.getUuid(template: template)
49+
}
50+
51+
public func stringFormat(template: String, uuid: String?) -> String {
52+
stringHelper.stringFormat(template: template, uuid: uuid)
53+
}
54+
}
55+
56+
// MARK: Dummy implementations
57+
58+
internal class AlwaysFalseTargetingHelper: NimbusTargetingHelperProtocol {
59+
public func evalJexl(expression _: String) throws -> Bool {
60+
false
61+
}
62+
}
63+
64+
internal class NonStringHelper: NimbusStringHelperProtocol {
65+
public func getUuid(template _: String) -> String? {
66+
nil
67+
}
68+
69+
public func stringFormat(template: String, uuid _: String?) -> String {
70+
template
71+
}
72+
}

0 commit comments

Comments
 (0)