Skip to content

Commit 8605b6b

Browse files
committed
Update playground to match plist/yaml file changes
1 parent 8827e55 commit 8605b6b

File tree

3 files changed

+57
-60
lines changed

3 files changed

+57
-60
lines changed

SwiftGen.playground/Pages/JSON-Demo.xcplaygroundpage/Contents.swift

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ import Foundation
2424

2525
// swiftlint:disable identifier_name line_length number_separator type_body_length
2626
internal enum JSONFilesInline {
27+
internal enum Configuration {
28+
internal static let apiVersion: String = "2"
29+
internal static let country: Any? = nil
30+
internal static let environment: String = "staging"
31+
internal static let options: [String: Any] = ["screen-order": ["1", "2", "3"]]
32+
}
2733
internal enum Documents {
2834
internal enum Document1 {
2935
internal static let items: [String] = ["Mark McGwire", "Sammy Sosa", "Ken Griffey"]
@@ -33,22 +39,16 @@ internal enum JSONFilesInline {
3339
}
3440
}
3541
internal enum GroceryList {
36-
internal static let items: [String] = ["value1", "value2"]
37-
}
38-
internal enum Json {
39-
internal static let key2: String = "2"
40-
internal static let key3: [String: Any] = ["nestedKey3": ["1", "2", "3"]]
41-
internal static let key4: Any? = nil
42-
internal static let key1: String = "value1"
42+
internal static let items: [String] = ["Eggs", "Bread", "Milk"]
4343
}
4444
internal enum Mapping {
45-
internal static let key2: Double = 1.0
46-
internal static let key3: [String: Any] = ["nestedKey1": "nestedValue1", "nestedKey2": "nestedValue2"]
47-
internal static let key4: Any? = nil
48-
internal static let key1: String = "value1"
45+
internal static let car: Any? = nil
46+
internal static let foo: [String: Any] = ["bar": "banana", "baz": "orange"]
47+
internal static let hello: String = "world"
48+
internal static let weight: Double = 33.3
4949
}
50-
internal enum Scalar {
51-
internal static let value: String = "value1"
50+
internal enum Version {
51+
internal static let value: String = "1.2.3.beta.4"
5252
}
5353
}
5454
// swiftlint:enable identifier_name line_length number_separator type_body_length
@@ -62,12 +62,12 @@ internal enum JSONFilesInline {
6262

6363
// swiftlint:disable identifier_name line_length type_body_length
6464
internal enum JSONFilesRuntime {
65-
internal enum Json {
66-
private static let _document = JSONDocument(path: "json.json")
67-
internal static let key2: String = _document["key2"]
68-
internal static let key3: [String: Any] = _document["key3"]
69-
internal static let key4: Any? = _document["key4"]
70-
internal static let key1: String = _document["key1"]
65+
internal enum Configuration {
66+
private static let _document = JSONDocument(path: "configuration.json")
67+
internal static let apiVersion: String = _document["api-version"]
68+
internal static let country: Any? = _document["country"]
69+
internal static let environment: String = _document["environment"]
70+
internal static let options: [String: Any] = _document["options"]
7171
}
7272
}
7373
// swiftlint:enable identifier_name line_length type_body_length
@@ -76,10 +76,9 @@ internal enum JSONFilesRuntime {
7676

7777
// Access content embedded inline in Swift
7878
let list = JSONFilesInline.GroceryList.items
79-
let dictionary = JSONFilesInline.Mapping.key3
80-
let name = JSONFilesInline.Scalar.value
79+
let dictionary = JSONFilesInline.Configuration.options
80+
let name = JSONFilesInline.Version.value
8181

8282
// Or access content by loading JSON file at runtime
83-
let stringValue = JSONFilesRuntime.Json.key1
84-
let doubleValue = JSONFilesRuntime.Json.key2
85-
let info = JSONFilesRuntime.Json.key3
83+
let stringValue = JSONFilesRuntime.Configuration.apiVersion
84+
let info = JSONFilesRuntime.Configuration.options

SwiftGen.playground/Pages/Plist-Demo.xcplaygroundpage/Contents.swift

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,18 @@ import Foundation
2626
internal enum PlistFilesInline {
2727
internal enum Info {
2828
internal static let cfBundleDevelopmentRegion: String = "en"
29+
internal static let cfBundleInfoDictionaryVersion: String = "6.0"
2930
internal static let cfBundleShortVersionString: String = "1.2.0"
31+
internal static let fabric: [String: Any] = ["APIKey": "512345678900aaafffff", "Kits": [["KitInfo": [:], "KitName": "Crashlytics"]]]
3032
internal static let uiLaunchStoryboardName: String = "LaunchScreen"
31-
internal static let cfBundleInfoDictionaryVersion: String = "6.0"
32-
internal static let uiStatusBarStyle: String = "UIStatusBarStyleDefault"
33-
internal static let uiSupportedInterfaceOrientations: [String] = ["UIInterfaceOrientationPortrait", "UIInterfaceOrientationPortraitUpsideDown", "UIInterfaceOrientationLandscapeRight", "UIInterfaceOrientationLandscapeLeft"]
3433
internal static let uiMainStoryboardFile: String = "Start"
3534
}
36-
internal enum Array {
37-
internal static let items: [String] = ["value1", "value2"]
35+
internal enum Configuration {
36+
internal static let environment: String = "development"
37+
internal static let options: [String: Any] = ["Animation Style": "Party Mode"]
3838
}
39-
internal enum Dictionary {
40-
internal static let key2: [String: Any] = ["nestedKey2": "nestedValue2"]
41-
internal static let key1: String = "value1"
39+
internal enum ShoppingList {
40+
internal static let items: [String] = ["Eggs", "Bread", "Milk"]
4241
}
4342
}
4443
// swiftlint:enable identifier_name line_length number_separator type_body_length
@@ -55,20 +54,19 @@ internal enum PlistFilesRuntime {
5554
internal enum Info {
5655
private static let _document = PlistDocument(path: "TestInfo.plist")
5756
internal static let cfBundleDevelopmentRegion: String = _document["CFBundleDevelopmentRegion"]
57+
internal static let cfBundleInfoDictionaryVersion: String = _document["CFBundleInfoDictionaryVersion"]
5858
internal static let cfBundleShortVersionString: String = _document["CFBundleShortVersionString"]
59+
internal static let fabric: [String: Any] = _document["Fabric"]
5960
internal static let uiLaunchStoryboardName: String = _document["UILaunchStoryboardName"]
60-
internal static let cfBundleInfoDictionaryVersion: String = _document["CFBundleInfoDictionaryVersion"]
61-
internal static let uiStatusBarStyle: String = _document["UIStatusBarStyle"]
62-
internal static let uiSupportedInterfaceOrientations: [String] = _document["UISupportedInterfaceOrientations"]
6361
internal static let uiMainStoryboardFile: String = _document["UIMainStoryboardFile"]
6462
}
65-
internal enum Array {
66-
internal static let items: [String] = arrayFromPlist(at: "array.plist")
63+
internal enum Configuration {
64+
private static let _document = PlistDocument(path: "configuration.plist")
65+
internal static let environment: String = _document["Environment"]
66+
internal static let options: [String: Any] = _document["Options"]
6767
}
68-
internal enum Dictionary {
69-
private static let _document = PlistDocument(path: "dictionary.plist")
70-
internal static let key2: [String: Any] = _document["key2"]
71-
internal static let key1: String = _document["key1"]
68+
internal enum ShoppingList {
69+
internal static let items: [String] = arrayFromPlist(at: "shopping-list.plist")
7270
}
7371
}
7472
// swiftlint:enable identifier_name line_length type_body_length
@@ -77,9 +75,9 @@ internal enum PlistFilesRuntime {
7775

7876
// Access content embedded inline in Swift
7977
let region = PlistFilesInline.Info.cfBundleDevelopmentRegion
80-
let orientations = PlistFilesInline.Info.uiSupportedInterfaceOrientations
81-
let info = PlistFilesInline.Dictionary.key2
78+
let fabricKits = PlistFilesInline.Info.fabric["Kits"]
79+
let options = PlistFilesInline.Configuration.options
8280

8381
// Or access content by loading Plist files at runtime
84-
let style = PlistFilesRuntime.Info.uiStatusBarStyle
85-
let items = PlistFilesRuntime.Array.items
82+
let style = PlistFilesRuntime.Info.uiMainStoryboardFile
83+
let items = PlistFilesRuntime.ShoppingList.items

SwiftGen.playground/Pages/YAML-Demo.xcplaygroundpage/Contents.swift

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ import Foundation
2020

2121
// swiftlint:disable identifier_name line_length number_separator type_body_length
2222
internal enum YAMLFiles {
23+
internal enum Configuration {
24+
internal static let apiVersion: String = "2"
25+
internal static let country: Any? = nil
26+
internal static let environment: String = "staging"
27+
internal static let options: [String: Any] = ["screen-order": ["1", "2", "3"]]
28+
}
2329
internal enum Documents {
2430
internal enum Document1 {
2531
internal static let items: [String] = ["Mark McGwire", "Sammy Sosa", "Ken Griffey"]
@@ -29,22 +35,16 @@ internal enum YAMLFiles {
2935
}
3036
}
3137
internal enum GroceryList {
32-
internal static let items: [String] = ["value1", "value2"]
33-
}
34-
internal enum Json {
35-
internal static let key2: String = "2"
36-
internal static let key3: [String: Any] = ["nestedKey3": ["1", "2", "3"]]
37-
internal static let key4: Any? = nil
38-
internal static let key1: String = "value1"
38+
internal static let items: [String] = ["Eggs", "Bread", "Milk"]
3939
}
4040
internal enum Mapping {
41-
internal static let key2: Double = 1.0
42-
internal static let key3: [String: Any] = ["nestedKey1": "nestedValue1", "nestedKey2": "nestedValue2"]
43-
internal static let key4: Any? = nil
44-
internal static let key1: String = "value1"
41+
internal static let car: Any? = nil
42+
internal static let foo: [String: Any] = ["bar": "banana", "baz": "orange"]
43+
internal static let hello: String = "world"
44+
internal static let weight: Double = 33.3
4545
}
46-
internal enum Scalar {
47-
internal static let value: String = "value1"
46+
internal enum Version {
47+
internal static let value: String = "1.2.3.beta.4"
4848
}
4949
}
5050
// swiftlint:enable identifier_name line_length number_separator type_body_length
@@ -53,6 +53,6 @@ internal enum YAMLFiles {
5353

5454
// Access content embedded inline in Swift
5555
let list = YAMLFiles.GroceryList.items
56-
let dictionary = YAMLFiles.Mapping.key3
57-
let name = YAMLFiles.Scalar.value
56+
let dictionary = YAMLFiles.Mapping.foo
57+
let version = YAMLFiles.Version.value
5858
let documentItems = YAMLFiles.Documents.Document1.items

0 commit comments

Comments
 (0)