Class: Lhj::Command::Local::Upload
Class Method Summary
collapse
Instance Method Summary
collapse
#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
#auto_spin, #run, #stop
Constructor Details
#initialize(argv) ⇒ Upload
Returns a new instance of Upload.
15
16
17
18
19
|
# File 'lib/lhj/command/local/local_upload.rb', line 15
def initialize(argv)
@pwd_path = argv.shift_argument || Dir.pwd
@upload_csv_file = argv.option('upload-file', '*.csv')
super
end
|
Class Method Details
.options ⇒ Object
9
10
11
12
13
|
# File 'lib/lhj/command/local/local_upload.rb', line 9
def self.options
[
%w[--upload-file 上传中英文对照csv文件名]
]
end
|
Instance Method Details
#csv_file_name ⇒ Object
21
22
23
24
25
|
# File 'lib/lhj/command/local/local_upload.rb', line 21
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
27
28
29
|
# File 'lib/lhj/command/local/local_upload.rb', line 27
def csv_oss_key(file_name)
"csv/#{Time.now.to_i}/#{file_name}"
end
|
#handle ⇒ Object
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/lhj/command/local/local_upload.rb', line 31
def handle
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
Lhj::OSS::Helper.instance.upload(oss_key, f)
url = Lhj::OSS::Helper.instance.object_url(oss_key)
puts "云端上传成功.下载Url:#{url}\n"
end
end
|