从Pastie-Textmate命令获取

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了从Pastie-Textmate命令获取相关的知识,希望对你有一定的参考价值。

  1. #!/usr/bin/env ruby
  2.  
  3. ##Licence
  4. # ger_from_pastie.rb - A TextMate command for getting file from http://pastie.caboo.se
  5. #Copyright (C) 2006 Alessio Caiazza - abisso.org
  6. #
  7. #This program is free software; you can redistribute it and/or modify
  8. #it under the terms of the GNU General Public License as published by
  9. #the Free Software Foundation; either version 2 of the License
  10. #
  11. #This program is distributed in the hope that it will be useful,
  12. #but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. #GNU General Public License for more details.
  15. #
  16. #You should have received a copy of the GNU General Public License
  17. #along with this program; if not, write to the Free Software Foundation,
  18. #Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  19.  
  20. ##Installation
  21. # for install create a new command in textmate and paste this code
  22. # select Input: None and Output: Create New Document
  23. # enjoy
  24.  
  25.  
  26. ##Script
  27. require 'net/http'
  28.  
  29. def request_document_number
  30. s = `"#{ENV['TM_SUPPORT_PATH']}/bin/CocoaDialog.app/Contents/MacOS/CocoaDialog" inputbox --title 'Get from Pastie' --informative-text 'Please enter the number of document to download' --text '' --button1 'Get' --button2 'Cancel'`
  31. case (a = s.split(" "))[0].to_i
  32. when 1 then a[1].to_i
  33. when 2 then puts "Abort"; abort
  34. end
  35. end
  36.  
  37. begin
  38. number = request_document_number
  39. document = index = Net::HTTP.get_print(
  40. URI.parse("http://pastie.caboo.se/#{number}/download"))
  41. rescue
  42. "Some error, document number may be wrong"
  43. end

以上是关于从Pastie-Textmate命令获取的主要内容,如果未能解决你的问题,请参考以下文章

Unity 错误:功能“输出变量声明”

从 SKScene 获取命令键

如何从命令行获取设备的 iOS 版本?

从命令行获取默认打印机名称?

从命令行获取 mysql 列

仅从命令 gtime 获取执行时间