Class: Pod::Command::Bin::Local::Upload

Inherits:
Pod::Command::Bin::Local show all
Defined in:
lib/cocoapods-lhj-bin/command/bin/local/upload.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Pod::Command::Bin::Local

#backup_csv_file, #bak_file, #copy_hk_to_cn_file, #down_load_csv_file, #download_cvs_str, #en_dir_name, #find_key_by_cn_val, #format_str, #gen_zh_cn_strings_file, #generate_file, #generate_file_name, #get_download_keys, #handle_modify_file, #handle_modify_line, #handle_modify_source, #modify_file_string, #modify_format_string, #need_download, #read_csv, #read_csv_file, #read_csv_file_name, #write_en_strings, #write_to_file, #write_zh_cn_strings, #write_zh_hk_strings, #zh_ch_reg, #zh_cn_dir_name, #zh_hk_dir_name

Methods inherited from Pod::Command::Bin

#validate!

Methods included from CBin::SpecFilesHelper

#binary_spec, #binary_spec_files, #binary_template_spec, #binary_template_spec_file, #binary_template_spec_files, #clear_binary_spec_file_if_needed, #code_spec, #code_spec_files, #create_binary_spec_file, #find_spec_file, #spec_files

Methods included from CBin::SourcesHelper

#binary_source, #code_source, #sources_manager, #sources_option, #valid_sources

Constructor Details

#initialize(argv) ⇒ Upload

Returns a new instance of Upload.


16
17
18
19
20
# File 'lib/cocoapods-lhj-bin/command/bin/local/upload.rb', line 16

def initialize(argv)
  @pwd_path = argv.shift_argument || Dir.pwd
  @upload_csv_file = argv.option('upload-file', '*.csv')
  super
end

Class Method Details

.optionsObject


10
11
12
13
14
# File 'lib/cocoapods-lhj-bin/command/bin/local/upload.rb', line 10

def self.options
  [
    %w[--upload-file 上传中英文对照csv文件名]
  ]
end

Instance Method Details

#csv_file_nameObject


22
23
24
25
26
# File 'lib/cocoapods-lhj-bin/command/bin/local/upload.rb', line 22

def csv_file_name
  file_name = @upload_csv_file
  file_name = "#{@upload_csv_file}.csv" unless /.csv$/ =~ @upload_csv_file
  file_name
end

#csv_oss_key(file_name) ⇒ Object


28
29
30
# File 'lib/cocoapods-lhj-bin/command/bin/local/upload.rb', line 28

def csv_oss_key(file_name)
  "csv/#{Time.now.to_i}/#{file_name}"
end

#runObject


32
33
34
35
36
37
38
39
40
41
# File 'lib/cocoapods-lhj-bin/command/bin/local/upload.rb', line 32

def run
  csv_files = File.join(@pwd_path, '**', csv_file_name)
  Dir.glob(csv_files).each do |f|
    file_name = File.basename(f)
    oss_key = csv_oss_key file_name
    CBin::OSS::Helper.instance.upload(oss_key, f)
    url = CBin::OSS::Helper.instance.object_url(oss_key)
    UI.puts "云端上传成功.下载Url:#{url}\n".green
  end
end