Class: Pindo::Command::Pgyer::Download
- Inherits:
-
Pindo::Command::Pgyer
- Object
- CLAide::Command
- Pindo::Command
- Pindo::Command::Pgyer
- Pindo::Command::Pgyer::Download
- Defined in:
- lib/pindo/command/pgyer/download.rb
Constant Summary
Constants inherited from Pindo::Command
DEFAULT_OPTIONS, DEFAULT_ROOT_OPTIONS
Instance Attribute Summary
Attributes inherited from Pindo::Command
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv) ⇒ Download
constructor
A new instance of Download.
- #run ⇒ Object
- #validate! ⇒ Object
Methods inherited from Pindo::Command
Methods included from Funlog::Mixin
Methods included from Pindoconfig::Mixin
Methods included from Githelper
#add_branch, #add_tag, #add_tag_with_check, #clone_clang_repo, #clone_devclang_repo, #clone_pindo_common_config_repo, #clone_pindo_env_config_repo, #clong_buildconfig_repo, #get_repo_base_name, #getcode_to_dir, #git_addpush_repo, #git_latest_commit_id, #local_branch_exists?, #local_tag_exists?, #prepare_gitenv, #process_need_add_files, #remote_branch_exists?, #remote_tag_exists?, #remove_branch, #remove_tag
Methods included from Executable
capture_command, #executable, execute_command, which, which!
Constructor Details
#initialize(argv) ⇒ Download
Returns a new instance of Download.
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/pindo/command/pgyer/download.rb', line 34 def initialize(argv) @args_login_flag = argv.flag?('login', false) @args_list_flag = argv.flag?('list', false) @args_proj_name = argv.option('proj') @app_version_index = argv.option('index') || nil super(argv) @additional_args = argv.remainder! end |
Class Method Details
.options ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/pindo/command/pgyer/download.rb', line 25 def self. [ ['--login', '强制再次登录pgyer网站'], ['--list', '列出上传记录并选择,用法:pindo pgyer download --list'], ['--proj', '指定哪个项目(忽略大小写空格等等字符),用法:pindo pgyer download --proj=prancksoundv4'], ].concat(super) end |
Instance Method Details
#run ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/pindo/command/pgyer/download.rb', line 50 def run PgyerHelper.share_instace.setForeLogin(beforeLogin:@args_login_flag) app_info_obj = PgyerHelper.share_instace.prepare_upload(working_directory:Dir.pwd, proj_name:@args_proj_name) if app_info_obj.nil? raise Informative, "#{proj_name} 错误, 请输入正确的App代号名称, pgyer网站没有该App" end version_item_obj = PgyerHelper.share_instace.get_versioon_history_item(app_info_obj:app_info_obj, list_select_flat:@args_list_flag) if version_item_obj.nil? raise Informative, "没有找到上传记录" end download_url = version_item_obj["cdnUrl"] base_name = [app_info_obj["appName"], version_item_obj["appVersion"], version_item_obj["incId"]].join("_") base_name = base_name + File.extname(download_url) # key_proj_name = proj_name.downcase.strip.gsub(/[\s\-_]/, '') base_name = base_name.strip.gsub(/[\s]/, '').downcase file_name = File.join(Dir.pwd, base_name) puts "文件名: #{file_name}" puts "下载中..." # File.binwrite(file_name, FastlaneCore::Helper.open_uri(download_url).read) # 使用选项参数 Funlog.instance.("开始下载...") total_num = 0 total_size = '' char_in = '>' char_out = '_' = '' URI.open(download_url, :content_length_proc => lambda { |total| total_num = total total_size = sprintf("%.2f", 1.00 * total_num / 1024 /1024 ) }, :progress_proc => lambda { |index_num| progress_str = sprintf("%.2f", 100.0 * index_num / total_num ) total_size = sprintf("%.2f", 1.00 * total_num / 1024 /1024 ) index = 40.0 * index_num / total_num = "已下载:#{progress_str}\%【" + (char_in * (index/1).floor).ljust(40.0, char_out) + "】Total: #{total_size} M" Funlog.instance.() }) do |file| File.binwrite(file_name, file.read) end Funlog.instance.() Funlog.instance.("#{file_name} 下载完成!") end |
#validate! ⇒ Object
45 46 47 48 |
# File 'lib/pindo/command/pgyer/download.rb', line 45 def validate! super end |