Class: Jekyll::GitHubMetadata::RepositoryCompat
- Inherits:
-
Object
- Object
- Jekyll::GitHubMetadata::RepositoryCompat
- Defined in:
- lib/jekyll-github-metadata/repository_compat.rb
Instance Attribute Summary collapse
-
#repo ⇒ Object
readonly
Returns the value of attribute repo.
Instance Method Summary collapse
- #domain ⇒ Object
-
#initialize(repo) ⇒ RepositoryCompat
constructor
A new instance of RepositoryCompat.
- #pages_url ⇒ Object (also: #html_url)
- #source ⇒ Object
-
#url_scheme ⇒ Object
In enterprise, the site’s scheme will be the same as the instance’s In dotcom, this will be ‘https` for GitHub-owned sites that end with `.github.com` and will be `http` for all other sites.
- #user_domain ⇒ Object
Constructor Details
#initialize(repo) ⇒ RepositoryCompat
Returns a new instance of RepositoryCompat.
8 9 10 |
# File 'lib/jekyll-github-metadata/repository_compat.rb', line 8 def initialize(repo) @repo = repo end |
Instance Attribute Details
#repo ⇒ Object (readonly)
Returns the value of attribute repo.
6 7 8 |
# File 'lib/jekyll-github-metadata/repository_compat.rb', line 6 def repo @repo end |
Instance Method Details
#domain ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/jekyll-github-metadata/repository_compat.rb', line 48 def domain @domain ||= if !Pages.custom_domains_enabled? Pages.github_hostname elsif repo.cname # explicit CNAME repo.cname elsif repo.primary? # user/org repo repo.default_user_domain else # project repo user_domain end end |
#pages_url ⇒ Object Also known as: html_url
37 38 39 40 41 42 43 44 45 |
# File 'lib/jekyll-github-metadata/repository_compat.rb', line 37 def pages_url return enterprise_url unless Pages.custom_domains_enabled? if repo.cname || repo.primary? "#{url_scheme}://#{domain}" else URI.join("#{url_scheme}://#{domain}", repo.name).to_s end end |
#source ⇒ Object
61 62 63 64 65 66 |
# File 'lib/jekyll-github-metadata/repository_compat.rb', line 61 def source { "branch" => (repo.user_page? ? "master" : "gh-pages"), "path" => "/", } end |
#url_scheme ⇒ Object
In enterprise, the site’s scheme will be the same as the instance’s In dotcom, this will be ‘https` for GitHub-owned sites that end with `.github.com` and will be `http` for all other sites. Note: This is not the same as instance’s scheme, which may differ
16 17 18 19 20 21 22 23 24 |
# File 'lib/jekyll-github-metadata/repository_compat.rb', line 16 def url_scheme if Pages.enterprise? Pages.scheme elsif repo.owner == "github" && domain.end_with?(".github.com") "https" else "http" end end |
#user_domain ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/jekyll-github-metadata/repository_compat.rb', line 26 def user_domain domain = repo.default_user_domain repo.user_page_domains.each do |user_repo| candidate_nwo = "#{repo.owner}/#{user_repo}" next unless Jekyll::GitHubMetadata.client.repository?(candidate_nwo) domain = Jekyll::GitHubMetadata::Repository.new(candidate_nwo).repo_compat.domain end domain end |