Module: RDocView

Defined in:
lib/rdoc-view.rb,
lib/rdoc-view/version.rb

Defined Under Namespace

Classes: ViewApp

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.convert(file, type) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/rdoc-view.rb', line 18

def convert(file, type)
  html = ""
  text = open(file){|f|f.read}
  case type
  when "md", "markdown"
    uri = URI.parse("https://api.github.com/markdown/raw")
    https = Net::HTTP.new(uri.host, uri.port)
    https.use_ssl = true
    https.verify_mode = OpenSSL::SSL::VERIFY_NONE
    #https.set_debug_output $stderr
    https.start do | access |
      resp = access.post(uri.path, text, {"content-type" => "text/plain"})
      html = resp.body
    end
  when "textile"
    html = RedCloth.new(text).to_html
  else
    h = RDoc::Markup::ToHtml.new
    html = h.convert(text)
  end
  return html
end