Permalink
Browse files

Added new paramater for github_url

Support github alternative sites.
for example: github:enterprise https://enterprise.github.com/
  • Loading branch information...
koichiro committed Jan 31, 2012
1 parent 9c5d4c7 commit 2097821c7c5aa4dc02a2cc54d5ca51968b373f95
Showing with 23 additions and 4 deletions.
  1. +4 −1 lib/octokit/configuration.rb
  2. +14 −2 lib/octokit/connection.rb
  3. +5 −1 lib/octokit/repository.rb
@@ -11,12 +11,14 @@ module Configuration
:proxy,
:oauth_token,
:user_agent,
- :auto_traversal].freeze
+ :auto_traversal,
+ :github_url].freeze
DEFAULT_ADAPTER = Faraday.default_adapter
DEFAULT_API_VERSION = 2
DEFAULT_USER_AGENT = "Octokit Ruby Gem #{Octokit::VERSION}".freeze
DEFAULT_AUTO_TRAVERSAL = false
+ DEFAULT_GITHUB_URL = "https://github.com"
attr_accessor(*VALID_OPTIONS_KEYS)
@@ -41,6 +43,7 @@ def reset
self.oauth_token = nil
self.user_agent = DEFAULT_USER_AGENT
self.auto_traversal = DEFAULT_AUTO_TRAVERSAL
+ self.github_url = DEFAULT_GITHUB_URL
end
end
end
View
@@ -9,9 +9,21 @@ module Connection
def connection(authenticate=true, raw=false, version=2, force_urlencoded=false)
case version
when 2
- url = "https://github.com"
+ if github_url
+ url = github_url
+ else
+ url = "https://github.com"
+ end
when 3
- url = "https://api.github.com"
+ if github_url
+ if github_url[/(https|http):\/\/(.*)/]
+ url = "#{$1}://api.#{$2}"
+ else
+ url = "https://api.github.com"
+ end
+ else
+ url = "https://api.github.com"
+ end
end
options = {
@@ -30,7 +30,11 @@ def to_s
end
def url
- "https://github.com/#{slug}"
+ if Client.github_url
+ "#{Client.github_url}/#{slug}"
+ else
+ "https://github.com/#{slug}"
+ end
end
alias :user :username

0 comments on commit 2097821

Please sign in to comment.