Class: Lhj::Command::OSS::Upload
- Inherits:
-
Lhj::Command::OSS
- Object
- CLAide::Command
- Lhj::Command
- Lhj::Command::OSS
- Lhj::Command::OSS::Upload
- Defined in:
- lib/lhj/command/oss/upload.rb
Overview
OSS file upload
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv) ⇒ Upload
constructor
A new instance of Upload.
- #run ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(argv) ⇒ Upload
Returns a new instance of Upload.
29 30 31 32 33 34 |
# File 'lib/lhj/command/oss/upload.rb', line 29 def initialize(argv) @current_path = argv.shift_argument || Dir.pwd @type = argv.option('type') @name = argv.option('name') super end |
Class Method Details
.options ⇒ Object
17 18 19 20 21 22 |
# File 'lib/lhj/command/oss/upload.rb', line 17 def self. [ %w[--type 文件类型], %w[--name 文件名] ] end |
Instance Method Details
#run ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/lhj/command/oss/upload.rb', line 36 def run Dir.glob(@current_path).each do |f| file_name = File.basename(f) if @name && /#{@name}/ =~ file_name upload(f, file_name) elsif @type && /#{@type}/ =~ file_name upload(f, file_name) end end end |
#validate! ⇒ Object
24 25 26 27 |
# File 'lib/lhj/command/oss/upload.rb', line 24 def validate! super help! '类型或名字必须输入' unless @name && @type end |