Class: API
- Inherits:
-
Object
- Object
- API
- Defined in:
- lib/api.rb
Instance Method Summary collapse
-
#create_and_upload_archive(carthage_dependency, framework_name, platform) ⇒ Object
Zip archive size in Bytes.
-
#download_and_unpack_archive(carthage_dependency, framework_name, platform) ⇒ Object
Zip archive size in Bytes.
-
#initialize(shell, networking, options) ⇒ API
constructor
A new instance of API.
- #version_file_matches_server?(carthage_dependency, version_file) ⇒ Boolean
Constructor Details
#initialize(shell, networking, options) ⇒ API
Returns a new instance of API.
2 3 4 5 6 |
# File 'lib/api.rb', line 2 def initialize(shell, networking, ) @shell = shell @networking = networking @options = end |
Instance Method Details
#create_and_upload_archive(carthage_dependency, framework_name, platform) ⇒ Object
Returns zip archive size in Bytes.
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/api.rb', line 20 def create_and_upload_archive(carthage_dependency, framework_name, platform) archive = CarthageArchive.new(framework_name, platform) archive.create_archive(@shell, carthage_dependency.should_include_dsym) 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_name, platform) ⇒ Object
Returns zip archive size in Bytes.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/api.rb', line 35 def download_and_unpack_archive(carthage_dependency, framework_name, platform) result = @networking.download_framework_archive(carthage_dependency, framework_name, 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}") archive.unpack_archive(@shell) ensure archive.delete_archive end archive_size end |
#version_file_matches_server?(carthage_dependency, version_file) ⇒ Boolean
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/api.rb', line 8 def version_file_matches_server?(carthage_dependency, version_file) if @options[:force] false else server_version_file = @networking.download_version_file(carthage_dependency) result = version_file.same_content?(server_version_file) server_version_file.remove unless server_version_file.nil? result end end |