module ImageTinify
Constants
- MARKUP_KEY
做标记的 Key
- MARKUP_VALUE
做标记的 Value
- TARGET_EXT
目标扩展名列表
- VERSION
Public Class Methods
random_key()
click to toggle source
# 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)
click to toggle source
# 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 对未压缩的图片进行压缩,并标记为已压缩 + mark 直接标记一张图片为已压缩 选项: --root 设置图片遍历的根目录,如 --root=~/foo/bar,默认当前目录 --key 设置 TinyPNG 的 key,如 --key=balabala --root-only 只查找根目录 --version 查看版本号 --help 显示帮助 HELP exit(0) end end
show_version(argv)
click to toggle source
# File lib/command.rb, line 32 def self.show_version(argv) if argv.flag?('version') puts VERSION exit(0) end end