forked from octokit/octokit.rb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds support for new markdown endpoint
Fixes octokit#107
- Loading branch information
Showing
4 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |