Module: Jekyll::JekyllFetch
- Defined in:
- lib/jekyll-fetch.rb
Overview
Filters for transforming URL strings into the content at the URL
Defined Under Namespace
Constant Summary collapse
- CONFIG =
{ 'default_github_branch' => 'main' }.freeze
Instance Method Summary collapse
- #fetch(uri_str, limit = 10) ⇒ Object
- #github_file(repo, file, branch = nil) ⇒ Object
- #github_readme(repo, branch = nil) ⇒ Object
- #github_url(repo) ⇒ Object
Instance Method Details
#fetch(uri_str, limit = 10) ⇒ Object
62 63 64 65 66 67 |
# File 'lib/jekyll-fetch.rb', line 62 def fetch(uri_str, limit = 10) raise ArgumentError, 'HTTP redirect too deep' if limit.zero? Jekyll.logger.debug "fetch(#{uri_str})" Utils.fetch(uri_str, limit) end |
#github_file(repo, file, branch = nil) ⇒ Object
79 80 81 82 83 |
# File 'lib/jekyll-fetch.rb', line 79 def github_file(repo, file, branch = nil) branch ||= Utils.config['default_github_branch'] Jekyll.logger.debug "github_file(#{repo}, #{file}, #{branch})" fetch "#{github_url(repo)}/raw/#{branch}/#{file}" end |
#github_readme(repo, branch = nil) ⇒ Object
73 74 75 76 77 |
# File 'lib/jekyll-fetch.rb', line 73 def github_readme(repo, branch = nil) branch ||= Utils.config['default_github_branch'] Jekyll.logger.debug "github_readme(#{repo}, #{branch})" github_file repo, 'README.md', branch end |
#github_url(repo) ⇒ Object
69 70 71 |
# File 'lib/jekyll-fetch.rb', line 69 def github_url(repo) "https://github.com/#{repo}" end |