module WarpEngine::Platforms::Updatable
The base concern of every platform service. Including it gives the class the declarations below (label, required_kinds, …) and the update entry point; the Builds concerns register the asset kinds the platform produces and the steps that prepare them.
class Service include Updatable include Builds::BuildWeb include Builds::BuildWinX64 label "Phaser" required_kinds "html" end
Public Instance Methods
Source
# File app/services/concerns/warp_engine/platforms/updatable.rb, line 105 def update(name, version) versioned = "#{name}-#{version}" prepare_files(versioned) asset_paths = collect_asset_paths(versioned) missing = self.class.required_kinds - asset_paths.keys raise MissingAssetsError.new(versioned, missing) if missing.any? metadata = parse_metadata(versioned) site_url = metadata.delete(:site) repo_url = metadata.delete(:repo) ActiveRecord::Base.transaction do software = update_or_create_software(metadata.merge(platform: self.class.platform)) upsert_external_link(software.id, "Source Code", site_url) if site_url.present? upsert_external_link(software.id, "Repository", repo_url) if repo_url.present? release = create_release_if_not_exists(software_id: software.id, version: version) sync_release_assets(release, asset_paths) discard_unexpected_assets(release, self.class.expected_kinds) release end end
Publishes the upload name-version found in the file container: runs the prepare steps (unpacking zips), collects the asset of every expected kind, reads the metadata, then in one transaction creates or updates the WarpEngine::Software (with its “Source Code” and “Repository” external links from site and repo), creates the WarpEngine::Release if new, writes its WarpEngine::ReleaseAsset records and soft-deletes assets of kinds the platform no longer expects.
- name
-
the software name
- version
-
the version string
Returns the WarpEngine::Release. Raises MissingAssetsError when a required kind is missing, and ActiveRecord::RecordInvalid when a record does not save.