Module: FIR::Publish
- Included in:
- Util::ClassMethods
- Defined in:
- lib/fir/util/publish.rb
Instance Method Summary collapse
- #convert_icon(origin_path) ⇒ Object
- #fetch_uploading_info ⇒ Object
- #initialize_publish_options(args, options) ⇒ Object
- #publish(*args, options) ⇒ Object
- #read_changelog(changelog) ⇒ Object
- #upload_app ⇒ Object
- #upload_app_binary ⇒ Object
- #upload_app_icon ⇒ Object
- #uploading_binary_info ⇒ Object
- #uploading_icon_info ⇒ Object
Instance Method Details
#convert_icon(origin_path) ⇒ Object
101 102 103 104 105 106 107 108 109 |
# File 'lib/fir/util/publish.rb', line 101 def convert_icon origin_path logger.info "Converting app's icon......" if @app_info[:type] == 'ios' output_path = Tempfile.new(['uncrushed_icon', '.png']).path FIR::Parser::Pngcrush.uncrush_icon(origin_path, output_path) origin_path = output_path if File.size(output_path) != 0 end origin_path end |
#fetch_uploading_info ⇒ Object
92 93 94 95 96 97 98 99 |
# File 'lib/fir/util/publish.rb', line 92 def fetch_uploading_info logger.info "Fetching #{@app_info[:identifier]}@onemt uploading info......" logger.info "Uploading app: #{@app_info[:name]}-#{@app_info[:version]}(Build #{@app_info[:build]})" post fir_api[:app_my_version], type: @app_info[:type], bundle_id: @app_info[:identifier], api_token: @token end |
#initialize_publish_options(args, options) ⇒ Object
76 77 78 79 80 81 82 83 84 85 |
# File 'lib/fir/util/publish.rb', line 76 def (args, ) @file_path = File.absolute_path(args.first.to_s) @file_type = File.extname(@file_path).delete('.') @token = [:token] || current_token @changelog = read_changelog([:changelog]).to_s.to_utf8 @short = [:short].to_s @passwd = [:password].to_s @is_opened = [:open] ? true : false @export_qrcode = !![:qrcode] end |
#publish(*args, options) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/fir/util/publish.rb', line 5 def publish(*args, ) (args, ) @app_info = send("#{@file_type}_info", @file_path, full_info: true) @change_log = [:changelog] @uploading_info = fetch_uploading_info upload_app end |
#read_changelog(changelog) ⇒ Object
87 88 89 90 |
# File 'lib/fir/util/publish.rb', line 87 def read_changelog(changelog) return if changelog.blank? File.exist?(changelog) ? File.read(changelog) : changelog end |
#upload_app ⇒ Object
13 14 15 16 |
# File 'lib/fir/util/publish.rb', line 13 def upload_app upload_app_icon unless @app_info[:icons].blank? upload_app_binary end |
#upload_app_binary ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/fir/util/publish.rb', line 47 def upload_app_binary logger.info 'Uploading app binary......' print uploading_binary_info uploaded_info = post(fir_api[:app_my_url], uploading_binary_info) return if uploaded_info[:is_completed] logger.error 'Upload app binary failed' logger.error uploaded_info[:msg] exit 1 end |
#upload_app_icon ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/fir/util/publish.rb', line 18 def upload_app_icon logger.info 'Uploading app icon......' uploaded_info = post(fir_api[:app_my_url], uploading_icon_info) return if uploaded_info[:is_completed] logger.error 'Upload app icon failed' logger.error uploaded_info[:msg] exit 1 end |
#uploading_binary_info ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/fir/util/publish.rb', line 57 def uploading_binary_info { id:@uploading_info[:id], token: @token, info: @change_log, short: @short, show: @is_opened, file: File.new(@file_path, 'rb'), # Custom variables 'type' => @app_info[:type], 'identifier' => @app_info[:identifier], 'name' => @app_info[:display_name] || @app_info[:name], 'build' => @app_info[:build], 'version' => @app_info[:version], 'release_type' => @app_info[:release_type], 'distribution_name' => @app_info[:distribution_name] } end |
#uploading_icon_info ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/fir/util/publish.rb', line 29 def uploading_icon_info large_icon_path = @app_info[:icons].max_by { |f| File.size(f) } uncrushed_icon_path = convert_icon(large_icon_path) { id:@uploading_info[:id], token: @token, file: File.new(uncrushed_icon_path, 'rb'), # Custom variables 'type' => @app_info[:type], 'identifier' => @app_info[:identifier], 'name' => @app_info[:display_name] || @app_info[:name], 'build' => @app_info[:build], 'version' => @app_info[:version], 'release_type' => @app_info[:release_type], 'distribution_name' => @app_info[:distribution_name] } end |