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 mtimes
@mtimes ||= {}
end
|
The cache of last modification times [path] -> mtime.
|
mtimes
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/static_file.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/static_file.rb
|
Apache-2.0
|
def initialize(site, base, dir, name, collection = nil)
@site = site
@base = base
@dir = dir
@name = name
@collection = collection
@relative_path = File.join(*[@dir, @name].compact)
@extname = File.extname(@name)
@data = @site.frontmatter_defaults.all(relative_path, type)
end
|
Initialize a new StaticFile.
site - The Site.
base - The String path to the <source>.
dir - The String path between <source> and the file.
name - The String filename of the file.
rubocop: disable ParameterLists
|
initialize
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/static_file.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/static_file.rb
|
Apache-2.0
|
def path
# Static file is from a collection inside custom collections directory
if [email protected]? && [email protected]["collections_dir"].empty?
File.join(*[@base, @site.config["collections_dir"], @dir, @name].compact)
else
File.join(*[@base, @dir, @name].compact)
end
end
|
rubocop: enable ParameterLists
Returns source file path.
|
path
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/static_file.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/static_file.rb
|
Apache-2.0
|
def destination(dest)
@site.in_dest_dir(*[dest, destination_rel_dir, @name].compact)
end
|
Obtain destination path.
dest - The String path to the destination dir.
Returns destination file path.
|
destination
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/static_file.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/static_file.rb
|
Apache-2.0
|
def modified?
self.class.mtimes[path] != mtime
end
|
Is source path modified?
Returns true if modified since last write.
|
modified?
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/static_file.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/static_file.rb
|
Apache-2.0
|
def write?
defaults.fetch("published", true)
end
|
Whether to write the file to the filesystem
Returns true unless the defaults for the destination path from
_config.yml contain `published: false`.
|
write?
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/static_file.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/static_file.rb
|
Apache-2.0
|
def write(dest)
dest_path = destination(dest)
return false if File.exist?(dest_path) && !modified?
self.class.mtimes[path] = mtime
FileUtils.mkdir_p(File.dirname(dest_path))
FileUtils.rm(dest_path) if File.exist?(dest_path)
copy_file(dest_path)
true
end
|
Write the static file to the destination directory (if modified).
dest - The String path to the destination dir.
Returns false if the file was not modified since last time (no-op).
|
write
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/static_file.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/static_file.rb
|
Apache-2.0
|
def url
@url ||= if @collection.nil?
relative_path
else
::Jekyll::URL.new({
:template => @collection.url_template,
:placeholders => placeholders,
})
end.to_s.chomp("/")
end
|
Applies a similar URL-building technique as Jekyll::Document that takes
the collection's URL template into account. The default URL template can
be overriden in the collection's configuration in _config.yml.
|
url
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/static_file.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/static_file.rb
|
Apache-2.0
|
def type
@type ||= @collection.nil? ? nil : @collection.label.to_sym
end
|
Returns the type of the collection if present, nil otherwise.
|
type
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/static_file.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/static_file.rb
|
Apache-2.0
|
def defaults
@defaults ||= @site.frontmatter_defaults.all url, type
end
|
Returns the front matter defaults defined for the file's URL and/or type
as defined in _config.yml.
|
defaults
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/static_file.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/static_file.rb
|
Apache-2.0
|
def initialize(options)
@template = options[:template]
@placeholders = options[:placeholders] || {}
@permalink = options[:permalink]
if (@template || @permalink).nil?
raise ArgumentError, "One of :template or :permalink must be supplied."
end
end
|
options - One of :permalink or :template must be supplied.
:template - The String used as template for URL generation,
for example "/:path/:basename:output_ext", where
a placeholder is prefixed with a colon.
:placeholders - A hash containing the placeholders which will be
replaced when used inside the template. E.g.
{ "year" => Time.now.strftime("%Y") } would replace
the placeholder ":year" with the current year.
:permalink - If supplied, no URL will be generated from the
template. Instead, the given permalink will be
used as URL.
|
initialize
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/url.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/url.rb
|
Apache-2.0
|
def to_s
sanitize_url(generated_permalink || generated_url)
end
|
The generated relative URL of the resource
Returns the String URL
|
to_s
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/url.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/url.rb
|
Apache-2.0
|
def generated_permalink
(@generated_permalink ||= generate_url(@permalink)) if @permalink
end
|
Generates a URL from the permalink
Returns the _unsanitized String URL
|
generated_permalink
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/url.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/url.rb
|
Apache-2.0
|
def generated_url
@generated_url ||= generate_url(@template)
end
|
Generates a URL from the template
Returns the unsanitized String URL
|
generated_url
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/url.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/url.rb
|
Apache-2.0
|
def generate_url(template)
if @placeholders.is_a? Drops::UrlDrop
generate_url_from_drop(template)
else
generate_url_from_hash(template)
end
end
|
Internal: Generate the URL by replacing all placeholders with their
respective values in the given template
Returns the unsanitized String URL
|
generate_url
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/url.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/url.rb
|
Apache-2.0
|
def possible_keys(key)
if key.end_with?("_")
[key, key.chomp("_")]
else
[key]
end
end
|
We include underscores in keys to allow for 'i_month' and so forth.
This poses a problem for keys which are followed by an underscore
but the underscore is not part of the key, e.g. '/:month_:day'.
That should be :month and :day, but our key extraction regexp isn't
smart enough to know that so we have to make it an explicit
possibility.
|
possible_keys
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/url.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/url.rb
|
Apache-2.0
|
def sanitize_url(str)
"/#{str}".gsub("..", "/").gsub("./", "").squeeze("/")
end
|
Returns a sanitized String URL, stripping "../../" and multiples of "/",
as well as the beginning "/" so we can enforce and ensure it.
|
sanitize_url
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/url.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/url.rb
|
Apache-2.0
|
def strip_heredoc(str)
str.gsub(%r!^[ \t]{#{(str.scan(%r!^[ \t]*(?=\S)!).min || "").size}}!, "")
end
|
Takes an indented string and removes the preceding spaces on each line
|
strip_heredoc
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/utils.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/utils.rb
|
Apache-2.0
|
def titleize_slug(slug)
slug.split("-").map!(&:capitalize).join(" ")
end
|
Takes a slug and turns it into a simple title.
|
titleize_slug
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/utils.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/utils.rb
|
Apache-2.0
|
def deep_merge_hashes(master_hash, other_hash)
deep_merge_hashes!(master_hash.dup, other_hash)
end
|
Non-destructive version of deep_merge_hashes! See that method.
Returns the merged hashes.
|
deep_merge_hashes
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/utils.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/utils.rb
|
Apache-2.0
|
def deep_merge_hashes!(target, overwrite)
merge_values(target, overwrite)
merge_default_proc(target, overwrite)
duplicate_frozen_values(target)
target
end
|
Merges a master hash with another hash, recursively.
master_hash - the "parent" hash whose values will be overridden
other_hash - the other hash whose values will be persisted after the merge
This code was lovingly stolen from some random gem:
http://gemjack.com/gems/tartan-0.1.1/classes/Hash.html
Thanks to whoever made it.
|
deep_merge_hashes!
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/utils.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/utils.rb
|
Apache-2.0
|
def pluralized_array_from_hash(hash, singular_key, plural_key)
[].tap do |array|
value = value_from_singular_key(hash, singular_key)
value ||= value_from_plural_key(hash, plural_key)
array << value
end.flatten.compact
end
|
Read array from the supplied hash favouring the singular key
and then the plural key, and handling any nil entries.
hash - the hash to read from
singular_key - the singular key
plural_key - the plural key
Returns an array
|
pluralized_array_from_hash
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/utils.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/utils.rb
|
Apache-2.0
|
def symbolize_hash_keys(hash)
transform_keys(hash) { |key| key.to_sym rescue key }
end
|
Apply #to_sym to all keys in the hash
hash - the hash to which to apply this transformation
Returns a new hash with symbolized keys
|
symbolize_hash_keys
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/utils.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/utils.rb
|
Apache-2.0
|
def stringify_hash_keys(hash)
transform_keys(hash) { |key| key.to_s rescue key }
end
|
Apply #to_s to all keys in the Hash
hash - the hash to which to apply this transformation
Returns a new hash with stringified keys
|
stringify_hash_keys
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/utils.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/utils.rb
|
Apache-2.0
|
def parse_date(input, msg = "Input could not be parsed.")
Time.parse(input).localtime
rescue ArgumentError
raise Errors::InvalidDateError, "Invalid date '#{input}': #{msg}"
end
|
Parse a date/time and throw an error if invalid
input - the date/time to parse
msg - (optional) the error message to show the user
Returns the parsed date if successful, throws a FatalException
if not
|
parse_date
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/utils.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/utils.rb
|
Apache-2.0
|
def has_yaml_header?(file)
!!(File.open(file, "rb", &:readline) =~ %r!\A---\s*\r?\n!)
rescue EOFError
false
end
|
Determines whether a given file has
Returns true if the YAML front matter is present.
rubocop: disable PredicateName
|
has_yaml_header?
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/utils.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/utils.rb
|
Apache-2.0
|
def has_liquid_construct?(content)
return false if content.nil? || content.empty?
content.include?("{%") || content.include?("{{")
end
|
Determine whether the given content string contains Liquid Tags or Vaiables
Returns true is the string contains sequences of `{%` or `{{`
|
has_liquid_construct?
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/utils.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/utils.rb
|
Apache-2.0
|
def slugify(string, mode: nil, cased: false)
mode ||= "default"
return nil if string.nil?
unless SLUGIFY_MODES.include?(mode)
return cased ? string : string.downcase
end
# Drop accent marks from latin characters. Everything else turns to ?
if mode == "latin"
I18n.config.available_locales = :en if I18n.config.available_locales.empty?
string = I18n.transliterate(string)
end
slug = replace_character_sequence_with_hyphen(string, :mode => mode)
# Remove leading/trailing hyphen
slug.gsub!(%r!^\-|\-$!i, "")
slug.downcase! unless cased
slug
end
|
rubocop: enable PredicateName
Slugify a filename or title.
string - the filename or title to slugify
mode - how string is slugified
cased - whether to replace all uppercase letters with their
lowercase counterparts
When mode is "none", return the given string.
When mode is "raw", return the given string,
with every sequence of spaces characters replaced with a hyphen.
When mode is "default" or nil, non-alphabetic characters are
replaced with a hyphen too.
When mode is "pretty", some non-alphabetic characters (._~!$&'()+,;=@)
are not replaced with hyphen.
When mode is "ascii", some everything else except ASCII characters
a-z (lowercase), A-Z (uppercase) and 0-9 (numbers) are not replaced with hyphen.
When mode is "latin", the input string is first preprocessed so that
any letters with accents are replaced with the plain letter. Afterwards,
it follows the "default" mode of operation.
If cased is true, all uppercase letters in the result string are
replaced with their lowercase counterparts.
Examples:
slugify("The _config.yml file")
# => "the-config-yml-file"
slugify("The _config.yml file", "pretty")
# => "the-_config.yml-file"
slugify("The _config.yml file", "pretty", true)
# => "The-_config.yml file"
slugify("The _config.yml file", "ascii")
# => "the-config-yml-file"
slugify("The _config.yml file", "latin")
# => "the-config-yml-file"
Returns the slugified string.
|
slugify
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/utils.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/utils.rb
|
Apache-2.0
|
def add_permalink_suffix(template, permalink_style)
template = template.dup
case permalink_style
when :pretty
template << "/"
when :date, :ordinal, :none
template << ":output_ext"
else
template << "/" if permalink_style.to_s.end_with?("/")
template << ":output_ext" if permalink_style.to_s.end_with?(":output_ext")
end
template
end
|
Add an appropriate suffix to template so that it matches the specified
permalink style.
template - permalink template without trailing slash or file extension
permalink_style - permalink style, either built-in or custom
The returned permalink template will use the same ending style as
specified in permalink_style. For example, if permalink_style contains a
trailing slash (or is :pretty, which indirectly has a trailing slash),
then so will the returned template. If permalink_style has a trailing
":output_ext" (or is :none, :date, or :ordinal) then so will the returned
template. Otherwise, template will be returned without modification.
Examples:
add_permalink_suffix("/:basename", :pretty)
# => "/:basename/"
add_permalink_suffix("/:basename", :date)
# => "/:basename:output_ext"
add_permalink_suffix("/:basename", "/:year/:month/:title/")
# => "/:basename/"
add_permalink_suffix("/:basename", "/:year/:month/:title")
# => "/:basename"
Returns the updated permalink template
|
add_permalink_suffix
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/utils.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/utils.rb
|
Apache-2.0
|
def safe_glob(dir, patterns, flags = 0)
return [] unless Dir.exist?(dir)
pattern = File.join(Array(patterns))
return [dir] if pattern.empty?
Dir.chdir(dir) do
Dir.glob(pattern, flags).map { |f| File.join(dir, f) }
end
end
|
Work the same way as Dir.glob but seperating the input into two parts
('dir' + '/' + 'pattern') to make sure the first part('dir') does not act
as a pattern.
For example, Dir.glob("path[/*") always returns an empty array,
because the method fails to find the closing pattern to '[' which is ']'
Examples:
safe_glob("path[", "*")
# => ["path[/file1", "path[/file2"]
safe_glob("path", "*", File::FNM_DOTMATCH)
# => ["path/.", "path/..", "path/file1"]
safe_glob("path", ["**", "*"])
# => ["path[/file1", "path[/folder/file2"]
dir - the dir where glob will be executed under
(the dir will be included to each result)
patterns - the patterns (or the pattern) which will be applied under the dir
flags - the flags which will be applied to the pattern
Returns matched pathes
|
safe_glob
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/utils.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/utils.rb
|
Apache-2.0
|
def merged_file_read_opts(site, opts)
merged = (site ? site.file_read_opts : {}).merge(opts)
if merged[:encoding] && !merged[:encoding].start_with?("bom|")
merged[:encoding] = "bom|#{merged[:encoding]}"
end
if merged["encoding"] && !merged["encoding"].start_with?("bom|")
merged["encoding"] = "bom|#{merged["encoding"]}"
end
merged
end
|
Returns merged option hash for File.read of self.site (if exists)
and a given param
|
merged_file_read_opts
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/utils.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/utils.rb
|
Apache-2.0
|
def init_with_program(prog)
prog.command(:build) do |c|
c.syntax "build [options]"
c.description "Build your site"
c.alias :b
add_build_options(c)
c.action do |_, options|
options["serving"] = false
Jekyll::Commands::Build.process(options)
end
end
end
|
Create the Mercenary command for the Jekyll CLI for this Command
|
init_with_program
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/commands/build.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/commands/build.rb
|
Apache-2.0
|
def process(options)
# Adjust verbosity quickly
Jekyll.logger.adjust_verbosity(options)
options = configuration_from_options(options)
site = Jekyll::Site.new(options)
if options.fetch("skip_initial_build", false)
Jekyll.logger.warn "Build Warning:", "Skipping the initial build." \
" This may result in an out-of-date site."
else
build(site, options)
end
if options.fetch("detach", false)
Jekyll.logger.info "Auto-regeneration:",
"disabled when running server detached."
elsif options.fetch("watch", false)
watch(site, options)
else
Jekyll.logger.info "Auto-regeneration:", "disabled. Use --watch to enable."
end
end
|
Build your jekyll site
Continuously watch if `watch` is set to true in the config.
|
process
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/commands/build.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/commands/build.rb
|
Apache-2.0
|
def build(site, options)
t = Time.now
source = options["source"]
destination = options["destination"]
incremental = options["incremental"]
Jekyll.logger.info "Source:", source
Jekyll.logger.info "Destination:", destination
Jekyll.logger.info "Incremental build:",
(incremental ? "enabled" : "disabled. Enable with --incremental")
Jekyll.logger.info "Generating..."
process_site(site)
Jekyll.logger.info "", "done in #{(Time.now - t).round(3)} seconds."
end
|
Build your Jekyll site.
site - the Jekyll::Site instance to build
options - A Hash of options passed to the command
Returns nothing.
|
build
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/commands/build.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/commands/build.rb
|
Apache-2.0
|
def watch(site, options)
# Warn Windows users that they might need to upgrade.
if Utils::Platforms.bash_on_windows?
Jekyll.logger.warn "",
"Auto-regeneration may not work on some Windows versions."
Jekyll.logger.warn "",
"Please see: https://github.com/Microsoft/BashOnWindows/issues/216"
Jekyll.logger.warn "",
"If it does not work, please upgrade Bash on Windows or "\
"run Jekyll with --no-watch."
end
External.require_with_graceful_fail "jekyll-watch"
watch_method = Jekyll::Watcher.method(:watch)
if watch_method.parameters.size == 1
watch_method.call(
options
)
else
watch_method.call(
options, site
)
end
end
|
Private: Watch for file changes and rebuild the site.
site - A Jekyll::Site instance
options - A Hash of options passed to the command
Returns nothing.
|
watch
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/commands/build.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/commands/build.rb
|
Apache-2.0
|
def after_install(path, options = {})
unless options["blank"] || options["skip-bundle"]
begin
require "bundler"
bundle_install path
rescue LoadError
Jekyll.logger.info "Could not load Bundler. Bundle install skipped."
end
end
Jekyll.logger.info "New jekyll site installed in #{path.cyan}."
Jekyll.logger.info "Bundle install skipped." if options["skip-bundle"]
end
|
After a new blog has been created, print a success notification and
then automatically execute bundle install from within the new blog dir
unless the user opts to generate a blank blog or skip 'bundle install'.
|
after_install
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/commands/new.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/commands/new.rb
|
Apache-2.0
|
def reload(pages)
pages.each do |p|
json_message = JSON.dump({
:command => "reload",
:path => p.url,
:liveCSS => true,
})
Jekyll.logger.debug "LiveReload:", "Reloading #{p.url}"
Jekyll.logger.debug "", json_message
@websockets.each { |ws| ws.send(json_message) }
end
end
|
For a description of the protocol see
http://feedback.livereload.com/knowledgebase/articles/86174-livereload-protocol
|
reload
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/commands/serve/live_reload_reactor.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/commands/serve/live_reload_reactor.rb
|
Apache-2.0
|
def search_file(req, res, basename)
# /file.* > /file/index.html > /file.html
super || super(req, res, "#{basename}.html")
end
|
Add the ability to tap file.html the same way that Nginx does on our
Docker images (or on GitHub Pages.) The difference is that we might end
up with a different preference on which comes first.
|
search_file
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/commands/serve/servlet.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/commands/serve/servlet.rb
|
Apache-2.0
|
def conditionally_inject_charset(res)
typ = res.header["content-type"]
return unless @mime_types_charset.key?(typ)
return if %r!;\s*charset=!.match?(typ)
res.header["content-type"] = "#{typ}; charset=#{@jekyll_opts["encoding"]}"
end
|
Inject charset based on Jekyll config only if our mime-types database contains
the charset metadata.
Refer `script/vendor-mimes` in the repository for further details.
|
conditionally_inject_charset
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/commands/serve/servlet.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/commands/serve/servlet.rb
|
Apache-2.0
|
def get_processor
case @config["markdown"].downcase
when "redcarpet" then return RedcarpetParser.new(@config)
when "kramdown" then return KramdownParser.new(@config)
when "rdiscount" then return RDiscountParser.new(@config)
else
custom_processor
end
end
|
Rubocop does not allow reader methods to have names starting with `get_`
To ensure compatibility, this check has been disabled on this method
rubocop:disable Naming/AccessorMethodName
|
get_processor
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/converters/markdown.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/converters/markdown.rb
|
Apache-2.0
|
def valid_processors
%w(rdiscount kramdown redcarpet) + third_party_processors
end
|
rubocop:enable Naming/AccessorMethodName
Public: Provides you with a list of processors, the ones we
support internally and the ones that you have provided to us (if you
are not in safe mode.)
|
valid_processors
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/converters/markdown.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/converters/markdown.rb
|
Apache-2.0
|
def third_party_processors
self.class.constants - \
%w(KramdownParser RDiscountParser RedcarpetParser PRIORITIES).map(
&:to_sym
)
end
|
Public: A list of processors that you provide via plugins.
This is really only available if you are not in safe mode, if you are
in safe mode (re: GitHub) then there will be none.
|
third_party_processors
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/converters/markdown.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/converters/markdown.rb
|
Apache-2.0
|
def setup
@config["syntax_highlighter"] ||= highlighter
@config["syntax_highlighter_opts"] ||= {}
@config["syntax_highlighter_opts"]["default_lang"] ||= "plaintext"
@config["syntax_highlighter_opts"]["guess_lang"] = @config["guess_lang"]
@config["coderay"] ||= {} # XXX: Legacy.
modernize_coderay_config
make_accessible
end
|
Setup and normalize the configuration:
* Create Kramdown if it doesn't exist.
* Set syntax_highlighter, detecting enable_coderay and merging
highlighter if none.
* Merge kramdown[coderay] into syntax_highlighter_opts stripping coderay_.
* Make sure `syntax_highlighter_opts` exists.
|
setup
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/converters/markdown/kramdown_parser.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/converters/markdown/kramdown_parser.rb
|
Apache-2.0
|
def hash_for_json(state = nil)
to_h.tap do |hash|
if state && state.depth >= 2
hash["previous"] = collapse_document(hash["previous"]) if hash["previous"]
hash["next"] = collapse_document(hash["next"]) if hash["next"]
end
end
end
|
Generate a Hash for use in generating JSON.
This is useful if fields need to be cleared before the JSON can generate.
state - the JSON::State object which determines the state of current processing.
Returns a Hash ready for JSON generation.
|
hash_for_json
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/drops/document_drop.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/drops/document_drop.rb
|
Apache-2.0
|
def initialize(obj)
@obj = obj
@mutations = {} # only if mutable: true
end
|
Create a new Drop
obj - the Jekyll Site, Collection, or Document required by the
drop.
Returns nothing
|
initialize
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/drops/drop.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/drops/drop.rb
|
Apache-2.0
|
def content_methods
@content_methods ||= (
self.class.instance_methods \
- Jekyll::Drops::Drop.instance_methods \
- NON_CONTENT_METHODS
).map(&:to_s).reject do |method|
method.end_with?("=")
end
end
|
Generates a list of strings which correspond to content getter
methods.
Returns an Array of strings which represent method-specific keys.
|
content_methods
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/drops/drop.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/drops/drop.rb
|
Apache-2.0
|
def key?(key)
return false if key.nil?
return true if self.class.mutable? && @mutations.key?(key)
respond_to?(key) || fallback_data.key?(key)
end
|
Check if key exists in Drop
key - the string key whose value to fetch
Returns true if the given key is present
|
key?
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/drops/drop.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/drops/drop.rb
|
Apache-2.0
|
def keys
(content_methods |
@mutations.keys |
fallback_data.keys).flatten
end
|
Generates a list of keys with user content as their values.
This gathers up the Drop methods and keys of the mutations and
underlying data hashes and performs a set union to ensure a list
of unique keys for the Drop.
Returns an Array of unique keys for content for the Drop.
|
keys
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/drops/drop.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/drops/drop.rb
|
Apache-2.0
|
def to_h
keys.each_with_object({}) do |(key, _), result|
result[key] = self[key]
end
end
|
Generate a Hash representation of the Drop by resolving each key's
value. It includes Drop methods, mutations, and the underlying object's
data. See the documentation for Drop#keys for more.
Returns a Hash with all the keys and values resolved.
|
to_h
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/drops/drop.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/drops/drop.rb
|
Apache-2.0
|
def inspect
JSON.pretty_generate to_h
end
|
Inspect the drop's keys and values through a JSON representation
of its keys and values.
Returns a pretty generation of the hash representation of the Drop.
|
inspect
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/drops/drop.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/drops/drop.rb
|
Apache-2.0
|
def to_json(state = nil)
JSON.generate(hash_for_json(state), state)
end
|
Generate a JSON representation of the Drop.
state - the JSON::State object which determines the state of current processing.
Returns a JSON representation of the Drop in a String.
|
to_json
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/drops/drop.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/drops/drop.rb
|
Apache-2.0
|
def documents
@documents ||= @obj.documents
end
|
`Site#documents` cannot be memoized so that `Site#docs_to_write` can access the
latest state of the attribute.
Since this method will be called after `Site#pre_render` hook,
the `Site#documents` array shouldn't thereafter change and can therefore be
safely memoized to prevent additional computation of `Site#documents`.
|
documents
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/drops/site_drop.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/drops/site_drop.rb
|
Apache-2.0
|
def related_posts
return nil unless @current_document.is_a?(Jekyll::Document)
@current_document.related_posts
end
|
`{{ site.related_posts }}` is how posts can get posts related to
them, either through LSI if it's enabled, or through the most
recent posts.
We should remove this in 4.0 and switch to `{{ post.related_posts }}`.
|
related_posts
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/drops/site_drop.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/drops/site_drop.rb
|
Apache-2.0
|
def date_to_string(date, type = nil, style = nil)
stringify_date(date, "%b", type, style)
end
|
Format a date in short format e.g. "27 Jan 2011".
Ordinal format is also supported, in both the UK
(e.g. "27th Jan 2011") and US ("e.g. Jan 27th, 2011") formats.
UK format is the default.
date - the Time to format.
type - if "ordinal" the returned String will be in ordinal format
style - if "US" the returned String will be in US format.
Otherwise it will be in UK format.
Returns the formatting String.
|
date_to_string
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/filters/date_filters.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/filters/date_filters.rb
|
Apache-2.0
|
def date_to_long_string(date, type = nil, style = nil)
stringify_date(date, "%B", type, style)
end
|
Format a date in long format e.g. "27 January 2011".
Ordinal format is also supported, in both the UK
(e.g. "27th January 2011") and US ("e.g. January 27th, 2011") formats.
UK format is the default.
date - the Time to format.
type - if "ordinal" the returned String will be in ordinal format
style - if "US" the returned String will be in US format.
Otherwise it will be in UK format.
Returns the formatted String.
|
date_to_long_string
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/filters/date_filters.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/filters/date_filters.rb
|
Apache-2.0
|
def date_to_xmlschema(date)
return date if date.to_s.empty?
time(date).xmlschema
end
|
Format a date for use in XML.
date - The Time to format.
Examples
date_to_xmlschema(Time.now)
# => "2011-04-24T20:34:46+08:00"
Returns the formatted String.
|
date_to_xmlschema
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/filters/date_filters.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/filters/date_filters.rb
|
Apache-2.0
|
def date_to_rfc822(date)
return date if date.to_s.empty?
time(date).rfc822
end
|
Format a date according to RFC-822
date - The Time to format.
Examples
date_to_rfc822(Time.now)
# => "Sun, 24 Apr 2011 12:34:46 +0000"
Returns the formatted String.
|
date_to_rfc822
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/filters/date_filters.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/filters/date_filters.rb
|
Apache-2.0
|
def stringify_date(date, month_type, type = nil, style = nil)
return date if date.to_s.empty?
time = time(date)
if type == "ordinal"
day = time.day
ordinal_day = "#{day}#{ordinal(day)}"
return time.strftime("#{month_type} #{ordinal_day}, %Y") if style == "US"
return time.strftime("#{ordinal_day} #{month_type} %Y")
end
time.strftime("%d #{month_type} %Y")
end
|
month_type: Notations that evaluate to 'Month' via `Time#strftime` ("%b", "%B")
type: nil (default) or "ordinal"
style: nil (default) or "US"
Returns a stringified date or the empty input.
|
stringify_date
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/filters/date_filters.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/filters/date_filters.rb
|
Apache-2.0
|
def group_by(input, property)
if groupable?(input)
groups = input.group_by { |item| item_property(item, property).to_s }
grouped_array(groups)
else
input
end
end
|
Group an array of items by a property
input - the inputted Enumerable
property - the property
Returns an array of Hashes, each looking something like this:
{"name" => "larry"
"items" => [...] } # all the items where `property` == "larry"
|
group_by
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/filters/grouping_filters.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/filters/grouping_filters.rb
|
Apache-2.0
|
def group_by_exp(input, variable, expression)
return input unless groupable?(input)
parsed_expr = parse_expression(expression)
@context.stack do
groups = input.group_by do |item|
@context[variable] = item
parsed_expr.render(@context)
end
grouped_array(groups)
end
end
|
Group an array of items by an expression
input - the object array
variable - the variable to assign each item to in the expression
expression -a Liquid comparison expression passed in as a string
Returns the filtered array of objects
|
group_by_exp
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/filters/grouping_filters.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/filters/grouping_filters.rb
|
Apache-2.0
|
def absolute_url(input)
return if input.nil?
input = input.url if input.respond_to?(:url)
return input if Addressable::URI.parse(input.to_s).absolute?
site = @context.registers[:site]
return relative_url(input) if site.config["url"].nil?
Addressable::URI.parse(
site.config["url"].to_s + relative_url(input)
).normalize.to_s
end
|
Produces an absolute URL based on site.url and site.baseurl.
input - the URL to make absolute.
Returns the absolute URL as a String.
|
absolute_url
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/filters/url_filters.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/filters/url_filters.rb
|
Apache-2.0
|
def relative_url(input)
return if input.nil?
input = input.url if input.respond_to?(:url)
return input if Addressable::URI.parse(input.to_s).absolute?
parts = [sanitized_baseurl, input]
Addressable::URI.parse(
parts.compact.map { |part| ensure_leading_slash(part.to_s) }.join
).normalize.to_s
end
|
Produces a URL relative to the domain root based on site.baseurl
unless it is already an absolute url with an authority (host).
input - the URL to make relative to the domain root
Returns a URL relative to the domain root as a String.
|
relative_url
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/filters/url_filters.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/filters/url_filters.rb
|
Apache-2.0
|
def strip_index(input)
return if input.nil? || input.to_s.empty?
input.sub(%r!/index\.html?$!, "/")
end
|
Strips trailing `/index.html` from URLs to create pretty permalinks
input - the URL with a possible `/index.html`
Returns a URL with the trailing `/index.html` removed
|
strip_index
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/filters/url_filters.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/filters/url_filters.rb
|
Apache-2.0
|
def read
site.collections.each_value do |collection|
collection.read unless SPECIAL_COLLECTIONS.include?(collection.label)
end
end
|
Read in all collections specified in the configuration
Returns nothing.
|
read
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/readers/collection_reader.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/readers/collection_reader.rb
|
Apache-2.0
|
def read(dir)
base = site.in_source_dir(dir)
read_data_to(base, @content)
@content
end
|
Read all the files in <dir> and adds them to @content
dir - The String relative path of the directory to read.
Returns @content, a Hash of the .yaml, .yml,
.json, and .csv files in the base directory
|
read
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/readers/data_reader.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/readers/data_reader.rb
|
Apache-2.0
|
def read_data_to(dir, data)
return unless File.directory?(dir) && !@entry_filter.symlink?(dir)
entries = Dir.chdir(dir) do
Dir["*.{yaml,yml,json,csv,tsv}"] + Dir["*"].select { |fn| File.directory?(fn) }
end
entries.each do |entry|
path = @site.in_source_dir(dir, entry)
next if @entry_filter.symlink?(path)
if File.directory?(path)
read_data_to(path, data[sanitize_filename(entry)] = {})
else
key = sanitize_filename(File.basename(entry, ".*"))
data[key] = read_data_file(path)
end
end
end
|
Read and parse all .yaml, .yml, .json, .csv and .tsv
files under <dir> and add them to the <data> variable.
dir - The string absolute path of the directory to read.
data - The variable to which data will be added.
Returns nothing
|
read_data_to
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/readers/data_reader.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/readers/data_reader.rb
|
Apache-2.0
|
def read_data_file(path)
case File.extname(path).downcase
when ".csv"
CSV.read(path,
:headers => true,
:encoding => site.config["encoding"]).map(&:to_hash)
when ".tsv"
CSV.read(path,
:col_sep => "\t",
:headers => true,
:encoding => site.config["encoding"]).map(&:to_hash)
else
SafeYAML.load_file(path)
end
end
|
Determines how to read a data file.
Returns the contents of the data file.
|
read_data_file
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/readers/data_reader.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/readers/data_reader.rb
|
Apache-2.0
|
def read(files)
files.map do |page|
@unfiltered_content << Page.new(@site, @site.source, @dir, page)
end
@unfiltered_content.select { |page| site.publisher.publish?(page) }
end
|
Read all the files in <source>/<dir>/ for Yaml header and create a new Page
object for each file.
dir - The String relative path of the directory to read.
Returns an array of static pages.
|
read
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/readers/page_reader.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/readers/page_reader.rb
|
Apache-2.0
|
def read_drafts(dir)
read_publishable(dir, "_drafts", Document::DATELESS_FILENAME_MATCHER)
end
|
Read all the files in <source>/<dir>/_drafts and create a new
Document object with each one.
dir - The String relative path of the directory to read.
Returns nothing.
|
read_drafts
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/readers/post_reader.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/readers/post_reader.rb
|
Apache-2.0
|
def read_posts(dir)
read_publishable(dir, "_posts", Document::DATE_FILENAME_MATCHER)
end
|
Read all the files in <source>/<dir>/_posts and create a new Document
object with each one.
dir - The String relative path of the directory to read.
Returns nothing.
|
read_posts
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/readers/post_reader.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/readers/post_reader.rb
|
Apache-2.0
|
def read_publishable(dir, magic_dir, matcher)
read_content(dir, magic_dir, matcher).tap { |docs| docs.each(&:read) }
.select do |doc|
if doc.content.valid_encoding?
site.publisher.publish?(doc).tap do |will_publish|
if !will_publish && site.publisher.hidden_in_the_future?(doc)
Jekyll.logger.debug "Skipping:", "#{doc.relative_path} has a future date"
end
end
else
Jekyll.logger.debug "Skipping:", "#{doc.relative_path} is not valid UTF-8"
false
end
end
end
|
Read all the files in <source>/<dir>/<magic_dir> and create a new
Document object with each one insofar as it matches the regexp matcher.
dir - The String relative path of the directory to read.
Returns nothing.
|
read_publishable
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/readers/post_reader.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/readers/post_reader.rb
|
Apache-2.0
|
def read_content(dir, magic_dir, matcher)
@site.reader.get_entries(dir, magic_dir).map do |entry|
next unless entry =~ matcher
path = @site.in_source_dir(File.join(dir, magic_dir, entry))
Document.new(path, {
:site => @site,
:collection => @site.posts,
})
end.reject(&:nil?)
end
|
Read all the content files from <source>/<dir>/magic_dir
and return them with the type klass.
dir - The String relative path of the directory to read.
magic_dir - The String relative directory to <dir>,
looks for content here.
klass - The return type of the content.
Returns klass type of content files
|
read_content
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/readers/post_reader.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/readers/post_reader.rb
|
Apache-2.0
|
def read(files)
files.map do |file|
@unfiltered_content << StaticFile.new(@site, @site.source, @dir, file)
end
@unfiltered_content
end
|
Read all the files in <source>/<dir>/ for Yaml header and create a new Page
object for each file.
dir - The String relative path of the directory to read.
Returns an array of static files.
|
read
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/readers/static_file_reader.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/readers/static_file_reader.rb
|
Apache-2.0
|
def read_file(file, context)
File.read(file, **file_read_opts(context))
end
|
This method allows to modify the file content by inheriting from the class.
|
read_file
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/tags/include.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/tags/include.rb
|
Apache-2.0
|
def post_slug(other)
path = other.basename.split("/")[0...-1].join("/")
if path.nil? || path == ""
other.data["slug"]
else
path + "/" + other.data["slug"]
end
end
|
Construct the directory-aware post slug for a Jekyll::Post
other - the Jekyll::Post
Returns the post slug with the subdirectory (relative to _posts)
|
post_slug
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/tags/post_url.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/tags/post_url.rb
|
Apache-2.0
|
def strip(str)
str.gsub MATCH, ""
end
|
Strip ANSI from the current string. It also strips cursor stuff,
well some of it, and it also strips some other stuff that a lot of
the other ANSI strippers don't.
|
strip
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/utils/ansi.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/utils/ansi.rb
|
Apache-2.0
|
def reset(str = "")
@ansi_reset ||= format("%c[0m", 27)
"#{@ansi_reset}#{str}"
end
|
Reset the color back to the default color so that you do not leak any
colors when you move onto the next line. This is probably normally
used as part of a wrapper so that we don't leak colors.
|
reset
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/utils/ansi.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/utils/ansi.rb
|
Apache-2.0
|
def run(*args)
stdin, stdout, stderr, process = Open3.popen3(*args)
out = stdout.read.strip
err = stderr.read.strip
[stdin, stdout, stderr].each(&:close)
[process.value, out + err]
end
|
Runs a program in a sub-shell.
*args - a list of strings containing the program name and arguments
Returns a Process::Status and a String of output in an array in
that order.
|
run
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/utils/exec.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/utils/exec.rb
|
Apache-2.0
|
def vanilla_windows?
RbConfig::CONFIG["host_os"] =~ %r!mswin|mingw|cygwin!i && \
!proc_version
end
|
--
Allows you to detect "real" Windows, or what we would consider
"real" Windows. That is, that we can pass the basic test and the
/proc/version returns nothing to us.
--
|
vanilla_windows?
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/utils/platforms.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/utils/platforms.rb
|
Apache-2.0
|
def calculate(timezone, now = Time.now)
External.require_with_graceful_fail("tzinfo") unless defined?(TZInfo)
tz = TZInfo::Timezone.get(timezone)
#
# Use period_for_utc and utc_total_offset instead of
# period_for and observed_utc_offset for compatibility with tzinfo v1.
offset = tz.period_for_utc(now.getutc).utc_total_offset
#
# POSIX style definition reverses the offset sign.
# e.g. Eastern Standard Time (EST) that is 5Hrs. to the 'west' of Prime Meridian
# is denoted as:
# EST+5 (or) EST+05:00
# Reference: https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html
sign = offset.positive? ? "-" : "+"
rational_hours = offset.abs.to_r / 3600
hours = rational_hours.to_i
minutes = ((rational_hours - hours) * 60).to_i
#
# Format the hours and minutes as two-digit numbers.
time = format("%<hours>02d:%<minutes>02d", :hours => hours, :minutes => minutes)
Jekyll.logger.debug "Timezone:", "#{timezone} #{sign}#{time}"
#
# Note: The 3-letter-word below doesn't have a particular significance.
"WTZ#{sign}#{time}"
end
|
Public: Calculate the Timezone for Windows when the config file has a defined
'timezone' key.
timezone - the IANA Time Zone specified in "_config.yml"
Returns a string that ultimately re-defines ENV["TZ"] in Windows
|
calculate
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/utils/win_tz.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-3.9.3/lib/jekyll/utils/win_tz.rb
|
Apache-2.0
|
def classes
size < 48 ? "avatar avatar-small" : "avatar"
end
|
See http://primercss.io/avatars/#small-avatars
|
classes
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-avatar-0.7.0/lib/jekyll-avatar.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-avatar-0.7.0/lib/jekyll-avatar.rb
|
Apache-2.0
|
def layout_specified?(document)
document.to_liquid.key? "layout"
end
|
Has the user already specified a default for this layout?
Note: We must use `to_liquid`, and not data, to ensure front matter defaults
|
layout_specified?
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-default-layout-0.1.4/lib/jekyll-default-layout/generator.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-default-layout-0.1.4/lib/jekyll-default-layout/generator.rb
|
Apache-2.0
|
def layout_for(document)
if index?(document) && layout_exists?("home")
"home"
elsif page?(document) && layout_exists?("page")
"page"
elsif post?(document) && layout_exists?("post")
"post"
elsif layout_exists?("default")
"default"
end
end
|
What layout is appropriate for this document, if any
rubocop:disable Metrics/PerceivedComplexity
|
layout_for
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-default-layout-0.1.4/lib/jekyll-default-layout/generator.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-default-layout-0.1.4/lib/jekyll-default-layout/generator.rb
|
Apache-2.0
|
def generate(site)
@site = site
collections.each do |name, meta|
Jekyll.logger.info "Jekyll Feed:", "Generating feed for #{name}"
(meta["categories"] + [nil]).each do |category|
path = feed_path(:collection => name, :category => category)
next if file_exists?(path)
@site.pages << make_page(path, :collection => name, :category => category)
end
end
generate_feed_by_tag if config["tags"] && [email protected]?
end
|
Main plugin action, called by Jekyll-core
|
generate
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-feed-0.15.1/lib/jekyll-feed/generator.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-feed-0.15.1/lib/jekyll-feed/generator.rb
|
Apache-2.0
|
def config
@config ||= @site.config["feed"] || {}
end
|
Returns the plugin's config or an empty hash if not set
|
config
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-feed-0.15.1/lib/jekyll-feed/generator.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-feed-0.15.1/lib/jekyll-feed/generator.rb
|
Apache-2.0
|
def feed_path(collection: "posts", category: nil)
prefix = collection == "posts" ? "/feed" : "/feed/#{collection}"
return "#{prefix}/#{category}.xml" if category
collections.dig(collection, "path") || "#{prefix}.xml"
end
|
Determines the destination path of a given feed
collection - the name of a collection, e.g., "posts"
category - a category within that collection, e.g., "news"
Will return "/feed.xml", or the config-specified default feed for posts
Will return `/feed/category.xml` for post categories
WIll return `/feed/collection.xml` for other collections
Will return `/feed/collection/category.xml` for other collection categories
|
feed_path
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-feed-0.15.1/lib/jekyll-feed/generator.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-feed-0.15.1/lib/jekyll-feed/generator.rb
|
Apache-2.0
|
def collections
return @collections if defined?(@collections)
@collections = if config["collections"].is_a?(Array)
config["collections"].map { |c| [c, {}] }.to_h
elsif config["collections"].is_a?(Hash)
config["collections"]
else
{}
end
@collections = normalize_posts_meta(@collections)
@collections.each_value do |meta|
meta["categories"] = (meta["categories"] || []).to_set
end
@collections
end
|
Returns a hash representing all collections to be processed and their metadata
in the form of { collection_name => { categories = [...], path = "..." } }
|
collections
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-feed-0.15.1/lib/jekyll-feed/generator.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-feed-0.15.1/lib/jekyll-feed/generator.rb
|
Apache-2.0
|
def feed_source_path
@feed_source_path ||= File.expand_path "feed.xml", __dir__
end
|
Path to feed.xml template file
|
feed_source_path
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-feed-0.15.1/lib/jekyll-feed/generator.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-feed-0.15.1/lib/jekyll-feed/generator.rb
|
Apache-2.0
|
def file_exists?(file_path)
File.exist? @site.in_source_dir(file_path)
end
|
Checks if a file already exists in the site source
|
file_exists?
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-feed-0.15.1/lib/jekyll-feed/generator.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-feed-0.15.1/lib/jekyll-feed/generator.rb
|
Apache-2.0
|
def normalize_posts_meta(hash)
hash["posts"] ||= {}
hash["posts"]["path"] ||= config["path"]
hash["posts"]["categories"] ||= config["categories"]
config["path"] ||= hash["posts"]["path"]
hash
end
|
Special case the "posts" collection, which, for ease of use and backwards
compatability, can be configured via top-level keys or directly as a collection
|
normalize_posts_meta
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-feed-0.15.1/lib/jekyll-feed/generator.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-feed-0.15.1/lib/jekyll-feed/generator.rb
|
Apache-2.0
|
def memoize_conditionally
if renderer_cached?
yield
else
dispatcher = "@#{caller_locations(1..1).first.label}".to_sym
if instance_variable_defined?(dispatcher)
instance_variable_get(dispatcher)
else
instance_variable_set(dispatcher, yield)
end
end
end
|
Utility function for compatibility with Jekyll 4.0
|
memoize_conditionally
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-github-metadata-2.13.0/lib/jekyll-github-metadata/edit-link-tag.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-github-metadata-2.13.0/lib/jekyll-github-metadata/edit-link-tag.rb
|
Apache-2.0
|
def ssl?
env_var("SSL") == "true" || test?
end
|
Whether the GitHub instance supports HTTPS
Note: this will be the same as how sites are served in Enterprise,
but may be different from how sites are served on GitHub.com.
See Repository#url_scheme
|
ssl?
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-github-metadata-2.13.0/lib/jekyll-github-metadata/pages.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-github-metadata-2.13.0/lib/jekyll-github-metadata/pages.rb
|
Apache-2.0
|
def url_scheme
if Pages.enterprise?
Pages.scheme
elsif repo.owner == "github" && domain.end_with?(".github.com")
"https"
else
"http"
end
end
|
In enterprise, the site's scheme will be the same as the instance's
In dotcom, this will be `https` for GitHub-owned sites that end with
`.github.com` and will be `http` for all other sites.
Note: This is not the same as *instance*'s scheme, which may differ
|
url_scheme
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-github-metadata-2.13.0/lib/jekyll-github-metadata/repository_compat.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-github-metadata-2.13.0/lib/jekyll-github-metadata/repository_compat.rb
|
Apache-2.0
|
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
|
Public: fetches the repository name with owner to fetch metadata for.
In order of precedence, this method uses:
1. the environment variable $PAGES_REPO_NWO
2. 'repository' variable in the site config
3. 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.
|
nwo
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-github-metadata-2.13.0/lib/jekyll-github-metadata/repository_finder.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-github-metadata-2.13.0/lib/jekyll-github-metadata/repository_finder.rb
|
Apache-2.0
|
def sanitize(resource)
case resource
when Array
resource.map { |item| sanitize(item) }
when Numeric, Time
resource
when FalseClass
false
when TrueClass
true
when NilClass
nil
when String
resource
else
if resource.respond_to?(:to_hash)
sanitize_resource(resource)
else
resource.to_s
end
end
end
|
Sanitize an object.
When the resource is either `false`, `true`, `nil` or a number,
it returns the resource as-is. When the resource is an array,
it maps over the entire array, sanitizing each of its values.
When the resource responds to the #to_hash method, it returns
the value of #sanitize_resource (see below). If none of the
aforementioned conditions are met, the return value of #to_s
is used.
resource - an Object
Returns the sanitized resource.
rubocop:disable Metrics/CyclomaticComplexity
|
sanitize
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-github-metadata-2.13.0/lib/jekyll-github-metadata/sanitizer.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-github-metadata-2.13.0/lib/jekyll-github-metadata/sanitizer.rb
|
Apache-2.0
|
def sanitize_resource(resource)
resource.to_hash.each_with_object({}) do |(k, v), result|
result[k.to_s] = sanitize(v)
result
end
end
|
rubocop:enable Metrics/CyclomaticComplexity
Sanitize the Sawyer Resource or Hash
Note: the object must respond to :to_hash for this to work.
Consider using #sanitize instead of this method directly.
resource - an Object which responds to :to_hash
Returns the sanitized sawyer resource or hash as a hash.
|
sanitize_resource
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-github-metadata-2.13.0/lib/jekyll-github-metadata/sanitizer.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-github-metadata-2.13.0/lib/jekyll-github-metadata/sanitizer.rb
|
Apache-2.0
|
def add_url_and_baseurl_fallbacks!
site.config["url"] ||= Value.new("url", proc { |_c, r| r.url_without_path })
return unless should_set_baseurl?
site.config["baseurl"] = Value.new("baseurl", proc { |_c, r| r.baseurl })
end
|
Set `site.url` and `site.baseurl` if unset.
|
add_url_and_baseurl_fallbacks!
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-github-metadata-2.13.0/lib/jekyll-github-metadata/site_github_munger.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-github-metadata-2.13.0/lib/jekyll-github-metadata/site_github_munger.rb
|
Apache-2.0
|
def should_set_baseurl?
site.config["baseurl"].nil? || site.config["baseurl"] == "/"
end
|
Set the baseurl only if it is `nil` or `/`
Baseurls should never be "/". See http://bit.ly/2s1Srid
|
should_set_baseurl?
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-github-metadata-2.13.0/lib/jekyll-github-metadata/site_github_munger.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-github-metadata-2.13.0/lib/jekyll-github-metadata/site_github_munger.rb
|
Apache-2.0
|
def call_or_value
return value unless value.respond_to?(:call)
case value.arity
when 0
value.call
when 1
value.call(GitHubMetadata.client)
when 2
value.call(GitHubMetadata.client, GitHubMetadata.repository)
else
raise ArgumentError, "Whoa, arity of 0, 1, or 2 please in your procs."
end
end
|
Calls the value Proc with the appropriate number of arguments
or returns the raw value if it's a literal
|
call_or_value
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-github-metadata-2.13.0/lib/jekyll-github-metadata/value.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-github-metadata-2.13.0/lib/jekyll-github-metadata/value.rb
|
Apache-2.0
|
def filter_with_mention(src)
filters[src] ||= HTML::Pipeline.new([
HTML::Pipeline::MentionFilter,
], :base_url => src, :username_pattern => mention_username_pattern)
end
|
rubocop:enable Metrics/AbcSize
Public: Create or fetch the filter for the given {{src}} base URL.
src - the base URL (e.g. https://github.com)
Returns an HTML::Pipeline instance for the given base URL.
|
filter_with_mention
|
ruby
|
collabnix/kubelabs
|
.bundles_cache/ruby/2.6.0/gems/jekyll-mentions-1.6.0/lib/jekyll-mentions.rb
|
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/jekyll-mentions-1.6.0/lib/jekyll-mentions.rb
|
Apache-2.0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.