Class: RokuBuilder::Packager
Overview
Method of packaging app for submission
Instance Method Summary collapse
-
#package(app_name_version:, out_file:, password:) ⇒ Boolean
Sign and download the currently sideloaded app.
Methods inherited from Util
#init, #initialize, #multipart_connection, options_parse, #simple_connection
Constructor Details
This class inherits a constructor from RokuBuilder::Util
Instance Method Details
#package(app_name_version:, out_file:, password:) ⇒ Boolean
Sign and download the currently sideloaded app
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/roku_builder/packager.rb', line 13 def package(app_name_version:, out_file:, password:) # Sign package path = "/plugin_package" conn = multipart_connection payload = { mysubmit: "Package", app_name: app_name_version, passwd: password, pkg_time: Time.now.to_i } response = conn.post path, payload # Check for error failed = /(Failed: [^\.]*\.)/.match(response.body) return failed[1] if failed # Download signed package pkg = /<a href="pkgs[^>]*>([^<]*)</.match(response.body)[1] path = "/pkgs/#{pkg}" conn = Faraday.new(url: @url) do |f| f.request :digest, @dev_username, @dev_password f.adapter Faraday.default_adapter end response = conn.get path return false if response.status != 200 File.open(out_file, 'w+') {|fp| fp.write(response.body)} true end |