Class: API
- Inherits:
-
Object
- Object
- API
- Defined in:
- lib/api.rb
Instance Method Summary collapse
-
#create_and_upload_archive(carthage_dependency, framework, platform) ⇒ Object
Zip archive size in Bytes.
-
#download_and_unpack_archive(carthage_dependency, framework, platform) ⇒ Object
Zip archive size in Bytes.
-
#initialize(shell, config, networking, options) ⇒ API
constructor
A new instance of API.
- #verify_build_dir_matches_cartfile_resolved ⇒ Object
- #verify_server_version ⇒ Object
- #version_file_matches_server?(carthage_dependency, version_file, platforms) ⇒ Boolean
Constructor Details
#initialize(shell, config, networking, options) ⇒ API
Returns a new instance of API.
2 3 4 5 6 7 8 |
# File 'lib/api.rb', line 2 def initialize(shell, config, networking, ) @shell = shell @config = config @networking = networking @options = @unpack_mutex = Mutex.new end |
Instance Method Details
#create_and_upload_archive(carthage_dependency, framework, platform) ⇒ Object
Returns zip archive size in Bytes.
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/api.rb', line 50 def create_and_upload_archive(carthage_dependency, framework, platform) archive = framework.make_archive(platform) archive.compress_archive(@shell) archive_size = archive.archive_size begin checksum = crc32(archive.archive_path) @networking.upload_framework_archive(archive.archive_path, carthage_dependency, framework.name, platform, checksum) ensure archive.delete_archive end archive_size end |
#download_and_unpack_archive(carthage_dependency, framework, platform) ⇒ Object
Returns zip archive size in Bytes.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/api.rb', line 65 def download_and_unpack_archive(carthage_dependency, framework, platform) result = @networking.download_framework_archive(carthage_dependency, framework, platform) if result.nil? raise AppError.new, "Failed to download framework #{carthage_dependency} – #{framework.name} (#{platform}). Please `upload` the framework first." end archive = result[:archive] remote_checksum = result[:checksum] local_checksum = crc32(archive.archive_path) if local_checksum != remote_checksum raise AppError.new, (archive.archive_path, remote_checksum, local_checksum) end archive_size = archive.archive_size begin $LOG.debug("Downloaded #{archive.archive_path}") # Can't unpack multiple archives concurrently. @unpack_mutex.synchronize do archive.unpack_archive(@shell) end ensure archive.delete_archive end archive_size end |
#verify_build_dir_matches_cartfile_resolved ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/api.rb', line 17 def verify_build_dir_matches_cartfile_resolved errors = [] for carthage_dependency in @config.carthage_resolved_dependencies begin version_file = carthage_dependency.new_version_file carthage_dependency.verify_version_in_version_file(version_file) rescue VersionFileDoesNotExistError => e errors << OutdatedFrameworkBuildError.new( carthage_dependency.guessed_framework_basename, "-", carthage_dependency.version ) rescue OutdatedFrameworkBuildError => e errors << e end end if errors.count > 0 raise FrameworkValidationError.new(errors) end end |
#verify_server_version ⇒ Object
10 11 12 13 14 15 |
# File 'lib/api.rb', line 10 def verify_server_version server_version = @networking.get_server_version unless server_version == VERSION raise ServerVersionMismatchError.new, (server_version) end end |
#version_file_matches_server?(carthage_dependency, version_file, platforms) ⇒ Boolean
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/api.rb', line 38 def version_file_matches_server?(carthage_dependency, version_file, platforms) if @options[:force] false else server_version_file = @networking.download_version_file(carthage_dependency, platforms) result = version_file.same_content?(server_version_file) server_version_file.remove unless server_version_file.nil? result end end |