Sha256: 80d4fcb37bfe5e536755914b5060b97b14aa2786ea8462d4857d11d4b6f77834

Contents?: true

Size: 1.35 KB

Versions: 24

Compression:

Stored size: 1.35 KB

Contents

# ********** Copyright Viacom, Inc. Apache 2.0 **********

module RokuBuilder

  # Method of packaging app for submission
  class Packager < Util

    # Sign and download the currently sideloaded app
    # @param app_name_version [String] The name and version of the package
    # @param out_file [String] Location to download signed package to
    # @param password [String] Password for the devices current key
    # @return [Boolean] True on package success and download, false otherwise
    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
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
roku_builder-3.11.0 lib/roku_builder/packager.rb
roku_builder-3.10.7 lib/roku_builder/packager.rb
roku_builder-3.10.6 lib/roku_builder/packager.rb
roku_builder-3.10.5 lib/roku_builder/packager.rb
roku_builder-3.10.4 lib/roku_builder/packager.rb
roku_builder-3.10.3 lib/roku_builder/packager.rb
roku_builder-3.10.2 lib/roku_builder/packager.rb
roku_builder-3.10.1 lib/roku_builder/packager.rb
roku_builder-3.10.0 lib/roku_builder/packager.rb
roku_builder-3.9.0 lib/roku_builder/packager.rb
roku_builder-3.8.5 lib/roku_builder/packager.rb
roku_builder-3.8.4 lib/roku_builder/packager.rb
roku_builder-3.8.3 lib/roku_builder/packager.rb
roku_builder-3.8.2 lib/roku_builder/packager.rb
roku_builder-3.8.1 lib/roku_builder/packager.rb
roku_builder-3.8.0 lib/roku_builder/packager.rb
roku_builder-3.7.3 lib/roku_builder/packager.rb
roku_builder-3.7.2 lib/roku_builder/packager.rb
roku_builder-3.7.1 lib/roku_builder/packager.rb
roku_builder-3.7.0 lib/roku_builder/packager.rb