class Object
Constants
- ARCHIVE_CHECKSUM_HEADER_REST_CLIENT
- ARCHIVE_CHECKSUM_HEADER_SINATRA_IN
- ARCHIVE_CHECKSUM_HEADER_SINATRA_OUT
- CARTFILE_RESOLVED
- CARTHAGE_BUILD_DIR
- CARTHAGE_DIR
- CARTRCFILE
- PLATFORMS
- SERVER_CACHE_DIR
- SERVER_DEFAULT_PORT
- THREAD_POOL_SIZE
- VERSION
Public Instance Methods
bail(message, code = 1)
click to toggle source
Exits Ruby process, only to be called from top level `carthagerc` script
# File lib/utils.rb, line 2 def bail(message, code = 1) $stderr.puts(message.strip + "\n") Process.exit(code) end
crc32(filename)
click to toggle source
# 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)
click to toggle source
@return string in “x.y MB” format
# File lib/utils.rb, line 73 def format_file_size(bytes) megabytes = bytes / 1000.0 / 1000.0 "#{megabytes.round(1)} MB" end
params_to_framework_dir(params)
click to toggle source
# File lib/server/server_app.rb, line 109 def params_to_framework_dir(params) File.join(SERVER_CACHE_DIR, params[:xcodebuild_version], params[:swift_version], params[:dependency_name], params[:version]) end
platform_to_api_string(platform)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
Quote command line arguments with double quotes. Useful for file paths with spaces.
# 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