Class: Yolo::Deployment::OTA
- Inherits:
-
BaseDeployer
- Object
- BaseDeployer
- Yolo::Deployment::OTA
- Defined in:
- lib/yolo/deployment/ota.rb
Overview
Deploys IPA’s using ustwo’s OTA
Instance Attribute Summary
Attributes inherited from BaseDeployer
Instance Method Summary collapse
-
#deploy(package_path, opts = {}, &block) ⇒ Object
Overides the super deploy method.
-
#initialize ⇒ OTA
constructor
Creates a new OTA instance.
-
#package ⇒ String
Creates a json package for the OTA uploader params.
-
#upload ⇒ Object
Uploades the package using CURL.
-
#upload_complete(response) ⇒ Object
Method called when the upload is complete, parses the json response form OTA which contains the package url and password.
Constructor Details
#initialize ⇒ OTA
Creates a new OTA instance
17 18 19 20 21 |
# File 'lib/yolo/deployment/ota.rb', line 17 def initialize @error_formatter = Yolo::Formatters::ErrorFormatter.new @progress_formatter = Yolo::Formatters::ProgressFormatter.new super end |
Instance Method Details
#deploy(package_path, opts = {}, &block) ⇒ Object
Overides the super deploy method
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/yolo/deployment/ota.rb', line 30 def deploy(package_path, opts={}, &block) self.package_path = package_path @complete_block = block unless self.url @error_formatter.no_deploy_url return end @progress_formatter.(self.package_path) upload end |
#package ⇒ String
Creates a json package for the OTA uploader params
48 49 50 51 |
# File 'lib/yolo/deployment/ota.rb', line 48 def package filename = self.package_path.split("/").last "{\"fileName\": \"#{filename}\", \"password\": \"\", \"validUntil\": \"2000000000\"}" end |
#upload ⇒ Object
Uploades the package using CURL
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/yolo/deployment/ota.rb', line 56 def upload response = "" IO.popen("curl #{self.url} -X POST -# -F fileContent=@\"#{self.package_path}\" -F params='#{package}'") do |io| begin while line = io.readline response << line end if response.length == 0 @error_formatter.deploy_failed("Upload error") end rescue EOFError end end upload_complete(response) if response.length > 0 end |
#upload_complete(response) ⇒ Object
Method called when the upload is complete, parses the json response form OTA which contains the package url and password
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/yolo/deployment/ota.rb', line 76 def upload_complete(response) json = nil begin json = JSON.parse(response) rescue JSON::ParserError @error_formatter.deploy_failed("\n ParserError: Deployment server response is not JSON") return end unless json @error_formatter.deploy_failed("\n ParserError: Deployment server response is not JSON") return end url = json["link"] password = json["password"] @complete_block.call(url,password) @progress_formatter.deploy_complete(url,password) end |