Class: Privatepaste

Inherits:
Object
  • Object
show all
Includes:
REXML
Defined in:
lib/privatepaste.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Privatepaste

Returns a new instance of Privatepaste.



13
14
15
# File 'lib/privatepaste.rb', line 13

def initialize(options)
    @options = options
end

Instance Method Details

#get_rawObject



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/privatepaste.rb', line 33

def get_raw
    @options["secure_paste_key"] = "" if ! @options["secure_paste_key"]
    url = "https://privatepaste.com/" +
          "download/" +
          @options["link"].split("/")[3] +
          "/" +
          @options["secure_paste_key"]
    clnt = HTTPClient.new(:agent_name => 'ruby privatepaste gem')
    clnt.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE
    clnt.get_content(url)
end

#pasteObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/privatepaste.rb', line 17

def paste
    if @options.has_key?("paste_content")
        if @options["paste_content"] == "-"
            @options["paste_content"] = $stdin.read
        else
            File.open(@options["paste_content"]) do |file|
                @options["paste_content"] = file.read
            end
        end
    end
    clnt = HTTPClient.new
    clnt.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE
    res = clnt.post("https://privatepaste.com/save", @options).header['location'][0]
    "https://privatepaste.com" + res
end