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
  • 9 commits
  • 10 files changed
  • 1 commit comment
  • 1 contributor
View
3  .travis.yml
@@ -1,4 +1,7 @@
language: ruby
+matrix:
+ allow_failures:
+ - rvm: ruby-head
rvm:
- rbx-18mode
- rbx-19mode
View
2  CHANGELOG.md
@@ -1,5 +1,7 @@
# CHANGELOG
+* [1.6.0 - June 14, 2012](https://github.com/pengwynn/octokit/compare/v1.5.0...v1.6.0)
+* [1.5.0 - June 14, 2012](https://github.com/pengwynn/octokit/compare/v1.4.0...v1.5.0)
* [1.4.0 - June 3, 2012](https://github.com/pengwynn/octokit/compare/v1.3.0...v1.4.0)
* [1.3.0 - May 17, 2012](https://github.com/pengwynn/octokit/compare/v1.2.1...v1.3.0)
* [1.2.0 - May 17, 2012](https://github.com/pengwynn/octokit/compare/v1.1.1...v1.2.0)
View
7 README.md
@@ -1,5 +1,5 @@
# Octokit [![Build Status](https://secure.travis-ci.org/pengwynn/octokit.png?branch=master)][travis] [![Dependency Status](https://gemnasium.com/pengwynn/octokit.png?travis)][gemnasium]
-Simple Ruby wrapper for the GitHub v2 & v3 API.
+Simple Ruby wrapper for the GitHub v3 API.
[travis]: http://travis-ci.org/pengwynn/octokit
[gemnasium]: https://gemnasium.com/pengwynn/octokit
@@ -26,7 +26,8 @@ Octokit.following("sferik")
```
### Repositories
-For convenience, methods that require a repository argument may be passed in any of the following forms:
+For convenience, methods that require a repository argument may be passed in
+any of the following forms:
* `"pengwynn/octokit"`
* `{:username => "pengwynn", :name => "octokit"}`
@@ -35,7 +36,7 @@ For convenience, methods that require a repository argument may be passed in any
```ruby
Octokit.repo("pengwynn/octokit")
-=> <#Hashie::Rash created_at="2009/12/10 13:41:49 -0800" description="Simple Ruby wrapper for the GitHub v2 API and feeds" fork=false forks=25 has_downloads=true has_issues=true has_wiki=true homepage="http://wynnnetherland.com/projects/octokit" integrate_branch="master" language="Ruby" name="octokit" open_issues=8 owner="pengwynn" private=false pushed_at="2011/05/05 10:48:57 -0700" size=1804 url="https://github.com/pengwynn/octokit" watchers=92>
+=> <#Hashie::Rash created_at="2009/12/10 13:41:49 -0800" description="Simple Ruby wrapper for the GitHub API and feeds" fork=false forks=25 has_downloads=true has_issues=true has_wiki=true homepage="http://wynnnetherland.com/projects/octokit" integrate_branch="master" language="Ruby" name="octokit" open_issues=8 owner="pengwynn" private=false pushed_at="2011/05/05 10:48:57 -0700" size=1804 url="https://github.com/pengwynn/octokit" watchers=92>
```
## Authenticated Requests
View
4 lib/octokit/client/pub_sub_hubbub/service_hooks.rb
@@ -13,7 +13,7 @@ module ServiceHooks
# client = Octokit::Client.new(:oauth_token = "token")
# client.subscribe_service_hook('joshk/device_imapable', 'Travis', { :token => "test", :domain => "domain", :user => "user" })
def subscribe_service_hook(repo, service_name, service_arguments = {})
- topic = "https://github.com/#{Repository.new(repo)}/events/push"
+ topic = "#{Octokit.web_endpoint}/#{Repository.new(repo)}/events/push"
callback = "github://#{service_name}?#{service_arguments.collect{ |k,v| [ k,v ].join("=") }.join("&") }"
subscribe(topic, callback)
true
@@ -28,7 +28,7 @@ def subscribe_service_hook(repo, service_name, service_arguments = {})
# client = Octokit::Client.new(:oauth_token = "token")
# client.unsubscribe_service_hook('joshk/device_imapable', 'Travis')
def unsubscribe_service_hook(repo, service_name)
- topic = "https://github.com/#{Repository.new(repo)}/events/push"
+ topic = "#{Octokit.web_endpoint}/#{Repository.new(repo)}/events/push"
callback = "github://#{service_name}"
unsubscribe(topic, callback)
true
View
6 lib/octokit/configuration.rb
@@ -6,6 +6,8 @@ module Configuration
VALID_OPTIONS_KEYS = [
:adapter,
:api_version,
+ :api_endpoint,
+ :web_endpoint,
:login,
:password,
:proxy,
@@ -16,6 +18,8 @@ module Configuration
DEFAULT_ADAPTER = Faraday.default_adapter
DEFAULT_API_VERSION = 3
+ DEFAULT_API_ENDPOINT = 'https://api.github.com'
+ DEFAULT_WEB_ENDPOINT = 'https://github.com'
DEFAULT_USER_AGENT = "Octokit Ruby Gem #{Octokit::VERSION}".freeze
DEFAULT_AUTO_TRAVERSAL = false
@@ -36,6 +40,8 @@ def options
def reset
self.adapter = DEFAULT_ADAPTER
self.api_version = DEFAULT_API_VERSION
+ self.api_endpoint = DEFAULT_API_ENDPOINT
+ self.web_endpoint = DEFAULT_WEB_ENDPOINT
self.login = nil
self.password = nil
self.proxy = nil
View
5 lib/octokit/connection.rb
@@ -8,10 +8,8 @@ module Connection
def connection(authenticate=true, raw=false, version=3, force_urlencoded=false)
case version
- when 2
- url = "https://github.com"
when 3
- url = "https://api.github.com"
+ url = Octokit.api_endpoint
end
options = {
@@ -22,6 +20,7 @@ def connection(authenticate=true, raw=false, version=3, force_urlencoded=false)
options.merge!(:params => {:access_token => oauth_token}) if oauthed? && !authenticated?
+ # TODO: Don't build on every request
connection = Faraday.new(options) do |builder|
if version >= 3 && !force_urlencoded
builder.request :json
View
2  lib/octokit/repository.rb
@@ -30,7 +30,7 @@ def to_s
end
def url
- "https://github.com/#{slug}"
+ "#{Octokit.web_endpoint}/#{slug}"
end
alias :user :username
View
2  lib/octokit/version.rb
@@ -1,3 +1,3 @@
module Octokit
- VERSION = "1.5.0" unless defined?(Octokit::VERSION)
+ VERSION = "1.6.0" unless defined?(Octokit::VERSION)
end
View
19 spec/octokit/client_spec.rb
@@ -62,4 +62,23 @@
end
+ describe "api_endpoint" do
+
+ after(:each) do
+ Octokit.reset
+ end
+
+ it "should default to https://api.github.com" do
+ client = Octokit::Client.new
+ client.api_endpoint.should == 'https://api.github.com'
+ end
+
+ it "should be set " do
+ Octokit.api_endpoint = 'http://foo.dev'
+ client = Octokit::Client.new
+ client.api_endpoint.should == 'http://foo.dev'
+ end
+ end
+
+
end
View
1  spec/repository_spec.rb
@@ -41,6 +41,7 @@
repository = Octokit::Repository.new(Octokit::Repository.new('sferik/octokit'))
repository.name.should == "octokit"
repository.username.should == "sferik"
+ repository.url.should == 'https://github.com/sferik/octokit'
end
end

Showing you all comments on commits in this comparison.

@pengwynn
Owner

To use:

Octokit.api_endpoint = 'http://foo.dev'
Octokit.user 'defunkt'

/cc @jbarnette

Something went wrong with that request. Please try again.