Skip to content

Commit

Permalink
Adds support for new markdown endpoint
Browse files Browse the repository at this point in the history
Fixes #107
  • Loading branch information
pengwynn committed Jul 11, 2012
1 parent cb3e49c commit db82f45
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/octokit/client.rb
Expand Up @@ -21,6 +21,7 @@
require 'octokit/client/authorizations'
require 'octokit/client/refs'
require 'octokit/client/contents'
require 'octokit/client/markdown'

module Octokit
class Client
Expand Down Expand Up @@ -54,5 +55,6 @@ def initialize(options={})
include Octokit::Client::Authorizations
include Octokit::Client::Refs
include Octokit::Client::Contents
include Octokit::Client::Markdown
end
end
22 changes: 22 additions & 0 deletions lib/octokit/client/markdown.rb
@@ -0,0 +1,22 @@
module Octokit
class Client
module Markdown

# Receive the default Readme for a repository
#
# @param text [String] Markdown source
# @option options [String] (optional) :mode (`markdown` or `gfm`)
# @option options [String] (optional) :context Repo context
# @return [String] HTML renderization
# @see http://developer.github.com/v3/repos/markdown/
# @example Render some GFM
# Octokit.markdown('Fixed in #111', :mode => "gfm", :context => "pengwynn/octokit")
def markdown(text, options={})
options[:text] = text
options[:repo] = Repository.new(options[:repo]) if options[:repo]
post("/markdown", options, 3, true, true).body
end

end
end
end
1 change: 1 addition & 0 deletions spec/fixtures/v3/markdown_gfm
@@ -0,0 +1 @@
<p>This is for <a href="https://github.com/pengwynn/octokit/issues/111" class="issue-link" title="[GitHub Enterprise] Calls to custom endpoints return 404">#111</a></p>
23 changes: 23 additions & 0 deletions spec/octokit/client/markdown_spec.rb
@@ -0,0 +1,23 @@
# -*- encoding: utf-8 -*-
require 'helper'

describe Octokit::Client::Markdown do

describe ".markdown" do

before do
@client = Octokit::Client.new
end

it "should render markdown" do
stub_post("/markdown").
to_return(:body => fixture("v3/markdown_gfm"))
text = "This is for #111"
markdown = @client.markdown(text, :context => 'pengwynn/octokit', :mode => 'gfm')

markdown.should include('https://github.com/pengwynn/octokit/issues/111')
end

end

end

0 comments on commit db82f45

Please sign in to comment.