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 test_url_xxurlxx_placeholder_post urls = [ 'http://127.0.0.1/' ] urls.each do |url| ssrf = SSRFProxy::HTTP.new(url: url, method: 'POST', post_data: 'xxURLxx') assert valid_ssrf?(ssrf) end end
@note test xxURLxx placeholder with POST method
test_url_xxurlxx_placeholder_post
ruby
bcoles/ssrf_proxy
test/unit/test_http.rb
https://github.com/bcoles/ssrf_proxy/blob/master/test/unit/test_http.rb
MIT
def test_url_xxurlxx_invalid (0..255).each do |i| buf = [i.to_s(16)].pack('H*') begin opts = SSRF_DEFAULT_OPTS.dup opts[:url] = "http://127.0.0.1/file.ext?query1=a&query2=xx#{buf}URLxx" ssrf = SSRFProxy::HTTP.new(opts) rescue SSRFProxy::HTTP::Error::NoUrlPlaceholder, SSRFProxy::HTTP::Error::InvalidSsrfRequest end assert_nil(ssrf) unless buf == 'x' end end
@note test the xxURLxx placeholder regex parser
test_url_xxurlxx_invalid
ruby
bcoles/ssrf_proxy
test/unit/test_http.rb
https://github.com/bcoles/ssrf_proxy/blob/master/test/unit/test_http.rb
MIT
def test_url_ssl opts = SSRF_DEFAULT_OPTS.dup opts[:url] = 'http://127.0.0.1/xxURLxx' opts[:ssl] = true ssrf = SSRFProxy::HTTP.new(opts) assert('https', ssrf.url.scheme) assert(80, ssrf.url.port) end
@note test force SSL URL scheme
test_url_ssl
ruby
bcoles/ssrf_proxy
test/unit/test_http.rb
https://github.com/bcoles/ssrf_proxy/blob/master/test/unit/test_http.rb
MIT
def test_send_request_nil url = 'http://127.0.0.1/xxURLxx' ssrf = SSRFProxy::HTTP.new(url: url) assert valid_ssrf?(ssrf) assert_raises SSRFProxy::HTTP::Error::InvalidClientRequest do ssrf.send_request(nil) end end
@note test send_request method with nil request
test_send_request_nil
ruby
bcoles/ssrf_proxy
test/unit/test_http.rb
https://github.com/bcoles/ssrf_proxy/blob/master/test/unit/test_http.rb
MIT
def test_send_request_invalid_url opts = SSRF_DEFAULT_OPTS.dup opts[:url] = 'http://127.0.0.1/xxURLxx' ssrf = SSRFProxy::HTTP.new(opts) assert valid_ssrf?(ssrf) urls = [ 'http://', 'ftp://', 'smb://', '://z', '://z:80', [], [[[]]], {}, {{}=>{}}, '', nil, 0x00, false, true, '://127.0.0.1/file.ext?query1=a&query2=b' ] urls.each do |url| assert_raises SSRFProxy::HTTP::Error::InvalidClientRequest do ssrf.send_request("GET #{url} HTTP/1.0\n\n") end end end
@note test send_request method with invalid URL
test_send_request_invalid_url
ruby
bcoles/ssrf_proxy
test/unit/test_http.rb
https://github.com/bcoles/ssrf_proxy/blob/master/test/unit/test_http.rb
MIT
def test_send_request_no_host_http1_0 url = 'http://127.0.0.1/xxURLxx' ssrf = SSRFProxy::HTTP.new(url: url) assert valid_ssrf?(ssrf) assert_raises SSRFProxy::HTTP::Error::InvalidClientRequest do ssrf.send_request("GET / HTTP/1.0\n\n") end end
@note test send_request method with no host (HTTP/1.0)
test_send_request_no_host_http1_0
ruby
bcoles/ssrf_proxy
test/unit/test_http.rb
https://github.com/bcoles/ssrf_proxy/blob/master/test/unit/test_http.rb
MIT
def test_send_request_no_host_http1_1 url = 'http://127.0.0.1/xxURLxx' ssrf = SSRFProxy::HTTP.new(url: url) assert valid_ssrf?(ssrf) assert_raises SSRFProxy::HTTP::Error::InvalidClientRequest do ssrf.send_request("GET / HTTP/1.1\n\n") end end
@note test send_request method with no host (HTTP/1.1)
test_send_request_no_host_http1_1
ruby
bcoles/ssrf_proxy
test/unit/test_http.rb
https://github.com/bcoles/ssrf_proxy/blob/master/test/unit/test_http.rb
MIT
def test_send_request_no_path url = 'http://127.0.0.1/xxURLxx' ssrf = SSRFProxy::HTTP.new(url: url) assert valid_ssrf?(ssrf) assert_raises SSRFProxy::HTTP::Error::InvalidClientRequest do ssrf.send_request("GET http://127.0.0.1 HTTP/1.1\n\n") end end
@note test send_request method with no path
test_send_request_no_path
ruby
bcoles/ssrf_proxy
test/unit/test_http.rb
https://github.com/bcoles/ssrf_proxy/blob/master/test/unit/test_http.rb
MIT
def test_send_request_invalid_method url = 'http://127.0.0.1/xxURLxx' ssrf = SSRFProxy::HTTP.new(url: url) assert valid_ssrf?(ssrf) assert_raises SSRFProxy::HTTP::Error::InvalidClientRequest do method = ('a'..'z').to_a.sample(8).join.to_s ssrf.send_request("#{method} / HTTP/1.1\nHost: 127.0.0.1\n\n") end end
@note test send_request method with invalid HTTP verb
test_send_request_invalid_method
ruby
bcoles/ssrf_proxy
test/unit/test_http.rb
https://github.com/bcoles/ssrf_proxy/blob/master/test/unit/test_http.rb
MIT
def test_send_request_body_with_no_content_length url = 'http://127.0.0.1/xxURLxx' ssrf = SSRFProxy::HTTP.new(url: url) assert valid_ssrf?(ssrf) assert_raises SSRFProxy::HTTP::Error::InvalidClientRequest do body = ('a'..'z').to_a.sample(8).join.to_s ssrf.send_request("POST / HTTP/1.1\nHost: 127.0.0.1\n\n#{body}") end end
@note test send_request method with a request body but no Content-Length header
test_send_request_body_with_no_content_length
ruby
bcoles/ssrf_proxy
test/unit/test_http.rb
https://github.com/bcoles/ssrf_proxy/blob/master/test/unit/test_http.rb
MIT
def test_send_request_upgrade_websocket_header opts = SSRF_DEFAULT_OPTS.dup opts[:url] = 'http://127.0.0.1/xxURLxx' assert_raises SSRFProxy::HTTP::Error::InvalidClientRequest do ssrf = SSRFProxy::HTTP.new(opts) assert valid_ssrf?(ssrf) ssrf.send_request("GET / HTTP/1.1\nHost: 127.0.0.1\nUpgrade: WebSocket\n\n") end end
@note test send_request method with upgrade WebSocket header
test_send_request_upgrade_websocket_header
ruby
bcoles/ssrf_proxy
test/unit/test_http.rb
https://github.com/bcoles/ssrf_proxy/blob/master/test/unit/test_http.rb
MIT
def test_send_uri_invalid_url opts = SSRF_DEFAULT_OPTS.dup opts[:url] = 'http://127.0.0.1/xxURLxx' assert_raises SSRFProxy::HTTP::Error::InvalidClientRequest do ssrf = SSRFProxy::HTTP.new(opts) assert valid_ssrf?(ssrf) ssrf.send_uri(nil) ssrf.send_uri([]) ssrf.send_uri({}) ssrf.send_uri([[]]) ssrf.send_uri([{}]) end end
@note test send_uri method with invalid URL
test_send_uri_invalid_url
ruby
bcoles/ssrf_proxy
test/unit/test_http.rb
https://github.com/bcoles/ssrf_proxy/blob/master/test/unit/test_http.rb
MIT
def test_send_uri_invalid_forwarded_method opts = SSRF_DEFAULT_OPTS.dup opts[:url] = 'http://127.0.0.1/xxURLxx' opts[:forward_method] = true assert_raises SSRFProxy::HTTP::Error::InvalidClientRequest do ssrf = SSRFProxy::HTTP.new(opts) assert valid_ssrf?(ssrf) method = ('a'..'z').to_a.sample(8).join.to_s ssrf.send_uri('http://127.0.0.1/', method: method) end end
@note test send_uri method with invalid forwarded HTTP verb
test_send_uri_invalid_forwarded_method
ruby
bcoles/ssrf_proxy
test/unit/test_http.rb
https://github.com/bcoles/ssrf_proxy/blob/master/test/unit/test_http.rb
MIT
def test_send_uri_invalid_headers opts = SSRF_DEFAULT_OPTS.dup opts[:url] = 'http://127.0.0.1/xxURLxx' ssrf = SSRFProxy::HTTP.new(opts) assert valid_ssrf?(ssrf) assert_raises SSRFProxy::HTTP::Error::InvalidClientRequest do junk = ('a'..'z').to_a.sample(8).join.to_s headers = { junk => nil } ssrf.send_uri('http://127.0.0.1/', headers: headers) end assert_raises SSRFProxy::HTTP::Error::InvalidClientRequest do junk = ('a'..'z').to_a.sample(8).join.to_s headers = { junk => {} } ssrf.send_uri('http://127.0.0.1/', headers: headers) end end
@note test send_uri method with invalid headers
test_send_uri_invalid_headers
ruby
bcoles/ssrf_proxy
test/unit/test_http.rb
https://github.com/bcoles/ssrf_proxy/blob/master/test/unit/test_http.rb
MIT
def test_send_uri_upgrade_websocket_header opts = SSRF_DEFAULT_OPTS.dup opts[:url] = 'http://127.0.0.1/xxURLxx' assert_raises SSRFProxy::HTTP::Error::InvalidClientRequest do ssrf = SSRFProxy::HTTP.new(opts) assert valid_ssrf?(ssrf) headers = { 'Upgrade' => 'WebSocket' } ssrf.send_uri('http://127.0.0.1/', headers: headers) end end
@note test send_uri method with upgrade WebSocket header
test_send_uri_upgrade_websocket_header
ruby
bcoles/ssrf_proxy
test/unit/test_http.rb
https://github.com/bcoles/ssrf_proxy/blob/master/test/unit/test_http.rb
MIT
def test_invalid_ssrf server_opts = SERVER_DEFAULT_OPTS.dup assert_raises SSRFProxy::Server::Error::InvalidSsrf do ssrf = nil SSRFProxy::Server.new(ssrf, server_opts['interface'], server_opts['port']) end end
@note test server with invalid SSRF
test_invalid_ssrf
ruby
bcoles/ssrf_proxy
test/unit/test_server.rb
https://github.com/bcoles/ssrf_proxy/blob/master/test/unit/test_server.rb
MIT
def test_proxy_recursion server_opts = SERVER_DEFAULT_OPTS.dup ssrf_opts = SSRF_DEFAULT_OPTS.dup ssrf_opts[:url] = 'http://127.0.0.1/xxURLxx' ssrf_opts[:proxy] = "http://#{server_opts['interface']}:#{server_opts['port']}" ssrf = SSRFProxy::HTTP.new(ssrf_opts) ssrf.logger.level = ::Logger::WARN assert_raises SSRFProxy::Server::Error::ProxyRecursion do SSRFProxy::Server.new(ssrf, server_opts['interface'], server_opts['port']) end end
@note test server with proxy recursion
test_proxy_recursion
ruby
bcoles/ssrf_proxy
test/unit/test_server.rb
https://github.com/bcoles/ssrf_proxy/blob/master/test/unit/test_server.rb
MIT
def always_liquid(content) Liquid::Template.error_mode = :warn Liquid::Template.parse(content, :line_numbers => true).render( "author" => "John Doe", "title" => "FooBar" ) end
Mimic how Jekyll's LiquidRenderer would process a non-static file, with some dummy payload
always_liquid
ruby
jekyll/jekyll
benchmark/conditional_liquid.rb
https://github.com/jekyll/jekyll/blob/master/benchmark/conditional_liquid.rb
MIT
def conditional_liquid(content) return content if content.nil? || content.empty? return content unless content.include?("{%") || content.include?("{{") always_liquid(content) end
Mimic how the proposed change would first execute a couple of checks and proceed to process with Liquid if necessary
conditional_liquid
ruby
jekyll/jekyll
benchmark/conditional_liquid.rb
https://github.com/jekyll/jekyll/blob/master/benchmark/conditional_liquid.rb
MIT
def require_all(path) glob = File.join(__dir__, path, "*.rb") Dir[glob].sort.each do |f| require f end end
Require all of the Ruby files in the given directory. path - The String relative path from here to the directory. Returns nothing.
require_all
ruby
jekyll/jekyll
lib/jekyll.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll.rb
MIT
def env ENV["JEKYLL_ENV"] || "development" end
Public: Tells you which Jekyll environment you are building in so you can skip tasks if you need to. This is useful when doing expensive compression tasks on css and images and allows you to skip that when working in development.
env
ruby
jekyll/jekyll
lib/jekyll.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll.rb
MIT
def configuration(override = {}) config = Configuration.new override = Configuration[override].stringify_keys unless override.delete("skip_config_files") config = config.read_config_files(config.config_files(override)) end # Merge DEFAULTS < _config.yml < override Configuration.from(Utils.deep_merge_hashes(config, override)).tap do |obj| set_timezone(obj["timezone"]) if obj["timezone"] end end
Public: Generate a Jekyll configuration Hash by merging the default options with anything in _config.yml, and adding the given options on top. override - A Hash of config directives that override any options in both the defaults and the config file. See Jekyll::Configuration::DEFAULTS for a list of option names and their defaults. Returns the final configuration Hash.
configuration
ruby
jekyll/jekyll
lib/jekyll.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll.rb
MIT
def set_timezone(timezone) ENV["TZ"] = if Utils::Platforms.really_windows? Utils::WinTZ.calculate(timezone) else timezone end end
Public: Set the TZ environment variable to use the timezone specified timezone - the IANA Time Zone Returns nothing rubocop:disable Naming/AccessorMethodName
set_timezone
ruby
jekyll/jekyll
lib/jekyll.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll.rb
MIT
def logger @logger ||= LogAdapter.new(Stevenson.new, (ENV["JEKYLL_LOG_LEVEL"] || :info).to_sym) end
rubocop:enable Naming/AccessorMethodName Public: Fetch the logger instance for this Jekyll process. Returns the LogAdapter instance.
logger
ruby
jekyll/jekyll
lib/jekyll.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll.rb
MIT
def sites @sites ||= [] end
Public: An array of sites Returns the Jekyll sites created.
sites
ruby
jekyll/jekyll
lib/jekyll.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll.rb
MIT
def sanitized_path(base_directory, questionable_path) return base_directory if base_directory.eql?(questionable_path) return base_directory if questionable_path.nil? +Jekyll::PathManager.sanitized_path(base_directory, questionable_path) end
Public: Ensures the questionable path is prefixed with the base directory and prepends the questionable path with the base directory if false. base_directory - the directory with which to prefix the questionable path questionable_path - the path we're unsure about, and want prefixed Returns the sanitized path.
sanitized_path
ruby
jekyll/jekyll
lib/jekyll.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll.rb
MIT
def disable_disk_cache! @disk_cache_enabled = false end
Disable Marshaling cached items to disk
disable_disk_cache!
ruby
jekyll/jekyll
lib/jekyll/cache.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/cache.rb
MIT
def clear_if_config_changed(config) config = config.inspect cache = Jekyll::Cache.new "Jekyll::Cache" return if cache.key?("config") && cache["config"] == config clear cache = Jekyll::Cache.new "Jekyll::Cache" cache["config"] = config nil end
Compare the current config to the cached config If they are different, clear all caches Returns nothing.
clear_if_config_changed
ruby
jekyll/jekyll
lib/jekyll/cache.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/cache.rb
MIT
def delete_cache_files FileUtils.rm_rf(@cache_dir) if disk_cache_enabled end
Delete all cached items from all caches Returns nothing.
delete_cache_files
ruby
jekyll/jekyll
lib/jekyll/cache.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/cache.rb
MIT
def initialize(name) @cache = Jekyll::Cache.base_cache[name] ||= {} @name = name.gsub(%r![^\w\s-]!, "-") end
Get an existing named cache, or create a new one if none exists name - name of the cache Returns nothing.
initialize
ruby
jekyll/jekyll
lib/jekyll/cache.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/cache.rb
MIT
def getset(key) self[key] rescue StandardError value = yield self[key] = value value end
If an item already exists in the cache, retrieve it. Else execute code block, and add the result to the cache, and return that result.
getset
ruby
jekyll/jekyll
lib/jekyll/cache.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/cache.rb
MIT
def delete(key) @cache.delete(key) File.delete(path_to(hash(key))) if disk_cache_enabled? end
Remove one particular item from the cache Returns nothing.
delete
ruby
jekyll/jekyll
lib/jekyll/cache.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/cache.rb
MIT
def key?(key) # First, check if item is already cached in memory return true if @cache.key?(key) # Otherwise, it might be cached on disk # but we should not consider the disk cache if it is disabled return false unless disk_cache_enabled? path = path_to(hash(key)) File.file?(path) && File.readable?(path) end
Check if `key` already exists in this cache Returns true if key exists in the cache, false otherwise
key?
ruby
jekyll/jekyll
lib/jekyll/cache.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/cache.rb
MIT
def path_to(hash = nil) @base_dir ||= File.join(Jekyll::Cache.cache_dir, @name) return @base_dir if hash.nil? File.join(@base_dir, hash[0..1], hash[2..-1]).freeze end
Given a hashed key, return the path to where this item would be saved on disk.
path_to
ruby
jekyll/jekyll
lib/jekyll/cache.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/cache.rb
MIT
def delete_cache_files FileUtils.rm_rf(path_to) if disk_cache_enabled? end
Remove all this caches items from disk Returns nothing.
delete_cache_files
ruby
jekyll/jekyll
lib/jekyll/cache.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/cache.rb
MIT
def load(path) raise unless disk_cache_enabled? cached_file = File.open(path, "rb") value = Marshal.load(cached_file) cached_file.close value end
Load `path` from disk and return the result. This MUST NEVER be called in Safe Mode rubocop:disable Security/MarshalLoad
load
ruby
jekyll/jekyll
lib/jekyll/cache.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/cache.rb
MIT
def dump(path, value) return unless disk_cache_enabled? FileUtils.mkdir_p(File.dirname(path)) File.open(path, "wb") do |cached_file| Marshal.dump(value, cached_file) end end
rubocop:enable Security/MarshalLoad Given a path and a value, save value to disk at path. This should NEVER be called in Safe Mode Returns nothing.
dump
ruby
jekyll/jekyll
lib/jekyll/cache.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/cache.rb
MIT
def cleanup! FileUtils.rm_rf(obsolete_files) FileUtils.rm_rf(metadata_file) unless @site.incremental? end
Cleans up the site's destination directory
cleanup!
ruby
jekyll/jekyll
lib/jekyll/cleaner.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/cleaner.rb
MIT
def obsolete_files out = (existing_files - new_files - new_dirs + replaced_files).to_a Jekyll::Hooks.trigger :clean, :on_obsolete, out out end
Private: The list of files and directories to be deleted during cleanup process Returns an Array of the file and directory paths
obsolete_files
ruby
jekyll/jekyll
lib/jekyll/cleaner.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/cleaner.rb
MIT
def existing_files files = Set.new regex = keep_file_regex dirs = keep_dirs Utils.safe_glob(site.in_dest_dir, ["**", "*"], File::FNM_DOTMATCH).each do |file| next if HIDDEN_FILE_REGEX.match?(file) || regex.match?(file) || dirs.include?(file) files << file end files end
Private: The list of existing files, apart from those included in keep_files and hidden files. Returns a Set with the file paths
existing_files
ruby
jekyll/jekyll
lib/jekyll/cleaner.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/cleaner.rb
MIT
def new_files @new_files ||= Set.new.tap do |files| site.each_site_file { |item| files << item.destination(site.dest) } end end
Private: The list of files to be created when site is built. Returns a Set with the file paths
new_files
ruby
jekyll/jekyll
lib/jekyll/cleaner.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/cleaner.rb
MIT
def new_dirs @new_dirs ||= new_files.flat_map { |file| parent_dirs(file) }.to_set end
Private: The list of directories to be created when site is built. These are the parent directories of the files in #new_files. Returns a Set with the directory paths
new_dirs
ruby
jekyll/jekyll
lib/jekyll/cleaner.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/cleaner.rb
MIT
def parent_dirs(file) parent_dir = File.dirname(file) if parent_dir == site.dest [] else parent_dirs(parent_dir).unshift(parent_dir) end end
Private: The list of parent directories of a given file Returns an Array with the directory paths
parent_dirs
ruby
jekyll/jekyll
lib/jekyll/cleaner.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/cleaner.rb
MIT
def replaced_files new_dirs.select { |dir| File.file?(dir) }.to_set end
Private: The list of existing files that will be replaced by a directory during build Returns a Set with the file paths
replaced_files
ruby
jekyll/jekyll
lib/jekyll/cleaner.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/cleaner.rb
MIT
def keep_dirs site.keep_files.flat_map { |file| parent_dirs(site.in_dest_dir(file)) }.to_set end
Private: The list of directories that need to be kept because they are parent directories of files specified in keep_files Returns a Set with the directory paths
keep_dirs
ruby
jekyll/jekyll
lib/jekyll/cleaner.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/cleaner.rb
MIT
def initialize(site, label) @site = site @label = sanitize_label(label) @metadata = extract_metadata end
Create a new Collection. site - the site to which this collection belongs. label - the name of the collection Returns nothing.
initialize
ruby
jekyll/jekyll
lib/jekyll/collection.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/collection.rb
MIT
def docs @docs ||= [] end
Fetch the Documents in this collection. Defaults to an empty array if no documents have been read in. Returns an array of Jekyll::Document objects.
docs
ruby
jekyll/jekyll
lib/jekyll/collection.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/collection.rb
MIT
def respond_to_missing?(method, include_private = false) docs.respond_to?(method.to_sym, include_private) || super end
Override of normal respond_to? to match method_missing's logic for looking in @data.
respond_to_missing?
ruby
jekyll/jekyll
lib/jekyll/collection.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/collection.rb
MIT
def method_missing(method, *args, &blck) if docs.respond_to?(method.to_sym) Jekyll.logger.warn "Deprecation:", "#{label}.#{method} should be changed to #{label}.docs.#{method}." Jekyll.logger.warn "", "Called by #{caller(0..0)}." docs.public_send(method.to_sym, *args, &blck) else super end end
Override of method_missing to check in @data for the key.
method_missing
ruby
jekyll/jekyll
lib/jekyll/collection.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/collection.rb
MIT
def files @files ||= [] end
Fetch the static files in this collection. Defaults to an empty array if no static files have been read in. Returns an array of Jekyll::StaticFile objects.
files
ruby
jekyll/jekyll
lib/jekyll/collection.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/collection.rb
MIT
def read filtered_entries.each do |file_path| full_path = collection_dir(file_path) next if File.directory?(full_path) if Utils.has_yaml_header? full_path read_document(full_path) else read_static_file(file_path, full_path) end end site.static_files.concat(files) unless files.empty? sort_docs! end
Read the allowed documents into the collection's array of docs. Returns the sorted array of docs.
read
ruby
jekyll/jekyll
lib/jekyll/collection.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/collection.rb
MIT
def entries return [] unless exists? @entries ||= begin collection_dir_slash = "#{collection_dir}/" Utils.safe_glob(collection_dir, ["**", "*"], File::FNM_DOTMATCH).map do |entry| entry[collection_dir_slash] = "" entry end end end
All the entries in this collection. Returns an Array of file paths to the documents in this collection relative to the collection's directory
entries
ruby
jekyll/jekyll
lib/jekyll/collection.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/collection.rb
MIT
def filtered_entries return [] unless exists? @filtered_entries ||= Dir.chdir(directory) do entry_filter.filter(entries).reject do |f| path = collection_dir(f) File.directory?(path) || entry_filter.symlink?(f) end end end
Filtered version of the entries in this collection. See `Jekyll::EntryFilter#filter` for more information. Returns a list of filtered entry paths.
filtered_entries
ruby
jekyll/jekyll
lib/jekyll/collection.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/collection.rb
MIT
def relative_directory @relative_directory ||= "_#{label}" end
The directory for this Collection, relative to the site source or the directory containing the collection. Returns a String containing the directory name where the collection is stored on the filesystem.
relative_directory
ruby
jekyll/jekyll
lib/jekyll/collection.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/collection.rb
MIT
def directory @directory ||= site.in_source_dir( File.join(container, relative_directory) ) end
The full path to the directory containing the collection. Returns a String containing th directory name where the collection is stored on the filesystem.
directory
ruby
jekyll/jekyll
lib/jekyll/collection.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/collection.rb
MIT
def collection_dir(*files) return directory if files.empty? site.in_source_dir(container, relative_directory, *files) end
The full path to the directory containing the collection, with optional subpaths. *files - (optional) any other path pieces relative to the directory to append to the path Returns a String containing th directory name where the collection is stored on the filesystem.
collection_dir
ruby
jekyll/jekyll
lib/jekyll/collection.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/collection.rb
MIT
def exists? File.directory?(directory) && !entry_filter.symlink?(directory) end
Checks whether the directory "exists" for this collection. The directory must exist on the filesystem and must not be a symlink if in safe mode. Returns false if the directory doesn't exist or if it's a symlink and we're in safe mode.
exists?
ruby
jekyll/jekyll
lib/jekyll/collection.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/collection.rb
MIT
def entry_filter @entry_filter ||= Jekyll::EntryFilter.new(site, relative_directory) end
The entry filter for this collection. Creates an instance of Jekyll::EntryFilter. Returns the instance of Jekyll::EntryFilter for this collection.
entry_filter
ruby
jekyll/jekyll
lib/jekyll/collection.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/collection.rb
MIT
def inspect "#<#{self.class} @label=#{label} docs=#{docs}>" end
An inspect string. Returns the inspect string
inspect
ruby
jekyll/jekyll
lib/jekyll/collection.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/collection.rb
MIT
def sanitize_label(label) label.gsub(%r![^a-z0-9_\-.]!i, "") end
Produce a sanitized label name Label names may not contain anything but alphanumeric characters, underscores, and hyphens. label - the possibly-unsafe label Returns a sanitized version of the label.
sanitize_label
ruby
jekyll/jekyll
lib/jekyll/collection.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/collection.rb
MIT
def to_liquid Drops::CollectionDrop.new self end
Produce a representation of this Collection for use in Liquid. Exposes two attributes: - label - docs Returns a representation of this collection for use in Liquid.
to_liquid
ruby
jekyll/jekyll
lib/jekyll/collection.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/collection.rb
MIT
def write? !!metadata.fetch("output", false) end
Whether the collection's documents ought to be written as individual files in the output. Returns true if the 'write' metadata is true, false otherwise.
write?
ruby
jekyll/jekyll
lib/jekyll/collection.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/collection.rb
MIT
def url_template @url_template ||= metadata.fetch("permalink") do Utils.add_permalink_suffix("/:collection/:path", site.permalink_style) end end
The URL template to render collection's documents at. Returns the URL template to render collection's documents at.
url_template
ruby
jekyll/jekyll
lib/jekyll/collection.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/collection.rb
MIT
def extract_metadata if site.config["collections"].is_a?(Hash) site.config["collections"][label] || {} else {} end end
Extract options for this collection from the site configuration. Returns the metadata for this collection
extract_metadata
ruby
jekyll/jekyll
lib/jekyll/collection.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/collection.rb
MIT
def sort_docs_by_key! meta_key = metadata["sort_by"] # Modify `docs` array to cache document's property along with the Document instance docs.map! { |doc| [doc.data[meta_key], doc] }.sort! do |apples, olives| order = determine_sort_order(meta_key, apples, olives) # Fall back to `Document#<=>` if the properties were equal or were non-sortable # Otherwise continue with current sort-order if order.nil? || order.zero? apples[-1] <=> olives[-1] else order end # Finally restore the `docs` array with just the Document objects themselves end.map!(&:last) end
A custom sort function based on Schwartzian transform Refer https://byparker.com/blog/2017/schwartzian-transform-faster-sorting/ for details
sort_docs_by_key!
ruby
jekyll/jekyll
lib/jekyll/collection.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/collection.rb
MIT
def rearrange_docs! docs_table = {} custom_order = {} # pre-sort to normalize default array across platforms and then proceed to create a Hash # from that sorted array. docs.sort.each do |doc| docs_table[doc.relative_path] = doc end metadata["order"].each do |entry| custom_order[File.join(relative_directory, entry)] = nil end result = Jekyll::Utils.deep_merge_hashes(custom_order, docs_table).values result.compact! self.docs = result end
Rearrange documents within the `docs` array as listed in the `metadata["order"]` array. Involves converting the two arrays into hashes based on relative_paths as keys first, then merging them to remove duplicates and finally retrieving the Document instances from the merged array.
rearrange_docs!
ruby
jekyll/jekyll
lib/jekyll/collection.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/collection.rb
MIT
def subclasses @subclasses ||= [] end
A list of subclasses of Jekyll::Command
subclasses
ruby
jekyll/jekyll
lib/jekyll/command.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/command.rb
MIT
def inherited(base) subclasses << base super(base) end
Keep a list of subclasses of Jekyll::Command every time it's inherited Called automatically. base - the subclass Returns nothing
inherited
ruby
jekyll/jekyll
lib/jekyll/command.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/command.rb
MIT
def process_site(site) site.process rescue Jekyll::Errors::FatalException => e Jekyll.logger.error "ERROR:", "YOUR SITE COULD NOT BE BUILT:" Jekyll.logger.error "", "------------------------------------" Jekyll.logger.error "", e.message exit(1) end
Run Site#process and catch errors site - the Jekyll::Site object Returns nothing
process_site
ruby
jekyll/jekyll
lib/jekyll/command.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/command.rb
MIT
def configuration_from_options(options) return options if options.is_a?(Jekyll::Configuration) Jekyll.configuration(options) end
Create a full Jekyll configuration with the options passed in as overrides options - the configuration overrides Returns a full Jekyll configuration
configuration_from_options
ruby
jekyll/jekyll
lib/jekyll/command.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/command.rb
MIT
def add_build_options(cmd) cmd.option "config", "--config CONFIG_FILE[,CONFIG_FILE2,...]", Array, "Custom configuration file" cmd.option "destination", "-d", "--destination DESTINATION", "The current folder will be generated into DESTINATION" cmd.option "source", "-s", "--source SOURCE", "Custom source directory" cmd.option "future", "--future", "Publishes posts with a future date" cmd.option "limit_posts", "--limit_posts MAX_POSTS", Integer, "Limits the number of posts to parse and publish" cmd.option "watch", "-w", "--[no-]watch", "Watch for changes and rebuild" cmd.option "baseurl", "-b", "--baseurl URL", "Serve the website from the given base URL" cmd.option "force_polling", "--force_polling", "Force watch to use polling" cmd.option "lsi", "--lsi", "Use LSI for improved related posts" cmd.option "show_drafts", "-D", "--drafts", "Render posts in the _drafts folder" cmd.option "unpublished", "--unpublished", "Render posts that were marked as unpublished" cmd.option "disable_disk_cache", "--disable-disk-cache", "Disable caching to disk in non-safe mode" cmd.option "quiet", "-q", "--quiet", "Silence output." cmd.option "verbose", "-V", "--verbose", "Print verbose output." cmd.option "incremental", "-I", "--incremental", "Enable incremental rebuild." cmd.option "strict_front_matter", "--strict_front_matter", "Fail if errors are present in front matter" end
Add common options to a command for building configuration cmd - the Jekyll::Command to add these options to Returns nothing rubocop:disable Metrics/MethodLength
add_build_options
ruby
jekyll/jekyll
lib/jekyll/command.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/command.rb
MIT
def process_with_graceful_fail(cmd, options, *klass) klass.each { |k| k.process(options) if k.respond_to?(:process) } rescue Exception => e raise e if cmd.trace msg = " Please append `--trace` to the `#{cmd.name}` command " dashes = "-" * msg.length Jekyll.logger.error "", dashes Jekyll.logger.error "Jekyll #{Jekyll::VERSION} ", msg Jekyll.logger.error "", " for any additional information or backtrace. " Jekyll.logger.abort_with "", dashes end
rubocop:enable Metrics/MethodLength Run ::process method in a given set of Jekyll::Command subclasses and suggest re-running the associated command with --trace switch to obtain any additional information or backtrace regarding the encountered Exception. cmd - the Jekyll::Command to be handled options - configuration overrides klass - an array of Jekyll::Command subclasses associated with the command Note that all exceptions are rescued.. rubocop: disable Lint/RescueException
process_with_graceful_fail
ruby
jekyll/jekyll
lib/jekyll/command.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/command.rb
MIT
def from(user_config) Utils.deep_merge_hashes(DEFAULTS, Configuration[user_config].stringify_keys) .add_default_collections.add_default_excludes end
Static: Produce a Configuration ready for use in a Site. It takes the input, fills in the defaults where values do not exist. user_config - a Hash or Configuration of overrides. Returns a Configuration filled with defaults.
from
ruby
jekyll/jekyll
lib/jekyll/configuration.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/configuration.rb
MIT
def stringify_keys each_with_object({}) { |(k, v), hsh| hsh[k.to_s] = v } end
Public: Turn all keys into string Return a copy of the hash where all its keys are strings
stringify_keys
ruby
jekyll/jekyll
lib/jekyll/configuration.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/configuration.rb
MIT
def source(override) get_config_value_with_override("source", override) end
Public: Directory of the Jekyll source folder override - the command-line options hash Returns the path to the Jekyll source directory
source
ruby
jekyll/jekyll
lib/jekyll/configuration.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/configuration.rb
MIT
def config_files(override) # Adjust verbosity quickly Jekyll.logger.adjust_verbosity( :quiet => quiet?(override), :verbose => verbose?(override) ) # Get configuration from <source>/_config.yml or <source>/<config_file> config_files = override["config"] if config_files.to_s.empty? default = %w(yml yaml toml).find(-> { "yml" }) do |ext| File.exist?(Jekyll.sanitized_path(source(override), "_config.#{ext}")) end config_files = Jekyll.sanitized_path(source(override), "_config.#{default}") @default_config_file = true end Array(config_files) end
Public: Generate list of configuration files from the override override - the command-line options hash Returns an Array of config files
config_files
ruby
jekyll/jekyll
lib/jekyll/configuration.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/configuration.rb
MIT
def read_config_file(file) file = File.expand_path(file) next_config = safe_load_file(file) unless next_config.is_a?(Hash) raise ArgumentError, "Configuration file: (INVALID) #{file}".yellow end Jekyll.logger.info "Configuration file:", file next_config rescue SystemCallError if @default_config_file ||= nil Jekyll.logger.warn "Configuration file:", "none" {} else Jekyll.logger.error "Fatal:", "The configuration file '#{file}' could not be found." raise LoadError, "The Configuration file '#{file}' could not be found." end end
Public: Read configuration and return merged Hash file - the path to the YAML file to be read in Returns this configuration, overridden by the values in the file
read_config_file
ruby
jekyll/jekyll
lib/jekyll/configuration.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/configuration.rb
MIT
def read_config_files(files) configuration = clone begin files.each do |config_file| next if config_file.nil? || config_file.empty? new_config = read_config_file(config_file) configuration = Utils.deep_merge_hashes(configuration, new_config) end rescue ArgumentError => e Jekyll.logger.warn "WARNING:", "Error reading configuration. Using defaults (and options)." warn e end configuration.validate.add_default_collections end
Public: Read in a list of configuration files and merge with this hash files - the list of configuration file paths Returns the full configuration, with the defaults overridden by the values in the configuration files
read_config_files
ruby
jekyll/jekyll
lib/jekyll/configuration.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/configuration.rb
MIT
def validate config = clone check_plugins(config) check_include_exclude(config) config end
Public: Ensure the proper options are set in the configuration Returns the configuration Hash
validate
ruby
jekyll/jekyll
lib/jekyll/configuration.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/configuration.rb
MIT
def check_plugins(config) return unless config.key?("plugins") return if config["plugins"].is_a?(Array) Jekyll.logger.error "'plugins' should be set as an array of gem-names, but was: " \ "#{config["plugins"].inspect}. Use 'plugins_dir' instead to set " \ "the directory for your non-gemified Ruby plugins." raise Jekyll::Errors::InvalidConfigurationError, "'plugins' should be set as an array, but was: #{config["plugins"].inspect}." end
Private: Checks if the `plugins` config is a String config - the config hash Raises a Jekyll::Errors::InvalidConfigurationError if the config `plugins` is not an Array.
check_plugins
ruby
jekyll/jekyll
lib/jekyll/configuration.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/configuration.rb
MIT
def initialize(config = {}) @config = config end
Initialize the converter. Returns an initialized Converter.
initialize
ruby
jekyll/jekyll
lib/jekyll/converter.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/converter.rb
MIT
def published? !(data.key?("published") && data["published"] == false) end
Whether the file is published or not, as indicated in YAML front-matter
published?
ruby
jekyll/jekyll
lib/jekyll/convertible.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/convertible.rb
MIT
def read_yaml(base, name, opts = {}) filename = @path || site.in_source_dir(base, name) Jekyll.logger.debug "Reading:", relative_path begin self.content = File.read(filename, **Utils.merged_file_read_opts(site, opts)) if content =~ Document::YAML_FRONT_MATTER_REGEXP self.content = Regexp.last_match.post_match self.data = SafeYAML.load(Regexp.last_match(1)) end rescue Psych::SyntaxError => e Jekyll.logger.warn "YAML Exception reading #{filename}: #{e.message}" raise e if site.config["strict_front_matter"] rescue StandardError => e Jekyll.logger.warn "Error reading file #{filename}: #{e.message}" raise e if site.config["strict_front_matter"] end self.data ||= {} validate_data! filename validate_permalink! filename self.data end
Read the YAML frontmatter. base - The String path to the dir containing the file. name - The String filename of the file. opts - optional parameter to File.read, default at site configs Returns nothing. rubocop:disable Metrics/AbcSize
read_yaml
ruby
jekyll/jekyll
lib/jekyll/convertible.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/convertible.rb
MIT
def render_liquid(content, payload, info, path) renderer.render_liquid(content, payload, info, path) end
Render Liquid in the content content - the raw Liquid content to render payload - the payload for Liquid info - the info for Liquid Returns the converted content
render_liquid
ruby
jekyll/jekyll
lib/jekyll/convertible.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/convertible.rb
MIT
def to_liquid(attrs = nil) further_data = \ (attrs || self.class::ATTRIBUTES_FOR_LIQUID).each_with_object({}) do |attribute, hsh| hsh[attribute] = send(attribute) end Utils.deep_merge_hashes defaults, Utils.deep_merge_hashes(data, further_data) end
Convert this Convertible's data to a Hash suitable for use by Liquid. Returns the Hash representation of this Convertible.
to_liquid
ruby
jekyll/jekyll
lib/jekyll/convertible.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/convertible.rb
MIT
def type :pages if is_a?(Page) end
The type of a document, i.e., its classname downcase'd and to_sym'd. Returns the type of self.
type
ruby
jekyll/jekyll
lib/jekyll/convertible.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/convertible.rb
MIT
def hook_owner :pages if is_a?(Page) end
returns the owner symbol for hook triggering
hook_owner
ruby
jekyll/jekyll
lib/jekyll/convertible.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/convertible.rb
MIT
def asset_file? sass_file? || coffeescript_file? end
Determine whether the document is an asset file. Asset files include CoffeeScript files and Sass/SCSS files. Returns true if the extname belongs to the set of extensions that asset files use.
asset_file?
ruby
jekyll/jekyll
lib/jekyll/convertible.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/convertible.rb
MIT
def coffeescript_file? ext == ".coffee" end
Determine whether the document is a CoffeeScript file. Returns true if extname == .coffee, false otherwise.
coffeescript_file?
ruby
jekyll/jekyll
lib/jekyll/convertible.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/convertible.rb
MIT
def render_with_liquid? return false if data["render_with_liquid"] == false Jekyll::Utils.has_liquid_construct?(content) end
Determine whether the file should be rendered with Liquid. Returns true if the file has Liquid Tags or Variables, false otherwise.
render_with_liquid?
ruby
jekyll/jekyll
lib/jekyll/convertible.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/convertible.rb
MIT
def place_in_layout? !(asset_file? || no_layout?) end
Determine whether the file should be placed into layouts. Returns false if the document is an asset file or if the front matter specifies `layout: none`
place_in_layout?
ruby
jekyll/jekyll
lib/jekyll/convertible.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/convertible.rb
MIT
def invalid_layout?(layout) !data["layout"].nil? && layout.nil? && !(is_a? Jekyll::Excerpt) end
Checks if the layout specified in the document actually exists layout - the layout to check Returns true if the layout is invalid, false if otherwise
invalid_layout?
ruby
jekyll/jekyll
lib/jekyll/convertible.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/convertible.rb
MIT
def render_all_layouts(layouts, payload, info) renderer.layouts = layouts self.output = renderer.place_in_layouts(output, payload, info) ensure @renderer = nil # this will allow the modifications above to disappear end
Recursively render layouts layouts - a list of the layouts payload - the payload for Liquid info - the info for Liquid Returns nothing
render_all_layouts
ruby
jekyll/jekyll
lib/jekyll/convertible.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/convertible.rb
MIT
def do_layout(payload, layouts) self.output = renderer.tap do |doc_renderer| doc_renderer.layouts = layouts doc_renderer.payload = payload end.run Jekyll.logger.debug "Post-Render Hooks:", relative_path Jekyll::Hooks.trigger hook_owner, :post_render, self ensure @renderer = nil # this will allow the modifications above to disappear end
Add any necessary layouts to this convertible document. payload - The site payload Drop or Hash. layouts - A Hash of {"name" => "layout"}. Returns nothing.
do_layout
ruby
jekyll/jekyll
lib/jekyll/convertible.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/convertible.rb
MIT
def write(dest) path = destination(dest) FileUtils.mkdir_p(File.dirname(path)) Jekyll.logger.debug "Writing:", path File.write(path, output, :mode => "wb") Jekyll::Hooks.trigger hook_owner, :post_write, self end
Write the generated page file to the destination directory. dest - The String path to the destination dir. Returns nothing.
write
ruby
jekyll/jekyll
lib/jekyll/convertible.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/convertible.rb
MIT
def initialize(path, relations = {}) @site = relations[:site] @path = path @extname = File.extname(path) @collection = relations[:collection] @type = @collection.label.to_sym @has_yaml_header = nil if draft? categories_from_path("_drafts") else categories_from_path(collection.relative_directory) end data.default_proc = proc do |_, key| site.frontmatter_defaults.find(relative_path, type, key) end trigger_hooks(:post_init) end
Create a new Document. path - the path to the file relations - a hash with keys :site and :collection, the values of which are the Jekyll::Site and Jekyll::Collection to which this Document belong. Returns nothing.
initialize
ruby
jekyll/jekyll
lib/jekyll/document.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/document.rb
MIT
def data @data ||= {} end
Fetch the Document's data. Returns a Hash containing the data. An empty hash is returned if no data was read.
data
ruby
jekyll/jekyll
lib/jekyll/document.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/document.rb
MIT
def merge_data!(other, source: "YAML front matter") merge_categories!(other) Utils.deep_merge_hashes!(data, other) merge_date!(source) data end
Merge some data in with this document's data. Returns the merged data.
merge_data!
ruby
jekyll/jekyll
lib/jekyll/document.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/document.rb
MIT
def date data["date"] ||= (draft? ? source_file_mtime : site.time) end
Returns the document date. If metadata is not present then calculates it based on Jekyll::Site#time or the document file modification time. Return document date string.
date
ruby
jekyll/jekyll
lib/jekyll/document.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/document.rb
MIT
def draft? data["draft"] ||= relative_path.index(collection.relative_directory).nil? && collection.label == "posts" end
Returns whether the document is a draft. This is only the case if the document is in the 'posts' collection but in a different directory than '_posts'. Returns whether the document is a draft.
draft?
ruby
jekyll/jekyll
lib/jekyll/document.rb
https://github.com/jekyll/jekyll/blob/master/lib/jekyll/document.rb
MIT