Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: octokit/octokit.rb
...
head fork: octokit/octokit.rb
  • 7 commits
  • 9 files changed
  • 0 commit comments
  • 1 contributor
View
1  CHANGELOG.md
@@ -1,5 +1,6 @@
# CHANGELOG
+* [1.9.0 - July 11, 2012](https://github.com/pengwynn/octokit/compare/v1.8.1...v1.9.0)
* [1.8.1 - June 18, 2012](https://github.com/pengwynn/octokit/compare/v1.8.0...v1.8.1)
* [1.7.0 - June 18, 2012](https://github.com/pengwynn/octokit/compare/v1.6.1...v1.7.0)
* [1.6.1 - June 14, 2012](https://github.com/pengwynn/octokit/compare/v1.6.0...v1.6.1)
View
14 README.md
@@ -63,6 +63,20 @@ client = Octokit::Client.new(:login => "me", :oauth_token => "oauth2token")
client.follow!("sferik")
```
+## Using with GitHub Enterprise
+
+To use with [GitHub Enterprise](https://enterprise.github.com/), you'll need to
+set the API and web endpoints before instantiating a client.
+
+```ruby
+Octokit.configure do |c|
+ c.api_endpoint = 'https://github.company.com/api/v3'
+ c.web_endpoint = 'https://github.company.com/'
+end
+
+@client = Octokit::Client.new(:login => 'USERNAME', :password => 'PASSWORD')
+```
+
## Submitting a Pull Request
1. [Fork the repository.][fork]
2. [Create a topic branch.][branch]
View
2  lib/octokit/client.rb
@@ -21,6 +21,7 @@
require 'octokit/client/authorizations'
require 'octokit/client/refs'
require 'octokit/client/contents'
+require 'octokit/client/markdown'
module Octokit
class Client
@@ -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
View
94 lib/octokit/client/contents.rb
@@ -1,51 +1,51 @@
module Octokit
- class Client
- module Contents
+ class Client
+ module Contents
- # Receive the default Readme for a repository
- #
- # @param repo [String, Repository, Hash] A GitHub repository
- # @param ref [String] The String name of the Commit/Branch/Tag. Defaults to “master”.
- # @option options [String] :ref name of the Commit/Branch/Tag. Defaults to “master”.
- # @return [Hash] The detail of the readme
- # @see http://developer.github.com/v3/repos/contents/
- # @example Get the readme file for a repo
- # Octokit.readme("pengwynn/octokit")
- def readme(repo, options={})
- get("/repos/#{Repository.new repo}/readme", options, 3)
- end
+ # Receive the default Readme for a repository
+ #
+ # @param repo [String, Repository, Hash] A GitHub repository
+ # @param ref [String] The String name of the Commit/Branch/Tag. Defaults to “master”.
+ # @option options [String] :ref name of the Commit/Branch/Tag. Defaults to “master”.
+ # @return [Hash] The detail of the readme
+ # @see http://developer.github.com/v3/repos/contents/
+ # @example Get the readme file for a repo
+ # Octokit.readme("pengwynn/octokit")
+ def readme(repo, options={})
+ get("/repos/#{Repository.new repo}/readme", options, 3)
+ end
- # Receive a listing of a repository folder or the contents of a file
- #
- # @param repo [String, Repository, Hash] A GitHub repository
- # @option options [String] :path A folder or file path
- # @option options [String] :ref name of the Commit/Branch/Tag. Defaults to “master”.
- # @return [Hash] The contents of a file or list of the files in the folder
- # @see http://developer.github.com/v3/repos/contents/
- # @example List the contents of lib/octokit.rb
- # Octokit.contents("pengwynn/octokit", :path => 'lib/octokit.rb')
- def contents(repo, options={})
- repo_path = options.delete :path
- url = "/repos/#{Repository.new repo}/contents/#{repo_path}"
- get(url, options, 3)
- end
-
- # This method will provide a URL to download a tarball or zipball archive for a repository.
- #
- # @param repo [String, Repository, Hash] A GitHub repository.
- # @option options format [String] Either tarball (default) or zipball.
- # @option options [String] :ref Optional valid Git reference, defaults to master.
- # @return [String] Location of the download
- # @see http://developer.github.com/v3/repos/contents/
- # @example Get archive link for pengwynn/octokit
- # Octokit.archive_link("pengwynn/octokit")
- def archive_link(repo, options={})
- repo_ref = options.delete :ref
- format = (options.delete :format) || 'tarball'
- url = "/repos/#{Repository.new repo}/#{format}/#{repo_ref}"
- headers = get(url, options, 3, false, true).headers
- return headers['location']
- end
- end
+ # Receive a listing of a repository folder or the contents of a file
+ #
+ # @param repo [String, Repository, Hash] A GitHub repository
+ # @option options [String] :path A folder or file path
+ # @option options [String] :ref name of the Commit/Branch/Tag. Defaults to “master”.
+ # @return [Hash] The contents of a file or list of the files in the folder
+ # @see http://developer.github.com/v3/repos/contents/
+ # @example List the contents of lib/octokit.rb
+ # Octokit.contents("pengwynn/octokit", :path => 'lib/octokit.rb')
+ def contents(repo, options={})
+ repo_path = options.delete :path
+ url = "/repos/#{Repository.new repo}/contents/#{repo_path}"
+ get(url, options, 3)
+ end
+
+ # This method will provide a URL to download a tarball or zipball archive for a repository.
+ #
+ # @param repo [String, Repository, Hash] A GitHub repository.
+ # @option options format [String] Either tarball (default) or zipball.
+ # @option options [String] :ref Optional valid Git reference, defaults to master.
+ # @return [String] Location of the download
+ # @see http://developer.github.com/v3/repos/contents/
+ # @example Get archive link for pengwynn/octokit
+ # Octokit.archive_link("pengwynn/octokit")
+ def archive_link(repo, options={})
+ repo_ref = options.delete :ref
+ format = (options.delete :format) || 'tarball'
+ url = "/repos/#{Repository.new repo}/#{format}/#{repo_ref}"
+ headers = get(url, options, 3, false, true).headers
+ return headers['location']
+ end
+ end
+end
end
-end
View
22 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
View
2  lib/octokit/version.rb
@@ -1,3 +1,3 @@
module Octokit
- VERSION = "1.8.1" unless defined?(Octokit::VERSION)
+ VERSION = "1.9.1" unless defined?(Octokit::VERSION)
end
View
1  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>
View
64 spec/octokit/client/contents_spec.rb
@@ -1,48 +1,48 @@
# -*- encoding: utf-8 -*-
require 'helper'
-describe Octokit::Client::Contents do
+describe Octokit::Client::Contents do
- before do
+ before do
@client = Octokit::Client.new(:login => 'sferik')
end
- describe ".readme" do
+ describe ".readme" do
- it "should return the default readme" do
- stub_get("/repos/pengwynn/octokit/readme").
- to_return(:body => fixture("v3/readme.json"))
- readme = @client.readme('pengwynn/octokit')
- readme.encoding.should == "base64"
- readme.type.should == "file"
- end
+ it "should return the default readme" do
+ stub_get("/repos/pengwynn/octokit/readme").
+ to_return(:body => fixture("v3/readme.json"))
+ readme = @client.readme('pengwynn/octokit')
+ readme.encoding.should == "base64"
+ readme.type.should == "file"
+ end
- end
+ end
- describe ".contents" do
+ describe ".contents" do
- it "should return the contents of a file" do
- stub_get("/repos/pengwynn/octokit/contents/lib/octokit.rb").
- to_return(:body => fixture("v3/contents.json"))
- contents = @client.contents('pengwynn/octokit', :path => "lib/octokit.rb")
- contents.path.should == "lib/octokit.rb"
- contents.name.should == "lib/octokit.rb"
- contents.encoding.should == "base64"
- contents.type.should == "file"
- end
+ it "should return the contents of a file" do
+ stub_get("/repos/pengwynn/octokit/contents/lib/octokit.rb").
+ to_return(:body => fixture("v3/contents.json"))
+ contents = @client.contents('pengwynn/octokit', :path => "lib/octokit.rb")
+ contents.path.should == "lib/octokit.rb"
+ contents.name.should == "lib/octokit.rb"
+ contents.encoding.should == "base64"
+ contents.type.should == "file"
+ end
- end
+ end
- describe ".archive_link" do
+ describe ".archive_link" do
- it "should return the headers of the request" do
- stub_get("/repos/pengwynn/octokit/tarball/master").
- to_return(:status => 302, :body => '', :headers =>
- { 'location' => "https://nodeload.github.com/repos/pengwynn/octokit/tarball/"})
- archive_link = @client.archive_link('pengwynn/octokit', :ref => "master")
- archive_link == "https://nodeload.github.com/pengwynn/octokit/tarball/"
- end
+ it "should return the headers of the request" do
+ stub_get("/repos/pengwynn/octokit/tarball/master").
+ to_return(:status => 302, :body => '', :headers =>
+ { 'location' => "https://nodeload.github.com/repos/pengwynn/octokit/tarball/"})
+ archive_link = @client.archive_link('pengwynn/octokit', :ref => "master")
+ archive_link == "https://nodeload.github.com/pengwynn/octokit/tarball/"
+ end
- end
+ end
-end
+end
View
23 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

No commit comments for this range

Something went wrong with that request. Please try again.