Skip to content

Commit

Permalink
Add public initializers to KeyPath
Browse files Browse the repository at this point in the history
  • Loading branch information
ikesyo committed Jun 5, 2015
1 parent 3886fcc commit da6ee25
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Himotoki.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "Himotoki"
s.version = "0.4"
s.version = "0.4.1"
s.summary = "A type-safe JSON decoding library purely written in Swift"
s.description = <<-DESC
Himotoki (紐解き) is a type-safe JSON decoding library purely written in Swift. This library is highly inspired by popular JSON parsing libraries in Swift: [Argo](https://github.com/thoughtbot/Argo) and [ObjectMapper](https://github.com/Hearst-DD/ObjectMapper).
Expand Down
2 changes: 1 addition & 1 deletion Himotoki/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.4</string>
<string>0.4.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
16 changes: 12 additions & 4 deletions Himotoki/KeyPath.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,37 @@

public struct KeyPath {
public let components: [String]

public init(_ key: String) {
self.init([key])
}

public init(_ components: [String]) {
self.components = components
}
}

extension KeyPath: StringLiteralConvertible {
public typealias UnicodeScalarLiteralType = StringLiteralType
public typealias ExtendedGraphemeClusterLiteralType = StringLiteralType

public init(unicodeScalarLiteral value: UnicodeScalarLiteralType) {
components = [value]
self.init(value)
}

public init(extendedGraphemeClusterLiteral value: ExtendedGraphemeClusterLiteralType) {
components = [value]
self.init(value)
}

public init(stringLiteral value: StringLiteralType) {
components = [value]
self.init(value)
}
}

extension KeyPath: ArrayLiteralConvertible {
public typealias Element = String

public init(arrayLiteral elements: String...) {
components = elements
self.init(elements)
}
}
2 changes: 1 addition & 1 deletion HimotokiTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>0.4</string>
<string>0.4.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down

0 comments on commit da6ee25

Please sign in to comment.