# File lib/jekyll-github-metadata/repository.rb, line 160 def primary? if Pages.enterprise? name.downcase == "#{owner.to_s.downcase}.#{Pages.github_hostname}" else user_page_domains.include? name.downcase end end
class Jekyll::GitHubMetadata::Repository
Attributes
name[R]
nwo[R]
owner[R]
Public Class Methods
def_hash_delegator(hash, key, method)
click to toggle source
Defines an instance method that delegates to a hash’s key
hash - a symbol representing the instance method to delegate to. The
instance method should return a hash or respond to #[]
key - the key to call within the hash method - (optional) the instance method the key should be aliased to.
If not specified, defaults to the hash key
Returns a symbol representing the instance method
# File lib/jekyll-github-metadata/repository.rb, line 17 def self.def_hash_delegator(hash, key, method) define_method(method) do public_send(hash)[key.to_s] end end
new(name_with_owner)
click to toggle source
# File lib/jekyll-github-metadata/repository.rb, line 38 def initialize(name_with_owner) @nwo = name_with_owner @owner = nwo.split("/").first @name = nwo.split("/").last end
Public Instance Methods
cname()
click to toggle source
# File lib/jekyll-github-metadata/repository.rb, line 185 def cname return nil unless Pages.custom_domains_enabled? repo_pages_info["cname"] end
contributors()
click to toggle source
# File lib/jekyll-github-metadata/repository.rb, line 136 def contributors memoize_value :@contributors, Value.new("contributors", proc { |c| c.contributors(nwo) }) end
default_user_domain()
click to toggle source
# File lib/jekyll-github-metadata/repository.rb, line 175 def default_user_domain if github_repo? "#{owner}.#{Pages.github_hostname}".downcase elsif Pages.enterprise? Pages.pages_hostname.downcase else "#{owner}.#{Pages.pages_hostname}".downcase end end
forks_count()
click to toggle source
# File lib/jekyll-github-metadata/repository.rb, line 207 def forks_count repo_pages_info["forks_count"] || 0 end
github_repo?()
click to toggle source
# File lib/jekyll-github-metadata/repository.rb, line 156 def github_repo? !Pages.enterprise? && owner.eql?("github") end
html_url()
click to toggle source
# File lib/jekyll-github-metadata/repository.rb, line 191 def html_url @html_url ||= (repo_pages_info["html_url"] || repo_compat.pages_url).chomp("/") end
issues_url()
click to toggle source
# File lib/jekyll-github-metadata/repository.rb, line 103 def issues_url "#{repository_url}/issues" if repo_info["has_issues"] end
latest_release()
click to toggle source
# File lib/jekyll-github-metadata/repository.rb, line 144 def latest_release memoize_value :@latest_release, Value.new("latest_release", proc { |c| c.latest_release(nwo) }) end
organization_public_members()
click to toggle source
# File lib/jekyll-github-metadata/repository.rb, line 130 def organization_public_members memoize_value :@organization_public_members, Value.new("organization_public_members", proc do |c| c.organization_public_members(owner) if organization_repository? end) end
organization_repository?()
click to toggle source
# File lib/jekyll-github-metadata/repository.rb, line 111 def organization_repository? memoize_value :@is_organization_repository, Value.new("organization_repository?", proc { |c| !!c.organization(owner) }) end
owner_display_name()
click to toggle source
# File lib/jekyll-github-metadata/repository.rb, line 67 def owner_display_name owner_metadata.name end
owner_gravatar_url()
click to toggle source
# File lib/jekyll-github-metadata/repository.rb, line 79 def owner_gravatar_url "#{owner_url}.png" end
owner_metadata()
click to toggle source
# File lib/jekyll-github-metadata/repository.rb, line 71 def owner_metadata @owner_metadata ||= Jekyll::GitHubMetadata::Owner.new(owner) end
owner_public_repositories()
click to toggle source
# File lib/jekyll-github-metadata/repository.rb, line 115 def owner_public_repositories options = { :type => "public", :accept => "application/vnd.github.mercy-preview+json", } memoize_value :@owner_public_repositories, Value.new("owner_public_repositories", proc do |c| repos = c.list_repos(owner, options) || [] repos.map do |r| r[:releases] = Value.new("owner_public_repositories_releases", proc { c.releases(r[:full_name]) }) r[:contributors] = Value.new("owner_public_repositories_contributors", proc { c.contributors(r[:full_name]) }) r end end) end
owner_url()
click to toggle source
# File lib/jekyll-github-metadata/repository.rb, line 75 def owner_url "#{Pages.github_url}/#{owner}" end
primary?()
click to toggle source
Also aliased as: user_page?
project_page?()
click to toggle source
# File lib/jekyll-github-metadata/repository.rb, line 152 def project_page? !user_page? end
releases()
click to toggle source
# File lib/jekyll-github-metadata/repository.rb, line 140 def releases memoize_value :@releases, Value.new("releases", proc { |c| c.releases(nwo) }) end
releases_url()
click to toggle source
# File lib/jekyll-github-metadata/repository.rb, line 99 def releases_url "#{repository_url}/releases" end
repo_clone_url()
click to toggle source
# File lib/jekyll-github-metadata/repository.rb, line 83 def repo_clone_url "#{repository_url}.git" end
repo_compat()
click to toggle source
# File lib/jekyll-github-metadata/repository.rb, line 44 def repo_compat @repo_compat ||= Jekyll::GitHubMetadata::RepositoryCompat.new(self) end
repo_info()
click to toggle source
# File lib/jekyll-github-metadata/repository.rb, line 48 def repo_info @repo_info ||= begin options = { :accept => "application/vnd.github.drax-preview+json" } (Value.new("repo_info", proc { |c| c.repository(nwo, options) }).render || {}) end end
repo_pages_info()
click to toggle source
# File lib/jekyll-github-metadata/repository.rb, line 55 def repo_pages_info @repo_pages_info ||= (Value.new("repo_pages_info", proc { |c| c.pages(nwo, repo_pages_info_opts) }).render || {}) end
repo_pages_info_opts()
click to toggle source
# File lib/jekyll-github-metadata/repository.rb, line 59 def repo_pages_info_opts if Pages.repo_pages_html_url_preview? { :accept => "application/vnd.github.mister-fantastic-preview+json" } else {} end end
repository_url()
click to toggle source
# File lib/jekyll-github-metadata/repository.rb, line 87 def repository_url "#{owner_url}/#{name}" end
source()
click to toggle source
# File lib/jekyll-github-metadata/repository.rb, line 148 def source repo_pages_info["source"] || repo_compat.source end
stargazers_count()
click to toggle source
# File lib/jekyll-github-metadata/repository.rb, line 203 def stargazers_count repo_pages_info["stargazers_count"] || 0 end
tar_url()
click to toggle source
# File lib/jekyll-github-metadata/repository.rb, line 95 def tar_url "#{repository_url}/tarball/#{git_ref}" end
uri()
click to toggle source
# File lib/jekyll-github-metadata/repository.rb, line 195 def uri @uri ||= URI(html_url) end
url_without_path()
click to toggle source
# File lib/jekyll-github-metadata/repository.rb, line 199 def url_without_path uri.dup.tap { |u| u.path = "" }.to_s end
user_page_domains()
click to toggle source
# File lib/jekyll-github-metadata/repository.rb, line 169 def user_page_domains domains = [default_user_domain] domains.push "#{owner}.github.com".downcase unless Pages.enterprise? domains end
wiki_url()
click to toggle source
# File lib/jekyll-github-metadata/repository.rb, line 107 def wiki_url "#{repository_url}/wiki" if repo_info["has_wiki"] end
zip_url()
click to toggle source
# File lib/jekyll-github-metadata/repository.rb, line 91 def zip_url "#{repository_url}/zipball/#{git_ref}" end
Private Instance Methods
memoize_value(var_name, value)
click to toggle source
# File lib/jekyll-github-metadata/repository.rb, line 213 def memoize_value(var_name, value) return instance_variable_get(var_name) if instance_variable_defined?(var_name) instance_variable_set(var_name, value.render) end