-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
94 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import Foundation | ||
import PathKit | ||
|
||
public enum RubyError: LocalizedError { | ||
case missingRuby | ||
|
||
public var errorDescription: String? { | ||
switch self { | ||
case .missingRuby: | ||
return "A Ruby installation that is not provided by the system is required to use CocoaPods dependencies. Please install Ruby via rbenv, rvm, or Homebrew." | ||
} | ||
} | ||
} | ||
|
||
struct Ruby { | ||
|
||
private let rubyPath: Path | ||
private let gemPath: Path | ||
|
||
init() throws { | ||
do { | ||
rubyPath = try which("ruby") | ||
gemPath = try which("gem") | ||
} catch ShellError.commandNotFound { | ||
throw RubyError.missingRuby | ||
} | ||
} | ||
|
||
func installGem(_ gem: String) throws { | ||
try sh(gemPath, "install", gem) | ||
.logOutput() | ||
.waitUntilExit() | ||
} | ||
|
||
func commandExists(_ command: String) -> Bool { | ||
return (try? which(command)) != nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters