Skip to content
This repository has been archived by the owner on Sep 6, 2018. It is now read-only.

Remove deprecated variables #35

Merged
merged 6 commits into from
May 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ _None_

### Breaking Changes

_None_
* Removed deprecated variables. See [SwiftGenKit#5](https://github.com/SwiftGen/SwiftGenKit/issues/5) for more information.
[David Jennes](https://github.com/djbe)
[#35](https://github.com/SwiftGen/templates/issues/35)

### New Features

Expand Down
27 changes: 3 additions & 24 deletions Sources/Stencil/AssetsCatalogContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,39 +19,18 @@ import Foundation
*/
extension AssetsCatalogParser {
public func stencilContext(enumName: String = "Asset") -> [String: Any] {
let images = catalogs.flatMap { justValues(entries: $1) }.sorted(by: <)
let structured = catalogs.keys.sorted(by: <).map { name -> [String: Any] in
let catalogs = self.catalogs.keys.sorted(by: <).map { name -> [String: Any] in
return [
"name": name,
"assets": structure(entries: catalogs[name] ?? [])
"assets": structure(entries: self.catalogs[name] ?? [])
]
}

return [
"catalogs": structured,

// NOTE: This is a deprecated variable
"enumName": enumName,
"images": images,
"param": ["enumName": enumName]
"catalogs": catalogs
]
}

private func justValues(entries: [Entry]) -> [String] {
var result = [String]()

for entry in entries {
switch entry {
case let .group(name: _, items: items):
result += justValues(entries: items)
case let .image(name: _, value: value):
result += [value]
}
}

return result
}

private func structure(entries: [Entry]) -> [[String: Any]] {
return entries.map { entry in
switch entry {
Expand Down
12 changes: 2 additions & 10 deletions Sources/Stencil/ColorsContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,12 @@ extension ColorsFileParser {
"red": comps[0],
"green": comps[1],
"blue": comps[2],
"alpha": comps[3],

// NOTE: This is a deprecated variable
"rgba": String(hexChars[0..<8]),
"rgb": String(hexChars[0..<6])
"alpha": comps[3]
]
}).sorted { $0["name"] ?? "" < $1["name"] ?? "" }

return [
"colors": colorMap,

// NOTE: This is a deprecated variable
"enumName": enumName,
"param": ["enumName": enumName]
"colors": colorMap
]
}
}
13 changes: 3 additions & 10 deletions Sources/Stencil/FontsContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,9 @@ extension FontsFileParser {
return [
"name": font.postScriptName,
"path": font.filePath,
"style": font.style,

// NOTE: This is a deprecated variable
"fontName": font.postScriptName
"style": font.style
]
}.sorted { $0["fontName"] ?? "" < $1["fontName"] ?? "" }
}.sorted { $0["name"] ?? "" < $1["name"] ?? "" }
// Family
return [
"name": name,
Expand All @@ -38,11 +35,7 @@ extension FontsFileParser {
}.sorted { $0["name"] as? String ?? "" < $1["name"] as? String ?? "" }

return [
"families": families,

// NOTE: This is a deprecated variable
"enumName": enumName,
"param": ["enumName": enumName]
"families": families
]
}
}
21 changes: 3 additions & 18 deletions Sources/Stencil/StoryboardsContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,7 @@ extension StoryboardParser {
}
return [
"modules": modules.sorted(),
"storyboards": storyboardsMap,

// NOTE: This is a deprecated variable
"extraImports": modules.sorted(),
"param": [
"sceneEnumName": sceneEnumName,
"segueEnumName": segueEnumName
],
"sceneEnumName": sceneEnumName,
"segueEnumName": segueEnumName
"storyboards": storyboardsMap
]
}

Expand All @@ -80,10 +71,7 @@ extension StoryboardParser {
]
} else {
return [
"baseType": uppercaseFirst(scene.tag),

// NOTE: This is a deprecated variable
"isBaseViewController": scene.tag == "viewController"
"baseType": uppercaseFirst(scene.tag)
]
}
}
Expand All @@ -98,10 +86,7 @@ extension StoryboardParser {
} else if scene.tag == "viewController" {
return [
"identifier": scene.storyboardID,
"baseType": uppercaseFirst(scene.tag),

// NOTE: This is a deprecated variable
"isBaseViewController": scene.tag == "viewController"
"baseType": uppercaseFirst(scene.tag)
]
} else {
return [
Expand Down
33 changes: 3 additions & 30 deletions Sources/Stencil/StringsContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,38 +32,21 @@ extension StringsFileParser {
public func stencilContext(enumName: String = "L10n", tableName: String = "Localizable") -> [String: Any] {

let entryToStringMapper = { (entry: Entry, keyPath: [String]) -> [String: Any] in
var keyStructure = entry.keyStructure
Array(0..<keyPath.count).forEach { _ in keyStructure.removeFirst() }
let levelName = keyStructure.joined(separator: ".")
let levelName = entry.keyStructure.last ?? ""

var result: [String: Any] = [
"name": levelName,
"key": entry.key.newlineEscaped,
"translation": entry.translation.newlineEscaped,

// NOTE: keytail is deprecated
"keytail": levelName
"translation": entry.translation.newlineEscaped
]

if entry.types.count > 0 {
result["types"] = entry.types.map { $0.rawValue }

// NOTE: params is deprecated
result["params"] = [
"types": entry.types.map { $0.rawValue },
"count": entry.types.count,
"declarations": entry.types.indices.map { "let p\($0)" },
"names": entry.types.indices.map { "p\($0)" },
"typednames": entry.types.enumerated().map { "p\($0): \($1.rawValue)" }
]
}

return result
}

let strings = entries
.sorted { $0.key.caseInsensitiveCompare($1.key) == .orderedAscending }
.map { entryToStringMapper($0, []) }
let structuredStrings = structure(
entries: entries,
usingMapper: entryToStringMapper
Expand All @@ -74,14 +57,7 @@ extension StringsFileParser {
]]

return [
"tables": tables,

// NOTE: These are deprecated variables
"enumName": enumName,
"param": ["enumName": enumName],
"strings": strings,
"structuredStrings": structuredStrings,
"tableName": tableName
"tables": tables
]
}

Expand Down Expand Up @@ -139,9 +115,6 @@ extension StringsFileParser {

if !children.isEmpty {
structuredStrings["children"] = children

// NOTE: These are deprecated variables
structuredStrings["subenums"] = children
}

return structuredStrings
Expand Down
2 changes: 1 addition & 1 deletion Tests/Resources
Submodule Resources updated 133 files