Top Level Namespace
Defined Under Namespace
Classes: API, AppError, CarthageArchive, CarthageDependency, CmdError, Configuration, DownloadCommand, Framework, FrameworkCarthageArchive, FrameworkValidationError, InitCommand, MissingFrameworkDirectoryError, MultipleErrorsError, Networking, OutdatedFrameworkBuildError, PlatformMismatchError, ServerCommand, ServerVersionMismatchError, ShellWrapper, Table, UploadCommand, VerifyCommand, VersionFile, VersionFileDoesNotExistError, XCFramework, XCFrameworkCarthageArchive
Constant Summary collapse
- VERSION =
"0.0.13"
- CARTHAGE_DIR =
"Carthage"
- CARTHAGE_BUILD_DIR =
File.join(CARTHAGE_DIR, "Build")
- CARTFILE_RESOLVED =
"Cartfile.resolved"
- CARTRCFILE =
"Cartrcfile"
- THREAD_POOL_SIZE =
8
- SERVER_DEFAULT_PORT =
9292
- SERVER_CACHE_DIR =
File.join(Dir.home, ".carthagerc_server")
- ARCHIVE_CHECKSUM_HEADER_REST_CLIENT =
:archive_checksum
- ARCHIVE_CHECKSUM_HEADER_SINATRA_IN =
"HTTP_ARCHIVE_CHECKSUM"
- ARCHIVE_CHECKSUM_HEADER_SINATRA_OUT =
"Archive-Checksum"
- PLATFORMS =
[:iOS, :macOS, :tvOS, :watchOS]
Instance Method Summary collapse
-
#bail(message, code = 1) ⇒ Object
Exits Ruby process, only to be called from top level ‘carthagerc` script.
- #crc32(filename) ⇒ Object
-
#format_file_size(bytes) ⇒ Object
String in “x.y MB” format.
- #platform_to_api_string(platform) ⇒ Object
- #platform_to_carthage_dir_string(platform) ⇒ Object
- #platform_to_symbols(string) ⇒ Object
-
#quote(input) ⇒ Object
Quote command line arguments with double quotes.
Instance Method Details
#bail(message, code = 1) ⇒ Object
Exits Ruby process, only to be called from top level ‘carthagerc` script
2 3 4 5 |
# File 'lib/utils.rb', line 2 def bail(, code = 1) $stderr.puts(.strip + "\n") Process.exit(code) end |
#crc32(filename) ⇒ Object
7 8 9 10 11 |
# File 'lib/utils.rb', line 7 def crc32(filename) checksum = Digest::CRC32.file(filename).hexdigest $LOG.debug("CRC32 checksum for '#{filename}': #{checksum}") checksum end |
#format_file_size(bytes) ⇒ Object
Returns string in “x.y MB” format.
73 74 75 76 77 78 79 80 |
# File 'lib/utils.rb', line 73 def format_file_size(bytes) if bytes == 0 "0.0 MB" else megabytes = [0.1, bytes / 1000.0 / 1000.0].max "#{megabytes.round(1)} MB" end end |
#platform_to_api_string(platform) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/utils.rb', line 32 def platform_to_api_string(platform) case platform when :iOS "iOS" when :macOS "macOS" when :tvOS "tvOS" when :watchOS "watchOS" else raise AppError.new, "Unrecognized platform #{platform.inspect}" end end |
#platform_to_carthage_dir_string(platform) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/utils.rb', line 47 def platform_to_carthage_dir_string(platform) case platform when :iOS "iOS" when :macOS "Mac" when :tvOS "tvOS" when :watchOS "watchOS" else raise AppError.new, "Unrecognized platform #{platform.inspect}" end end |
#platform_to_symbols(string) ⇒ Object
62 63 64 65 66 67 68 69 70 |
# File 'lib/utils.rb', line 62 def platform_to_symbols(string) platforms = string.split(",").map(&:to_sym) for platform in platforms if !PLATFORMS.include?(platform) raise PlatformMismatchError.new(platform) end end platforms end |
#quote(input) ⇒ Object
Quote command line arguments with double quotes. Useful for file paths with spaces.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/utils.rb', line 15 def quote(input) if input.is_a? String if input.empty? "" else '"' + input + '"' end elsif input.is_a? Array input .map { |e| quote(e) } .select { |e| !e.empty? } .join(" ") else raise AppError.new, "Unsupported type #{input}" end end |