Module: ImageTinify
- Defined in:
- lib/command.rb,
lib/key_manager.rb,
lib/image_tinify.rb,
lib/image_tinify/version.rb
Defined Under Namespace
Classes: ImageTinify
Constant Summary collapse
- MARKUP_KEY =
做标记的 Key
'IMG_TINIFY'- MARKUP_VALUE =
做标记的 Value
'1'- TARGET_EXT =
目标扩展名列表
['.png']
- VERSION =
"1.0.0"
Class Method Summary collapse
Class Method Details
.random_key ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/key_manager.rb', line 6 def self.random_key uri = URI('http://code.kaipao.cc/snippets/8/raw') resp = Net::HTTP.get_response(uri) keys = JSON.parse(resp.body) key = keys.sample puts "Use [#{key['mail']}]'s key" key['key'] end |
.show_help(argv = nil) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/command.rb', line 5 def self.show_help(argv = nil) if argv == nil || argv.flag?('help') puts <<-HELP 使用方法: $ image_tinify COMMAND [OPTIONS] 支持的操作命令: + list 查看所有未压缩的图片 + compress 对未压缩的图片进行压缩,并标记为已压缩 选项: --root 设置图片遍历的根目录,如 --root=~/foo/bar,默认当前目录 --key 设置 TinyPNG 的 key,如 --key=balabala --root-only 只查找根目录 --version 查看版本号 --help 显示帮助 HELP exit(0) end end |
.show_version(argv) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/command.rb', line 31 def self.show_version(argv) if argv.flag?('version') puts VERSION exit(0) end end |