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 "\n\u4F7F\u7528\u65B9\u6CD5:\n\n $ image_tinify COMMAND [OPTIONS]\n\n\u652F\u6301\u7684\u64CD\u4F5C\u547D\u4EE4:\n\n + list \u67E5\u770B\u6240\u6709\u672A\u538B\u7F29\u7684\u56FE\u7247\n + compress \u5BF9\u672A\u538B\u7F29\u7684\u56FE\u7247\u8FDB\u884C\u538B\u7F29\uFF0C\u5E76\u6807\u8BB0\u4E3A\u5DF2\u538B\u7F29\n\n\u9009\u9879:\n\n --root \u8BBE\u7F6E\u56FE\u7247\u904D\u5386\u7684\u6839\u76EE\u5F55\uFF0C\u5982 --root=~/foo/bar\uFF0C\u9ED8\u8BA4\u5F53\u524D\u76EE\u5F55\n --key \u8BBE\u7F6E TinyPNG \u7684 key\uFF0C\u5982 --key=balabala\n --root-only \u53EA\u67E5\u627E\u6839\u76EE\u5F55\n --version \u67E5\u770B\u7248\u672C\u53F7\n --help \u663E\u793A\u5E2E\u52A9\n\n" 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 |