Skip to content

Commit

Permalink
Merge pull request Carthage#572 from Carthage/collect-operator
Browse files Browse the repository at this point in the history
Put collect() operator in its place
  • Loading branch information
jspahrsummers committed Jun 18, 2015
2 parents 41e9384 + e8e2fae commit 69b8101
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Source/CarthageKit/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ public final class Project {

return loadCombinedCartfile()
|> flatMap(.Merge) { cartfile in resolver.resolveDependenciesInCartfile(cartfile) }
|> reduce([]) { $0 + [ $1 ] }
|> collect
|> map { ResolvedCartfile(dependencies: $0) }
}

Expand Down
4 changes: 2 additions & 2 deletions Source/CarthageKit/Resolver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public struct Resolver {
}

return self.versionsForDependency(dependency.project)
|> reduce([]) { $0 + [ $1 ] }
|> collect
|> flatMap(.Merge) { nodes -> SignalProducer<PinnedVersion, CarthageError> in
if nodes.isEmpty {
return SignalProducer(error: CarthageError.TaggedVersionNotFound(dependency.project))
Expand All @@ -95,7 +95,7 @@ public struct Resolver {
|> startOn(scheduler)
|> observeOn(scheduler)
|> map { DependencyNode(project: dependency.project, proposedVersion: $0, versionSpecifier: dependency.version) }
|> reduce([]) { $0 + [ $1 ] }
|> collect
|> map(sorted)
|> flatMap(.Concat) { nodes -> SignalProducer<DependencyNode, CarthageError> in
if nodes.isEmpty {
Expand Down
2 changes: 1 addition & 1 deletion Source/CarthageKit/Xcode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ private func mergeExecutables(executableURLs: [NSURL], outputURL: NSURL) -> Sign
return .failure(.ParseError(description: "expected file URL to built executable, got (URL)"))
}
}
|> reduce([]) { $0 + [ $1 ] }
|> collect
|> flatMap(.Merge) { executablePaths -> SignalProducer<TaskEvent<NSData>, CarthageError> in
let lipoTask = TaskDescription(launchPath: "/usr/bin/xcrun", arguments: [ "lipo", "-create" ] + executablePaths + [ "-output", outputURL.path! ])

Expand Down
2 changes: 1 addition & 1 deletion Source/CarthageKitTests/ArchiveSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class ArchiveSpec: QuickSpec {
let enumerationResult = NSFileManager.defaultManager().carthage_enumeratorAtURL(unzipResult?.value ?? temporaryURL, includingPropertiesForKeys: [], options: nil)
|> map { enumerator, URL in URL }
|> map { $0.lastPathComponent! }
|> reduce([]) { $0 + [ $1 ] }
|> collect
|> single

expect(enumerationResult).notTo(beNil())
Expand Down
6 changes: 2 additions & 4 deletions Source/CarthageKitTests/ResolverSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ class ResolverSpec: QuickSpec {

private func orderedDependencies(resolver: Resolver, fromCartfile cartfile: Cartfile) -> [[String: PinnedVersion]] {
let result = resolver.resolveDependenciesInCartfile(cartfile)
|> reduce([]) { (var dependencies, dependency) -> [[String: PinnedVersion]] in
dependencies.append([ dependency.project.name: dependency.version ])
return dependencies
}
|> map { [ $0.project.name: $0.version ] }
|> collect
|> first

expect(result).notTo(beNil())
Expand Down
4 changes: 2 additions & 2 deletions Source/CarthageKitTests/XcodeSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class XcodeSpec: QuickSpec {
// Verify that the iOS framework is a universal binary for device
// and simulator.
let architectures = architecturesInFramework(frameworkFolderURL)
|> reduce([]) { $0 + [ $1 ] }
|> collect
|> single

expect(architectures?.value).to(contain("i386"))
Expand All @@ -108,7 +108,7 @@ class XcodeSpec: QuickSpec {
expect(strippingResult.value).notTo(beNil())

let strippedArchitectures = architecturesInFramework(targetURL)
|> reduce([]) { $0 + [ $1 ] }
|> collect
|> single

expect(strippedArchitectures?.value).notTo(contain("i386"))
Expand Down
2 changes: 1 addition & 1 deletion Source/carthage/Archive.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public struct ArchiveCommand: CommandType {
|> on(next: { path in
carthage.println(formatting.bullets + "Found " + formatting.path(string: path))
})
|> reduce([]) { $0 + [ $1 ] }
|> collect
|> flatMap(.Merge) { paths -> SignalProducer<(), CarthageError> in
if paths.isEmpty {
return SignalProducer(error: CarthageError.InvalidArgument(description: "Could not find any copies of \(options.frameworkName).framework. Make sure you're in the project’s root and that the framework has already been built using 'carthage build --no-skip-current'."))
Expand Down

0 comments on commit 69b8101

Please sign in to comment.