Class: Jekyll::GitHubMetadata::RepositoryFinder
- Inherits:
-
Object
- Object
- Jekyll::GitHubMetadata::RepositoryFinder
- Defined in:
- lib/jekyll-github-metadata/repository_finder.rb
Constant Summary collapse
- NoRepositoryError =
Class.new(Jekyll::Errors::FatalException)
Instance Attribute Summary collapse
-
#site ⇒ Object
readonly
Returns the value of attribute site.
Instance Method Summary collapse
-
#initialize(site) ⇒ RepositoryFinder
constructor
A new instance of RepositoryFinder.
-
#nwo ⇒ Object
Public: fetches the repository name with owner to fetch metadata for.
Constructor Details
#initialize(site) ⇒ RepositoryFinder
Returns a new instance of RepositoryFinder.
9 10 11 |
# File 'lib/jekyll-github-metadata/repository_finder.rb', line 9 def initialize(site) @site = site end |
Instance Attribute Details
#site ⇒ Object (readonly)
Returns the value of attribute site.
8 9 10 |
# File 'lib/jekyll-github-metadata/repository_finder.rb', line 8 def site @site end |
Instance Method Details
#nwo ⇒ Object
Public: fetches the repository name with owner to fetch metadata for. In order of precedence, this method uses:
-
the environment variable $PAGES_REPO_NWO
-
‘repository’ variable in the site config
-
the ‘origin’ git remote’s URL
site - the Jekyll::Site being processed
Return the name with owner (e.g. ‘parkr/my-repo’) or raises an error if one cannot be found.
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/jekyll-github-metadata/repository_finder.rb', line 23 def nwo @nwo ||= begin nwo_from_env || \ nwo_from_config || \ nwo_from_git_origin_remote || \ proc do raise NoRepositoryError, "No repo name found. " \ "Specify using PAGES_REPO_NWO environment variables, " \ "'repository' in your configuration, or set up an 'origin' " \ "git remote pointing to your github.com repository." end.call end end |