Class: Appship::PgyerUploader

Inherits:
Object
  • Object
show all
Defined in:
lib/appship/uploader.rb

Constant Summary collapse

PGYER_HOST =
"www.pgyer.com"

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ PgyerUploader

Returns a new instance of PgyerUploader.

Raises:



25
26
27
28
29
# File 'lib/appship/uploader.rb', line 25

def initialize(options = {})
  @options = options
  @api_key = options[:api_key] || ENV[options[:api_key_env] || "PGYER_API_KEY"]
  raise ConfigurationError, "缺少蒲公英 API Key,请使用 --api-key 或 PGYER_API_KEY" if @api_key.to_s.empty?
end

Instance Method Details

#upload!(file) ⇒ Object

Raises:



31
32
33
34
35
36
37
38
39
40
# File 'lib/appship/uploader.rb', line 31

def upload!(file)
  raise ConfigurationError, "IPA/APK 文件不存在: #{file}" unless File.file?(file)

  puts "☁️ 获取蒲公英上传凭证..."
  token = request_token(file)
  puts "☁️ 上传 #{File.basename(file)}#{format_size(File.size(file))})..."
  upload_to_cos!(file, token)
  puts "☁️ 等待蒲公英处理..."
  poll_build_info!(token.fetch(:build_key))
end