Skip to content

move TOML printing to toTOML methods. #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 9, 2015
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
8 changes: 7 additions & 1 deletion Sources/PackageDescription/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ public final class Package {
public class func Package(url url: String, _ version: Version) -> Dependency {
return Dependency(url, version...version)
}

/// Print a representation of the dependency as TOML.
public func toTOML() -> String {
return "[\"\(url)\", \"\(versionRange.startIndex)\", \"\(versionRange.endIndex)\"],"
}

}

/// The name of the package, if specified.
Expand Down Expand Up @@ -74,7 +80,7 @@ public final class Package {
}
result += "dependencies = ["
for dependency in dependencies {
result += "[\"\(dependency.url)\", \"\(dependency.versionRange.startIndex)\", \"\(dependency.versionRange.endIndex)\"],"
result += dependency.toTOML()
}
result += "]\n"
for target in targets {
Expand Down
13 changes: 9 additions & 4 deletions Sources/PackageDescription/Target.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ public final class Target {
public enum Dependency {
/// A dependency on a target in the same project.
case Target(name: String)

/// Print a representation of the target dependency as TOML.
public func toTOML() -> String {
switch self {
case .Target(let name):
return "\"\(name)\","
}
}
}

/// The name of the target.
Expand All @@ -35,10 +43,7 @@ public final class Target {
result += "name = \"\(name)\"\n"
result += "dependencies = ["
for dependency in dependencies {
switch dependency {
case .Target(let name):
result += "\"\(name)\","
}
result += dependency.toTOML()
}
result += "]\n"
return result
Expand Down