Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
mac-cain13 committed May 16, 2015
2 parents ec7a69c + c5aba8e commit 878d584
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
3 changes: 2 additions & 1 deletion R.swift/func.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ func sanitizedSwiftName(name: String, lowercaseFirstCharacter: Bool = true) -> S
var components = name.componentsSeparatedByString("-")
let firstComponent = components.removeAtIndex(0)
let swiftName = components.reduce(firstComponent) { $0 + $1.capitalizedString }
let capitalizedSwiftName = lowercaseFirstCharacter ? swiftName.lowercaseFirstCharacter : swiftName

return lowercaseFirstCharacter ? swiftName.lowercaseFirstCharacter : swiftName
return contains(SwiftKeywords, capitalizedSwiftName) ? "`\(capitalizedSwiftName)`" : capitalizedSwiftName
}

func writeResourceFile(code: String, toFolderURL folderURL: NSURL) {
Expand Down
14 changes: 12 additions & 2 deletions R.swift/types.swift
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,18 @@ struct AssetFolder {
init(url: NSURL, fileManager: NSFileManager) {
name = url.filename!

let contents = fileManager.contentsOfDirectoryAtURL(url, includingPropertiesForKeys: nil, options: NSDirectoryEnumerationOptions.SkipsHiddenFiles, error: nil) as! [NSURL]
imageAssets = contents.map { $0.filename! }
// Browse asset directory recursively and list only the assets folders
var assets = [NSURL]()
let enumerator = fileManager.enumeratorAtURL(url, includingPropertiesForKeys: nil, options: .SkipsHiddenFiles, errorHandler: nil)
if let enumerator = enumerator {
for file in enumerator {
if let fileURL = file as? NSURL, pathExtension = fileURL.pathExtension where find(AssetExtensions, pathExtension) != nil {
assets.append(fileURL)
}
}
}

imageAssets = assets.map { $0.filename! }
}
}

Expand Down
4 changes: 4 additions & 0 deletions R.swift/values.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ let Ordinals = [
(number: 20, word: "twentieth"),
]

let AssetExtensions = ["appiconset", "launchimage", "imageset"]

let ElementNameToTypeMapping = [
"viewController": Type._UIViewController,
"glkViewController": Type(name: "GLKViewController"),
Expand All @@ -54,3 +56,5 @@ let ElementNameToTypeMapping = [
"avPlayerViewController": Type(name: "AVPlayerViewController"),
"collectionViewController": Type(name: "UICollectionViewController"),
]

let SwiftKeywords = ["class", "deinit", "enum", "extension", "func", "import", "init", "internal", "let", "operator", "private", "protocol", "public", "static", "struct", "subscript", "typealias", "var", "break", "case", "continue", "default", "do", "else", "fallthrough", "for", "if", "in", "return", "switch", "where", "while", "as", "dynamicType", "false", "is", "nil", "self", "Self", "super", "true", "__COLUMN__", "__FILE__", "__FUNCTION__", "__LINE__"]

0 comments on commit 878d584

Please sign in to comment.