code
stringlengths
26
124k
docstring
stringlengths
23
125k
func_name
stringlengths
1
98
language
stringclasses
1 value
repo
stringlengths
5
53
path
stringlengths
7
151
url
stringlengths
50
211
license
stringclasses
7 values
def sort(input, property = nil, nils = "first") if input.nil? raise ArgumentError, "Cannot sort a null object." end if property.nil? input.sort else if nils == "first" order = - 1 elsif nils == "last" order = + 1 else raise ArgumentError, "Invalid nils order: " \ "'#{nils}' is not a valid nils order. It must be 'first' or 'last'." end sort_input(input, property, order) end end
Sort an array of objects input - the object array property - property within each object to filter by nils ('first' | 'last') - nils appear before or after non-nil values Returns the filtered array of objects
sort
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/filters.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/filters.rb
Apache-2.0
def sort_input(input, property, order) input.map { |item| [item_property(item, property), item] } .sort! do |apple_info, orange_info| apple_property = apple_info.first orange_property = orange_info.first if !apple_property.nil? && orange_property.nil? - order elsif apple_property.nil? && !orange_property.nil? + order else apple_property <=> orange_property end end .map!(&:last) end
Sort the input Enumerable by the given property. If the property doesn't exist, return the sort order respective of which item doesn't have the property. We also utilize the Schwartzian transform to make this more efficient.
sort_input
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/filters.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/filters.rb
Apache-2.0
def find(path, type, setting) value = nil old_scope = nil matching_sets(path, type).each do |set| if set["values"].key?(setting) && has_precedence?(old_scope, set["scope"]) value = set["values"][setting] old_scope = set["scope"] end end value end
Finds a default value for a given setting, filtered by path and type path - the path (relative to the source) of the page, post or :draft the default is used in type - a symbol indicating whether a :page, a :post or a :draft calls this method Returns the default value or nil if none was found
find
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/frontmatter_defaults.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/frontmatter_defaults.rb
Apache-2.0
def all(path, type) defaults = {} old_scope = nil matching_sets(path, type).each do |set| if has_precedence?(old_scope, set["scope"]) defaults = Utils.deep_merge_hashes(defaults, set["values"]) old_scope = set["scope"] else defaults = Utils.deep_merge_hashes(set["values"], defaults) end end defaults end
Collects a hash with all default values for a page or post path - the relative path of the page or post type - a symbol indicating the type (:post, :page or :draft) Returns a hash with all default values (an empty hash if there are none)
all
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/frontmatter_defaults.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/frontmatter_defaults.rb
Apache-2.0
def applies?(scope, path, type) applies_path?(scope, path) && applies_type?(scope, type) end
Checks if a given default setting scope matches the given path and type scope - the hash indicating the scope, as defined in _config.yml path - the path to check for type - the type (:post, :page or :draft) to check for Returns true if the scope applies to the given path and type
applies?
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/frontmatter_defaults.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/frontmatter_defaults.rb
Apache-2.0
def applies_type?(scope, type) !scope.key?("type") || scope["type"].eql?(type.to_s) end
Determines whether the scope applies to type. The scope applies to the type if: 1. no 'type' is specified 2. the 'type' in the scope is the same as the type asked about scope - the Hash defaults set being asked about application type - the type of the document being processed / asked about its defaults. Returns true if either of the above conditions are satisfied, otherwise returns false
applies_type?
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/frontmatter_defaults.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/frontmatter_defaults.rb
Apache-2.0
def valid?(set) set.is_a?(Hash) && set["values"].is_a?(Hash) end
Checks if a given set of default values is valid set - the default value hash, as defined in _config.yml Returns true if the set is valid and can be used in this class
valid?
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/frontmatter_defaults.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/frontmatter_defaults.rb
Apache-2.0
def has_precedence?(old_scope, new_scope) return true if old_scope.nil? new_path = sanitize_path(new_scope["path"]) old_path = sanitize_path(old_scope["path"]) if new_path.length != old_path.length new_path.length >= old_path.length elsif new_scope.key?("type") true else !old_scope.key? "type" end end
Determines if a new scope has precedence over an old one old_scope - the old scope hash, or nil if there's none new_scope - the new scope hash Returns true if the new scope has precedence over the older rubocop: disable PredicateName
has_precedence?
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/frontmatter_defaults.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/frontmatter_defaults.rb
Apache-2.0
def matching_sets(path, type) valid_sets.select do |set| !set.key?("scope") || applies?(set["scope"], path, type) end end
rubocop: enable PredicateName Collects a list of sets that match the given path and type Returns an array of hashes
matching_sets
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/frontmatter_defaults.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/frontmatter_defaults.rb
Apache-2.0
def valid_sets sets = @site.config["defaults"] return [] unless sets.is_a?(Array) sets.map do |set| if valid?(set) ensure_time!(update_deprecated_types(set)) else Jekyll.logger.warn "Defaults:", "An invalid front-matter default set was found:" Jekyll.logger.warn set.to_s nil end end.compact end
Returns a list of valid sets This is not cached to allow plugins to modify the configuration and have their changes take effect Returns an array of hashes
valid_sets
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/frontmatter_defaults.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/frontmatter_defaults.rb
Apache-2.0
def initialize(site, base, name) @site = site @base = base @name = name if site.theme && site.theme.layouts_path.eql?(base) @base_dir = site.theme.root @path = site.in_theme_dir(base, name) else @base_dir = site.source @path = site.in_source_dir(base, name) end @relative_path = @path.sub(@base_dir, "") self.data = {} process(name) read_yaml(base, name) end
Initialize a new Layout. site - The Site. base - The String path to the source. name - The String filename of the post file.
initialize
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/layout.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/layout.rb
Apache-2.0
def process(name) self.ext = File.extname(name) end
Extract information from the layout filename. name - The String filename of the layout file. Returns nothing.
process
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/layout.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/layout.rb
Apache-2.0
def lookup_variable(context, variable) lookup = context variable.split(".").each do |value| lookup = lookup[value] end lookup || variable end
Lookup a Liquid variable in the given context. context - the Liquid context in question. variable - the variable name, as a string. Returns the value of the variable in the context or the variable name if not found.
lookup_variable
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/liquid_extensions.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/liquid_extensions.rb
Apache-2.0
def initialize(writer, level = :info) @messages = [] @writer = writer self.log_level = level end
Public: Create a new instance of a log writer writer - Logger compatible instance log_level - (optional, symbol) the log level Returns nothing
initialize
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/log_adapter.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/log_adapter.rb
Apache-2.0
def debug(topic, message = nil, &block) write(:debug, topic, message, &block) end
Public: Print a debug message topic - the topic of the message, e.g. "Configuration file", "Deprecation", etc. message - the message detail Returns nothing
debug
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/log_adapter.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/log_adapter.rb
Apache-2.0
def info(topic, message = nil, &block) write(:info, topic, message, &block) end
Public: Print a message topic - the topic of the message, e.g. "Configuration file", "Deprecation", etc. message - the message detail Returns nothing
info
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/log_adapter.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/log_adapter.rb
Apache-2.0
def warn(topic, message = nil, &block) write(:warn, topic, message, &block) end
Public: Print a message topic - the topic of the message, e.g. "Configuration file", "Deprecation", etc. message - the message detail Returns nothing
warn
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/log_adapter.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/log_adapter.rb
Apache-2.0
def error(topic, message = nil, &block) write(:error, topic, message, &block) end
Public: Print an error message topic - the topic of the message, e.g. "Configuration file", "Deprecation", etc. message - the message detail Returns nothing
error
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/log_adapter.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/log_adapter.rb
Apache-2.0
def message(topic, message = nil) raise ArgumentError, "block or message, not both" if block_given? && message message = yield if block_given? message = message.to_s.gsub(%r!\s+!, " ") topic = formatted_topic(topic, block_given?) out = topic + message messages << out out end
Internal: Build a topic method topic - the topic of the message, e.g. "Configuration file", "Deprecation", etc. message - the message detail Returns the formatted message
message
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/log_adapter.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/log_adapter.rb
Apache-2.0
def formatted_topic(topic, colon = false) "#{topic}#{colon ? ": " : " "}".rjust(20) end
Internal: Format the topic topic - the topic of the message, e.g. "Configuration file", "Deprecation", etc. colon - Returns the formatted topic statement
formatted_topic
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/log_adapter.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/log_adapter.rb
Apache-2.0
def write_message?(level_of_message) LOG_LEVELS.fetch(level) <= LOG_LEVELS.fetch(level_of_message) end
Internal: Check if the message should be written given the log level. level_of_message - the Symbol level of message, one of :debug, :info, :warn, :error Returns whether the message should be written.
write_message?
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/log_adapter.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/log_adapter.rb
Apache-2.0
def write(level_of_message, topic, message = nil, &block) return false unless write_message?(level_of_message) writer.public_send(level_of_message, message(topic, message, &block)) end
Internal: Log a message. level_of_message - the Symbol level of message, one of :debug, :info, :warn, :error topic - the String topic or full message message - the String message (optional) block - a block containing the message (optional) Returns false if the message was not written, otherwise returns the value of calling the appropriate writer method, e.g. writer.info.
write
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/log_adapter.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/log_adapter.rb
Apache-2.0
def initialize(site, base, dir, name) @site = site @base = base @dir = dir @name = name @path = if site.in_theme_dir(base) == base # we're in a theme site.in_theme_dir(base, dir, name) else site.in_source_dir(base, dir, name) end process(name) read_yaml(File.join(base, dir), name) data.default_proc = proc do |_, key| site.frontmatter_defaults.find(File.join(dir, name), type, key) end Jekyll::Hooks.trigger :pages, :post_init, self end
Initialize a new Page. site - The Site object. base - The String path to the source. dir - The String path between the source and the file. name - The String filename of the file.
initialize
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/page.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/page.rb
Apache-2.0
def dir if url.end_with?(FORWARD_SLASH) url else url_dir = File.dirname(url) url_dir.end_with?(FORWARD_SLASH) ? url_dir : "#{url_dir}/" end end
The generated directory into which the page will be placed upon generation. This is derived from the permalink or, if permalink is absent, will be '/' Returns the String destination directory.
dir
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/page.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/page.rb
Apache-2.0
def permalink data.nil? ? nil : data["permalink"] end
The full path and filename of the post. Defined in the YAML of the post body. Returns the String permalink or nil if none has been set.
permalink
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/page.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/page.rb
Apache-2.0
def template if !html? "/:path/:basename:output_ext" elsif index? "/:path/" else Utils.add_permalink_suffix("/:path/:basename", site.permalink_style) end end
The template of the permalink. Returns the template String.
template
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/page.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/page.rb
Apache-2.0
def url @url ||= URL.new({ :template => template, :placeholders => url_placeholders, :permalink => permalink, }).to_s end
The generated relative url of this page. e.g. /about.html. Returns the String url.
url
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/page.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/page.rb
Apache-2.0
def url_placeholders { :path => @dir, :basename => basename, :output_ext => output_ext, } end
Returns a hash of URL placeholder names (as symbols) mapping to the desired placeholder replacements. For details see "url.rb"
url_placeholders
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/page.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/page.rb
Apache-2.0
def process(name) self.ext = File.extname(name) self.basename = name[0..-ext.length - 1] end
Extract information from the page filename. name - The String filename of the page file. Returns nothing.
process
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/page.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/page.rb
Apache-2.0
def render(layouts, site_payload) site_payload["page"] = to_liquid site_payload["paginator"] = pager.to_liquid do_layout(site_payload, layouts) end
Add any necessary layouts to this post layouts - The Hash of {"name" => "layout"}. site_payload - The site payload Hash. Returns String rendered page.
render
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/page.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/page.rb
Apache-2.0
def path data.fetch("path") { relative_path } end
The path to the source file Returns the path to the source file
path
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/page.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/page.rb
Apache-2.0
def relative_path File.join(*[@dir, @name].map(&:to_s).reject(&:empty?)).sub(%r!\A\/!, "") end
The path to the page source file, relative to the site source
relative_path
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/page.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/page.rb
Apache-2.0
def destination(dest) path = site.in_dest_dir(dest, URL.unescape_path(url)) path = File.join(path, "index") if url.end_with?("/") path << output_ext unless path.end_with? output_ext path end
Obtain destination path. dest - The String path to the destination dir. Returns the destination file path String.
destination
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/page.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/page.rb
Apache-2.0
def inspect "#<Jekyll::Page @name=#{name.inspect}>" end
Returns the object as a debug String.
inspect
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/page.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/page.rb
Apache-2.0
def index? basename == "index" end
Returns the Boolean of whether this Page is an index file or not.
index?
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/page.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/page.rb
Apache-2.0
def initialize(site) @site = site end
Create an instance of this class. site - the instance of Jekyll::Site we're concerned with Returns nothing
initialize
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/plugin_manager.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/plugin_manager.rb
Apache-2.0
def conscientious_require require_theme_deps if site.theme require_plugin_files require_gems deprecation_checks end
Require all the plugins which are allowed. Returns nothing
conscientious_require
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/plugin_manager.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/plugin_manager.rb
Apache-2.0
def require_gems Jekyll::External.require_with_graceful_fail( site.gems.select { |plugin| plugin_allowed?(plugin) } ) end
Require each of the gem plugins specified. Returns nothing.
require_gems
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/plugin_manager.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/plugin_manager.rb
Apache-2.0
def require_theme_deps return false unless site.theme.runtime_dependencies site.theme.runtime_dependencies.each do |dep| next if dep.name == "jekyll" External.require_with_graceful_fail(dep.name) if plugin_allowed?(dep.name) end end
Require each of the runtime_dependencies specified by the theme's gemspec. Returns false only if no dependencies have been specified, otherwise nothing.
require_theme_deps
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/plugin_manager.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/plugin_manager.rb
Apache-2.0
def plugin_allowed?(plugin_name) !site.safe || whitelist.include?(plugin_name) end
Check whether a gem plugin is allowed to be used during this build. plugin_name - the name of the plugin Returns true if the plugin name is in the whitelist or if the site is not in safe mode.
plugin_allowed?
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/plugin_manager.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/plugin_manager.rb
Apache-2.0
def whitelist @whitelist ||= Array[site.config["whitelist"]].flatten end
Build an array of allowed plugin gem names. Returns an array of strings, each string being the name of a gem name that is allowed to be used.
whitelist
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/plugin_manager.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/plugin_manager.rb
Apache-2.0
def require_plugin_files unless site.safe plugins_path.each do |plugin_search_path| plugin_files = Utils.safe_glob(plugin_search_path, File.join("**", "*.rb")) Jekyll::External.require_with_graceful_fail(plugin_files) end end end
Require all .rb files if safe mode is off Returns nothing.
require_plugin_files
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/plugin_manager.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/plugin_manager.rb
Apache-2.0
def plugins_path if site.config["plugins_dir"].eql? Jekyll::Configuration::DEFAULTS["plugins_dir"] [site.in_source_dir(site.config["plugins_dir"])] else Array(site.config["plugins_dir"]).map { |d| File.expand_path(d) } end end
Public: Setup the plugin search path Returns an Array of plugin search paths
plugins_path
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/plugin_manager.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/plugin_manager.rb
Apache-2.0
def read @site.layouts = LayoutReader.new(site).read read_directories sort_files! @site.data = DataReader.new(site).read(site.config["data_dir"]) CollectionReader.new(site).read ThemeAssetsReader.new(site).read end
Read Site data from disk and load it into internal data structures. Returns nothing.
read
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/reader.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/reader.rb
Apache-2.0
def sort_files! site.collections.each_value { |c| c.docs.sort! } site.pages.sort_by!(&:name) site.static_files.sort_by!(&:relative_path) end
Sorts posts, pages, and static files.
sort_files!
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/reader.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/reader.rb
Apache-2.0
def read_directories(dir = "") base = site.in_source_dir(dir) return unless File.directory?(base) dot = Dir.chdir(base) { filter_entries(Dir.entries("."), base) } dot_dirs = dot.select { |file| File.directory?(@site.in_source_dir(base, file)) } dot_files = (dot - dot_dirs) dot_pages = dot_files.select do |file| Utils.has_yaml_header?(@site.in_source_dir(base, file)) end dot_static_files = dot_files - dot_pages retrieve_posts(dir) retrieve_dirs(base, dir, dot_dirs) retrieve_pages(dir, dot_pages) retrieve_static_files(dir, dot_static_files) end
Recursively traverse directories to find pages and static files that will become part of the site according to the rules in filter_entries. dir - The String relative path of the directory to read. Default: ''. Returns nothing.
read_directories
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/reader.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/reader.rb
Apache-2.0
def retrieve_posts(dir) return if outside_configured_directory?(dir) site.posts.docs.concat(post_reader.read_posts(dir)) site.posts.docs.concat(post_reader.read_drafts(dir)) if site.show_drafts end
Retrieves all the posts(posts/drafts) from the given directory and add them to the site and sort them. dir - The String representing the directory to retrieve the posts from. Returns nothing.
retrieve_posts
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/reader.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/reader.rb
Apache-2.0
def retrieve_dirs(_base, dir, dot_dirs) dot_dirs.each do |file| dir_path = site.in_source_dir(dir, file) rel_path = File.join(dir, file) unless @site.dest.chomp("/") == dir_path @site.reader.read_directories(rel_path) end end end
Recursively traverse directories with the read_directories function. base - The String representing the site's base directory. dir - The String representing the directory to traverse down. dot_dirs - The Array of subdirectories in the dir. Returns nothing.
retrieve_dirs
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/reader.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/reader.rb
Apache-2.0
def retrieve_pages(dir, dot_pages) site.pages.concat(PageReader.new(site, dir).read(dot_pages)) end
Retrieve all the pages from the current directory, add them to the site and sort them. dir - The String representing the directory retrieve the pages from. dot_pages - The Array of pages in the dir. Returns nothing.
retrieve_pages
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/reader.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/reader.rb
Apache-2.0
def retrieve_static_files(dir, dot_static_files) site.static_files.concat(StaticFileReader.new(site, dir).read(dot_static_files)) end
Retrieve all the static files from the current directory, add them to the site and sort them. dir - The directory retrieve the static files from. dot_static_files - The static files in the dir. Returns nothing.
retrieve_static_files
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/reader.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/reader.rb
Apache-2.0
def filter_entries(entries, base_directory = nil) EntryFilter.new(site, base_directory).filter(entries) end
Filter out any files/directories that are hidden or backup files (start with "." or "#" or end with "~"), or contain site content (start with "_"), or are excluded in the site configuration, unless they are web server files such as '.htaccess'. entries - The Array of String file/directory entries to filter. base_directory - The string representing the optional base directory. Returns the Array of filtered entries.
filter_entries
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/reader.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/reader.rb
Apache-2.0
def get_entries(dir, subfolder) base = site.in_source_dir(dir, subfolder) return [] unless File.exist?(base) entries = Dir.chdir(base) { filter_entries(Dir["**/*"], base) } entries.delete_if { |e| File.directory?(site.in_source_dir(base, e)) } end
Read the entries from a particular directory for processing dir - The String representing the relative path of the directory to read. subfolder - The String representing the directory to read. Returns the list of entries to process
get_entries
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/reader.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/reader.rb
Apache-2.0
def outside_configured_directory?(dir) collections_dir = site.config["collections_dir"] !collections_dir.empty? && !dir.start_with?("/#{collections_dir}") end
Internal Determine if the directory is supposed to contain posts and drafts. If the user has defined a custom collections_dir, then attempt to read posts and drafts only from within that directory. Returns true if a custom collections_dir has been set but current directory lies outside that directory.
outside_configured_directory?
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/reader.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/reader.rb
Apache-2.0
def post_reader @post_reader ||= PostReader.new(site) end
Create a single PostReader instance to retrieve drafts and posts from all valid directories in current site.
post_reader
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/reader.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/reader.rb
Apache-2.0
def regenerate?(document) return true if disabled case document when Page regenerate_page?(document) when Document regenerate_document?(document) else source_path = document.respond_to?(:path) ? document.path : nil dest_path = if document.respond_to?(:destination) document.destination(@site.dest) end source_modified_or_dest_missing?(source_path, dest_path) end end
Checks if a renderable object needs to be regenerated Returns a boolean.
regenerate?
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/regenerator.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/regenerator.rb
Apache-2.0
def add(path) return true unless File.exist?(path) metadata[path] = { "mtime" => File.mtime(path), "deps" => [], } cache[path] = true end
Add a path to the metadata Returns true, also on failure.
add
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/regenerator.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/regenerator.rb
Apache-2.0
def force(path) cache[path] = true end
Force a path to regenerate Returns true.
force
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/regenerator.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/regenerator.rb
Apache-2.0
def clear @metadata = {} clear_cache end
Clear the metadata and cache Returns nothing
clear
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/regenerator.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/regenerator.rb
Apache-2.0
def clear_cache @cache = {} end
Clear just the cache Returns nothing
clear_cache
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/regenerator.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/regenerator.rb
Apache-2.0
def source_modified_or_dest_missing?(source_path, dest_path) modified?(source_path) || (dest_path && !File.exist?(dest_path)) end
Checks if the source has been modified or the destination is missing returns a boolean
source_modified_or_dest_missing?
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/regenerator.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/regenerator.rb
Apache-2.0
def modified?(path) return true if disabled? # objects that don't have a path are always regenerated return true if path.nil? # Check for path in cache if cache.key? path return cache[path] end if metadata[path] # If we have seen this file before, # check if it or one of its dependencies has been modified existing_file_modified?(path) else # If we have not seen this file before, add it to the metadata and regenerate it add(path) end end
Checks if a path's (or one of its dependencies) mtime has changed Returns a boolean.
modified?
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/regenerator.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/regenerator.rb
Apache-2.0
def add_dependency(path, dependency) return if metadata[path].nil? || disabled unless metadata[path]["deps"].include? dependency metadata[path]["deps"] << dependency add(dependency) unless metadata.include?(dependency) end regenerate? dependency end
Add a dependency of a path Returns nothing.
add_dependency
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/regenerator.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/regenerator.rb
Apache-2.0
def write_metadata unless disabled? Jekyll.logger.debug "Writing Metadata:", ".jekyll-metadata" File.binwrite(metadata_file, Marshal.dump(metadata)) end end
Write the metadata to disk Returns nothing.
write_metadata
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/regenerator.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/regenerator.rb
Apache-2.0
def metadata_file @metadata_file ||= site.in_source_dir(".jekyll-metadata") end
Produce the absolute path of the metadata file Returns the String path of the file.
metadata_file
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/regenerator.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/regenerator.rb
Apache-2.0
def disabled? self.disabled = !site.incremental? if disabled.nil? disabled end
Check if metadata has been disabled Returns a Boolean (true for disabled, false for enabled).
disabled?
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/regenerator.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/regenerator.rb
Apache-2.0
def read_metadata @metadata = if !disabled? && File.file?(metadata_file) content = File.binread(metadata_file) begin Marshal.load(content) rescue TypeError SafeYAML.load(content) rescue ArgumentError => e Jekyll.logger.warn("Failed to load #{metadata_file}: #{e}") {} end else {} end end
Read metadata from the metadata file, if no file is found, initialize with an empty hash Returns the read metadata.
read_metadata
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/regenerator.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/regenerator.rb
Apache-2.0
def payload @payload ||= site.site_payload end
Fetches the payload used in Liquid rendering. It can be written with #payload=(new_payload) Falls back to site.site_payload if no payload is set. Returns a Jekyll::Drops::UnifiedPayloadDrop
payload
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/renderer.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/renderer.rb
Apache-2.0
def layouts @layouts || site.layouts end
The list of layouts registered for this Renderer. It can be written with #layouts=(new_layouts) Falls back to site.layouts if no layouts are registered. Returns a Hash of String => Jekyll::Layout identified as basename without the extension name.
layouts
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/renderer.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/renderer.rb
Apache-2.0
def converters @converters ||= site.converters.select { |c| c.matches(document.extname) }.sort end
Determine which converters to use based on this document's extension. Returns Array of Converter instances.
converters
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/renderer.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/renderer.rb
Apache-2.0
def output_ext @output_ext ||= (permalink_ext || converter_output_ext) end
Determine the extname the outputted file should have Returns String the output extname including the leading period.
output_ext
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/renderer.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/renderer.rb
Apache-2.0
def run Jekyll.logger.debug "Rendering:", document.relative_path assign_pages! assign_current_document! assign_highlighter_options! assign_layout_data! Jekyll.logger.debug "Pre-Render Hooks:", document.relative_path document.trigger_hooks(:pre_render, payload) render_document end
Prepare payload and render the document Returns String rendered document output
run
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/renderer.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/renderer.rb
Apache-2.0
def render_document info = { :registers => { :site => site, :page => payload["page"] }, :strict_filters => liquid_options["strict_filters"], :strict_variables => liquid_options["strict_variables"], } output = document.content if document.render_with_liquid? Jekyll.logger.debug "Rendering Liquid:", document.relative_path output = render_liquid(output, payload, info, document.path) end Jekyll.logger.debug "Rendering Markup:", document.relative_path output = convert(output.to_s) document.content = output if document.place_in_layout? Jekyll.logger.debug "Rendering Layout:", document.relative_path output = place_in_layouts(output, payload, info) end output end
Render the document. Returns String rendered document output rubocop: disable AbcSize
render_document
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/renderer.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/renderer.rb
Apache-2.0
def convert(content) converters.reduce(content) do |output, converter| begin converter.convert output rescue StandardError => e Jekyll.logger.error "Conversion error:", "#{converter.class} encountered an error while "\ "converting '#{document.relative_path}':" Jekyll.logger.error("", e.to_s) raise e end end end
rubocop: enable AbcSize Convert the document using the converters which match this renderer's document. Returns String the converted content.
convert
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/renderer.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/renderer.rb
Apache-2.0
def render_liquid(content, payload, info, path = nil) template = site.liquid_renderer.file(path).parse(content) template.warnings.each do |e| Jekyll.logger.warn "Liquid Warning:", LiquidRenderer.format_error(e, path || document.relative_path) end template.render!(payload, info) # rubocop: disable RescueException rescue Exception => e Jekyll.logger.error "Liquid Exception:", LiquidRenderer.format_error(e, path || document.relative_path) raise e end
Render the given content with the payload and info content - payload - info - path - (optional) the path to the file, for use in ex Returns String the content, rendered by Liquid.
render_liquid
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/renderer.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/renderer.rb
Apache-2.0
def invalid_layout?(layout) !document.data["layout"].nil? && layout.nil? && !(document.is_a? Jekyll::Excerpt) end
rubocop: enable RescueException Checks if the layout specified in the document actually exists layout - the layout to check Returns Boolean true if the layout is invalid, false if otherwise
invalid_layout?
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/renderer.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/renderer.rb
Apache-2.0
def place_in_layouts(content, payload, info) output = content.dup layout = layouts[document.data["layout"].to_s] validate_layout(layout) used = Set.new([layout]) # Reset the payload layout data to ensure it starts fresh for each page. payload["layout"] = nil while layout output = render_layout(output, layout, info) add_regenerator_dependencies(layout) if (layout = site.layouts[layout.data["layout"]]) break if used.include?(layout) used << layout end end output end
Render layouts and place document content inside. Returns String rendered content
place_in_layouts
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/renderer.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/renderer.rb
Apache-2.0
def initialize(config) # Source and destination may not be changed after the site has been created. @source = File.expand_path(config["source"]).freeze @dest = File.expand_path(config["destination"]).freeze self.config = config @reader = Reader.new(self) @regenerator = Regenerator.new(self) @liquid_renderer = LiquidRenderer.new(self) Jekyll.sites << self reset setup Jekyll::Hooks.trigger :site, :after_init, self end
Public: Initialize a new Site. config - A Hash containing site configuration details.
initialize
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/site.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/site.rb
Apache-2.0
def process reset read generate render cleanup write print_stats if config["profile"] end
Public: Read, process, and write this Site to output. Returns nothing.
process
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/site.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/site.rb
Apache-2.0
def setup ensure_not_in_dest plugin_manager.conscientious_require self.converters = instantiate_subclasses(Jekyll::Converter) self.generators = instantiate_subclasses(Jekyll::Generator) end
Load necessary libraries, plugins, converters, and generators. Returns nothing.
setup
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/site.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/site.rb
Apache-2.0
def ensure_not_in_dest dest_pathname = Pathname.new(dest) Pathname.new(source).ascend do |path| if path == dest_pathname raise Errors::FatalException, "Destination directory cannot be or contain the Source directory." end end end
Check that the destination dir isn't the source dir or a directory parent to the source dir.
ensure_not_in_dest
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/site.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/site.rb
Apache-2.0
def collections @collections ||= Hash[collection_names.map do |coll| [coll, Jekyll::Collection.new(self, coll)] end] end
The list of collections and their corresponding Jekyll::Collection instances. If config['collections'] is set, a new instance is created for each item in the collection, a new hash is returned otherwise. Returns a Hash containing collection name-to-instance pairs.
collections
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/site.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/site.rb
Apache-2.0
def collection_names case config["collections"] when Hash config["collections"].keys when Array config["collections"] when nil [] else raise ArgumentError, "Your `collections` key must be a hash or an array." end end
The list of collection names. Returns an array of collection names from the configuration, or an empty array if the `collections` key is not set.
collection_names
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/site.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/site.rb
Apache-2.0
def read reader.read limit_posts! Jekyll::Hooks.trigger :site, :post_read, self end
Read Site data from disk and load it into internal data structures. Returns nothing.
read
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/site.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/site.rb
Apache-2.0
def generate generators.each do |generator| start = Time.now generator.generate(self) Jekyll.logger.debug "Generating:", "#{generator.class} finished in #{Time.now - start} seconds." end end
Run each of the Generators. Returns nothing.
generate
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/site.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/site.rb
Apache-2.0
def render relative_permalinks_are_deprecated payload = site_payload Jekyll::Hooks.trigger :site, :pre_render, self, payload render_docs(payload) render_pages(payload) Jekyll::Hooks.trigger :site, :post_render, self, payload end
Render the site to the destination. Returns nothing.
render
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/site.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/site.rb
Apache-2.0
def write each_site_file do |item| item.write(dest) if regenerator.regenerate?(item) end regenerator.write_metadata Jekyll::Hooks.trigger :site, :post_write, self end
Write static files, pages, and posts. Returns nothing.
write
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/site.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/site.rb
Apache-2.0
def post_attr_hash(post_attr) # Build a hash map based on the specified post attribute ( post attr => # array of posts ) then sort each array in reverse order. hash = Hash.new { |h, key| h[key] = [] } posts.docs.each do |p| p.data[post_attr].each { |t| hash[t] << p } if p.data[post_attr] end hash.each_value { |posts| posts.sort!.reverse! } hash end
Construct a Hash of Posts indexed by the specified Post attribute. post_attr - The String name of the Post attribute. Examples post_attr_hash('categories') # => { 'tech' => [<Post A>, <Post B>], # 'ruby' => [<Post B>] } Returns the Hash: { attr => posts } where attr - One of the values for the requested attribute. posts - The Array of Posts with the given attr value.
post_attr_hash
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/site.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/site.rb
Apache-2.0
def site_data @site_data ||= (config["data"] || data) end
Prepare site data for site payload. The method maintains backward compatibility if the key 'data' is already used in _config.yml. Returns the Hash to be hooked to site.data.
site_data
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/site.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/site.rb
Apache-2.0
def site_payload Drops::UnifiedPayloadDrop.new self end
The Hash payload containing site-wide data. Returns the Hash: { "site" => data } where data is a Hash with keys: "time" - The Time as specified in the configuration or the current time if none was specified. "posts" - The Array of Posts, sorted chronologically by post date and then title. "pages" - The Array of all Pages. "html_pages" - The Array of HTML Pages. "categories" - The Hash of category values and Posts. See Site#post_attr_hash for type info. "tags" - The Hash of tag values and Posts. See Site#post_attr_hash for type info.
site_payload
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/site.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/site.rb
Apache-2.0
def find_converter_instance(klass) @find_converter_instance ||= {} @find_converter_instance[klass] ||= begin converters.find { |converter| converter.instance_of?(klass) } || \ raise("No Converters found for #{klass}") end end
Get the implementation class for the given Converter. Returns the Converter instance implementing the given Converter. klass - The Class of the Converter to fetch.
find_converter_instance
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/site.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/site.rb
Apache-2.0
def instantiate_subclasses(klass) klass.descendants.select { |c| !safe || c.safe }.sort.map do |c| c.new(config) end end
klass - class or module containing the subclasses. Returns array of instances of subclasses of parameter. Create array of instances of the subclasses of the class or module passed in as argument.
instantiate_subclasses
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/site.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/site.rb
Apache-2.0
def relative_permalinks_are_deprecated if config["relative_permalinks"] Jekyll.logger.abort_with "Since v3.0, permalinks for pages" \ " in subfolders must be relative to the" \ " site source directory, not the parent" \ " directory. Check https://jekyllrb.com/docs/upgrading/"\ " for more info." end end
Warns the user if permanent links are relative to the parent directory. As this is a deprecated function of Jekyll. Returns
relative_permalinks_are_deprecated
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/site.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/site.rb
Apache-2.0
def documents collections.each_with_object(Set.new) do |(_, collection), set| set.merge(collection.docs).merge(collection.files) end.to_a end
Get all the documents Returns an Array of all Documents
documents
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/site.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/site.rb
Apache-2.0
def frontmatter_defaults @frontmatter_defaults ||= FrontmatterDefaults.new(self) end
Returns the FrontmatterDefaults or creates a new FrontmatterDefaults if it doesn't already exist. Returns The FrontmatterDefaults
frontmatter_defaults
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/site.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/site.rb
Apache-2.0
def incremental?(override = {}) override["incremental"] || config["incremental"] end
Whether to perform a full rebuild without incremental regeneration Returns a Boolean: true for a full rebuild, false for normal build
incremental?
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/site.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/site.rb
Apache-2.0
def publisher @publisher ||= Publisher.new(self) end
Returns the publisher or creates a new publisher if it doesn't already exist. Returns The Publisher
publisher
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/site.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/site.rb
Apache-2.0
def in_source_dir(*paths) paths.reduce(source) do |base, path| Jekyll.sanitized_path(base, path) end end
Public: Prefix a given path with the source directory. paths - (optional) path elements to a file or directory within the source directory Returns a path which is prefixed with the source directory.
in_source_dir
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/site.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/site.rb
Apache-2.0
def in_theme_dir(*paths) return nil unless theme paths.reduce(theme.root) do |base, path| Jekyll.sanitized_path(base, path) end end
Public: Prefix a given path with the theme directory. paths - (optional) path elements to a file or directory within the theme directory Returns a path which is prefixed with the theme root directory.
in_theme_dir
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/site.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/site.rb
Apache-2.0
def in_dest_dir(*paths) paths.reduce(dest) do |base, path| Jekyll.sanitized_path(base, path) end end
Public: Prefix a given path with the destination directory. paths - (optional) path elements to a file or directory within the destination directory Returns a path which is prefixed with the destination directory.
in_dest_dir
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/site.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/site.rb
Apache-2.0
def collections_path dir_str = config["collections_dir"] @collections_path ||= dir_str.empty? ? source : in_source_dir(dir_str) end
Public: The full path to the directory that houses all the collections registered with the current site. Returns the source directory or the absolute path to the custom collections_dir
collections_path
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/site.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/site.rb
Apache-2.0