Class: Jekyll::GitHubMetadata::Repository
- Inherits:
-
Object
- Object
- Jekyll::GitHubMetadata::Repository
- Defined in:
- lib/jekyll-github-metadata/repository.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#nwo ⇒ Object
readonly
Returns the value of attribute nwo.
-
#owner ⇒ Object
readonly
Returns the value of attribute owner.
Instance Method Summary collapse
- #cname ⇒ Object
- #contributors ⇒ Object
- #default_user_domain ⇒ Object
- #domain ⇒ Object
- #git_ref ⇒ Object
- #github_repo? ⇒ Boolean
-
#initialize(name_with_owner) ⇒ Repository
constructor
A new instance of Repository.
- #issues_url ⇒ Object
- #language ⇒ Object
- #organization_public_members ⇒ Object
- #organization_repository? ⇒ Boolean
- #owner_gravatar_url ⇒ Object
- #owner_public_repositories ⇒ Object
- #owner_url ⇒ Object
- #pages_url ⇒ Object
- #primary? ⇒ Boolean
- #project_page? ⇒ Boolean
- #releases ⇒ Object
- #releases_url ⇒ Object
- #repo_clone_url ⇒ Object
- #repo_info ⇒ Object
- #repository_url ⇒ Object
- #show_downloads? ⇒ Boolean
- #tagline ⇒ Object
- #tar_url ⇒ Object
- #url_scheme ⇒ Object
- #user_domain ⇒ Object
- #user_page? ⇒ Boolean
- #user_page_domains ⇒ Object
- #wiki_url ⇒ Object
- #zip_url ⇒ Object
Constructor Details
#initialize(name_with_owner) ⇒ Repository
Returns a new instance of Repository.
5 6 7 8 9 |
# File 'lib/jekyll-github-metadata/repository.rb', line 5 def initialize(name_with_owner) @nwo = name_with_owner @owner = nwo.split("/").first @name = nwo.split("/").last end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/jekyll-github-metadata/repository.rb', line 4 def name @name end |
#nwo ⇒ Object (readonly)
Returns the value of attribute nwo.
4 5 6 |
# File 'lib/jekyll-github-metadata/repository.rb', line 4 def nwo @nwo end |
#owner ⇒ Object (readonly)
Returns the value of attribute owner.
4 5 6 |
# File 'lib/jekyll-github-metadata/repository.rb', line 4 def owner @owner end |
Instance Method Details
#cname ⇒ Object
160 161 162 163 164 165 166 |
# File 'lib/jekyll-github-metadata/repository.rb', line 160 def cname memoize_value :@cname, Value.new(proc { |c| if Pages.custom_domains_enabled? (c.pages(nwo) || {'cname' => nil})['cname'] end }) end |
#contributors ⇒ Object
81 82 83 |
# File 'lib/jekyll-github-metadata/repository.rb', line 81 def contributors memoize_value :@contributors, Value.new(proc { |c| c.contributors(nwo) }) end |
#default_user_domain ⇒ Object
119 120 121 122 123 124 125 126 127 |
# File 'lib/jekyll-github-metadata/repository.rb', line 119 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 |
#domain ⇒ Object
168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/jekyll-github-metadata/repository.rb', line 168 def domain @domain ||= if !Pages.custom_domains_enabled? Pages.github_hostname elsif cname # explicit CNAME cname elsif primary? # user/org repo default_user_domain else # project repo user_domain end end |
#git_ref ⇒ Object
11 12 13 |
# File 'lib/jekyll-github-metadata/repository.rb', line 11 def git_ref user_page? ? 'master' : 'gh-pages' end |
#github_repo? ⇒ Boolean
97 98 99 |
# File 'lib/jekyll-github-metadata/repository.rb', line 97 def github_repo? !Pages.enterprise? && owner.eql?('github') end |
#issues_url ⇒ Object
55 56 57 |
# File 'lib/jekyll-github-metadata/repository.rb', line 55 def issues_url "#{repository_url}/issues" if repo_info["has_issues"] end |
#language ⇒ Object
19 20 21 |
# File 'lib/jekyll-github-metadata/repository.rb', line 19 def language repo_info["language"] end |
#organization_public_members ⇒ Object
75 76 77 78 79 |
# File 'lib/jekyll-github-metadata/repository.rb', line 75 def organization_public_members memoize_value :@organization_public_members, Value.new(proc { |c| c.organization_public_members(owner) if organization_repository? }) end |
#organization_repository? ⇒ Boolean
67 68 69 |
# File 'lib/jekyll-github-metadata/repository.rb', line 67 def organization_repository? memoize_value :@is_organization_repository, Value.new(proc { |c| !!c.organization(owner) }) end |
#owner_gravatar_url ⇒ Object
31 32 33 |
# File 'lib/jekyll-github-metadata/repository.rb', line 31 def owner_gravatar_url "#{owner_url}.png" end |
#owner_public_repositories ⇒ Object
71 72 73 |
# File 'lib/jekyll-github-metadata/repository.rb', line 71 def owner_public_repositories memoize_value :@owner_public_repositories, Value.new(proc { |c| c.list_repos(owner, "type" => "public") }) end |
#owner_url ⇒ Object
27 28 29 |
# File 'lib/jekyll-github-metadata/repository.rb', line 27 def owner_url "#{Pages.github_url}/#{owner}" end |
#pages_url ⇒ Object
145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/jekyll-github-metadata/repository.rb', line 145 def pages_url if !Pages.custom_domains_enabled? path = user_page? ? owner : nwo if Pages.subdomain_isolation? URI.join("#{Pages.scheme}://#{Pages.pages_hostname}/", path).to_s else URI.join("#{Pages.github_url}/pages/", path).to_s end elsif cname || primary? "#{url_scheme}://#{domain}" else URI.join("#{url_scheme}://#{domain}", name).to_s end end |
#primary? ⇒ Boolean
101 102 103 104 105 106 107 |
# File 'lib/jekyll-github-metadata/repository.rb', line 101 def primary? if Pages.enterprise? name.downcase == "#{owner.to_s.downcase}.#{Pages.github_hostname}" else user_page_domains.include? name.downcase end end |
#project_page? ⇒ Boolean
93 94 95 |
# File 'lib/jekyll-github-metadata/repository.rb', line 93 def project_page? !user_page? end |
#releases ⇒ Object
85 86 87 |
# File 'lib/jekyll-github-metadata/repository.rb', line 85 def releases memoize_value :@releases, Value.new(proc { |c| c.releases(nwo) }) end |
#releases_url ⇒ Object
51 52 53 |
# File 'lib/jekyll-github-metadata/repository.rb', line 51 def releases_url "#{repository_url}/releases" end |
#repo_clone_url ⇒ Object
35 36 37 |
# File 'lib/jekyll-github-metadata/repository.rb', line 35 def repo_clone_url "#{repository_url}.git" end |
#repo_info ⇒ Object
15 16 17 |
# File 'lib/jekyll-github-metadata/repository.rb', line 15 def repo_info @repo_info ||= (Value.new(proc { |c| c.repository(nwo) }).render || Hash.new) end |
#repository_url ⇒ Object
39 40 41 |
# File 'lib/jekyll-github-metadata/repository.rb', line 39 def repository_url "#{owner_url}/#{name}" end |
#show_downloads? ⇒ Boolean
63 64 65 |
# File 'lib/jekyll-github-metadata/repository.rb', line 63 def show_downloads? !!repo_info["has_downloads"] end |
#tagline ⇒ Object
23 24 25 |
# File 'lib/jekyll-github-metadata/repository.rb', line 23 def tagline repo_info["description"] end |
#tar_url ⇒ Object
47 48 49 |
# File 'lib/jekyll-github-metadata/repository.rb', line 47 def tar_url "#{repository_url}/tarball/#{git_ref}" end |
#url_scheme ⇒ Object
109 110 111 112 113 114 115 116 117 |
# File 'lib/jekyll-github-metadata/repository.rb', line 109 def url_scheme if domain.end_with?(".github.com".freeze) "https".freeze elsif cname "http" else Pages.scheme end end |
#user_domain ⇒ Object
135 136 137 138 139 140 141 142 143 |
# File 'lib/jekyll-github-metadata/repository.rb', line 135 def user_domain domain = default_user_domain user_page_domains.each do |user_repo| candidate_nwo = "#{owner}/#{user_repo}" next unless Value.new(proc { |client| client.repository? candidate_nwo }).render domain = self.class.new(candidate_nwo).domain end domain end |
#user_page? ⇒ Boolean
89 90 91 |
# File 'lib/jekyll-github-metadata/repository.rb', line 89 def user_page? primary? end |
#user_page_domains ⇒ Object
129 130 131 132 133 |
# File 'lib/jekyll-github-metadata/repository.rb', line 129 def user_page_domains domains = [default_user_domain] domains.push "#{owner}.github.com".downcase unless Pages.enterprise? domains end |
#wiki_url ⇒ Object
59 60 61 |
# File 'lib/jekyll-github-metadata/repository.rb', line 59 def wiki_url "#{repository_url}/wiki" if repo_info["has_wiki"] end |
#zip_url ⇒ Object
43 44 45 |
# File 'lib/jekyll-github-metadata/repository.rb', line 43 def zip_url "#{repository_url}/zipball/#{git_ref}" end |