Module: Lifer
- Defined in:
- lib/lifer.rb,
lib/lifer/cli.rb,
lib/lifer/tag.rb,
lib/lifer/entry.rb,
lib/lifer/author.rb,
lib/lifer/version.rb
Overview
The root Lifer module is a great entrypoint into the system, with convenience methods to access global resources like collections and configuration settings.
Defined Under Namespace
Modules: Dev, Shared, Utilities Classes: Asset, Author, Brain, Builder, CLI, Collection, Config, Entry, Message, Selection, Tag, URIStrategy
Constant Summary collapse
- IGNORE_DIRECTORIES =
Lifer considers files and directories that have the following names or contain the following patterns special and ignoreable when they’re at the root of the Lifer project.
[ "assets", "bin", "vendor" ]
- IGNORE_PATTERNS =
Lifer projects ignore files and directories that contain particular patterns.
[ "^(\\.)", # Starts with a dot. "^(_)", # Starts with an underscore. "(\\/\\.)+" # Contains a dot directory. ] | IGNORE_DIRECTORIES.map { |d| "^(#{d})" }
- FRONTMATTER_REGEX =
We expect frontmatter in any file to be provided in the following format.
/^---\n(.*?)---\n/m- VERSION =
"0.13.0"
Class Method Summary collapse
-
.asset_manifest ⇒ Array<Lifer::Asset>
All of the assets represented in Lifer entries for the current project.
-
.author_manifest ⇒ Set<Lifer::Author>
A set of all authors added to the project.
-
.authors ⇒ Array<Lifer::Author>
All of the authors represented in Lifer entries for the current project.
-
.brain(root: Dir.pwd, config_file: nil) ⇒ Lifer::Brain
The first time ‘Lifer.brain` is referenced, we build a new `Lifer::Brain` object that is used and reused until the current process has ended.
-
.build!(environment: :build) ⇒ void
Initiates the Lifer build process.
-
.collections(without_selections: false) ⇒ Array<Lifer::Collection>
List all collections in the project.
-
.config_file ⇒ Pathname
Used to locate the configuration file being used by the current Lifer project.
-
.entry_manifest ⇒ Set
A set of all entries currently in the project.
-
.gem_root ⇒ String
This convenience method locates the Ruby gem root, which is always distinct from the Lifer project root.
-
.ignoreable?(directory_or_file) ⇒ boolean
Check if the given path matches the Lifer ignore patterns.
-
.manifest ⇒ Set
A set of all entries currently in the project.
-
.output_directory ⇒ Pathname
The build directory for the Lifer project.
-
.parallelism_disabled? ⇒ boolean
Returns false if the Lifer project will be built with parallelism.
-
.register_settings(setting, ...) ⇒ void
Register new settings so that they are “safe” and can be read from a Lifer configuration file.
-
.root ⇒ Lifer::Brain
The project brain.
-
.setting(..., collection: nil, strict: false) ⇒ String, NilClass
Given a path to a setting, with or without a collection scope, get the current configured value for that setting.
-
.settings ⇒ Hash
The project’s current settings tree.
-
.tag_manifest ⇒ Set<Lifer::Tag>
A set of all tags added to the project.
-
.tags ⇒ Array<Lifer::Tag>
All of the tags represented in Lifer entries for the current project.
Class Method Details
.asset_manifest ⇒ Array<Lifer::Asset>
All of the assets represented in Lifer entries for the current project.
35 |
# File 'lib/lifer.rb', line 35 def asset_manifest = brain.asset_manifest |
.author_manifest ⇒ Set<Lifer::Author>
A set of all authors added to the project. Prefer using the ‘#authors` method for author queries.
46 |
# File 'lib/lifer.rb', line 46 def = brain. |
.authors ⇒ Array<Lifer::Author>
All of the authors represented in Lifer entries for the current project.
40 |
# File 'lib/lifer.rb', line 40 def = brain. |
.brain(root: Dir.pwd, config_file: nil) ⇒ Lifer::Brain
The first time ‘Lifer.brain` is referenced, we build a new `Lifer::Brain` object that is used and reused until the current process has ended.
55 56 57 |
# File 'lib/lifer.rb', line 55 def brain(root: Dir.pwd, config_file: nil) @@brain ||= Lifer::Brain.init root:, config_file: end |
.build!(environment: :build) ⇒ void
This method returns an undefined value.
Initiates the Lifer build process.
64 |
# File 'lib/lifer.rb', line 64 def build!(environment: :build) = (brain.build! environment:) |
.collections(without_selections: false) ⇒ Array<Lifer::Collection>
List all collections in the project. By default, selections are also included.
72 73 74 75 76 |
# File 'lib/lifer.rb', line 72 def collections(without_selections: false) return brain.collections unless without_selections brain.collections.select { _1.class == Lifer::Collection } end |
.config_file ⇒ Pathname
Used to locate the configuration file being used by the current Lifer project.
82 |
# File 'lib/lifer.rb', line 82 def config_file = brain.config.file |
.entry_manifest ⇒ Set
A set of all entries currently in the project.
89 |
# File 'lib/lifer.rb', line 89 def entry_manifest = brain.entry_manifest |
.gem_root ⇒ String
This convenience method locates the Ruby gem root, which is always distinct from the Lifer project root. This is helpful, for example, if default templates provided by the gem are required in the current project.
96 |
# File 'lib/lifer.rb', line 96 def gem_root = File.dirname(__dir__) |
.ignoreable?(directory_or_file) ⇒ boolean
Check if the given path matches the Lifer ignore patterns.
102 103 104 |
# File 'lib/lifer.rb', line 102 def ignoreable?(directory_or_file) directory_or_file.match?(/#{IGNORE_PATTERNS.join("|")}/) end |
.manifest ⇒ Set
A set of all entries currently in the project.
111 |
# File 'lib/lifer.rb', line 111 def manifest = brain.manifest |
.output_directory ⇒ Pathname
The build directory for the Lifer project.
117 |
# File 'lib/lifer.rb', line 117 def output_directory = brain.output_directory |
.parallelism_disabled? ⇒ boolean
Returns false if the Lifer project will be built with parallelism. This should return false almost always–unless you’ve explicitly set the ‘LIFER_UNPARALLELIZED` environment variable before running the program.
This method is used internally by Lifer to determine whether features that would normally run in parallel should not run in parallel for some reason.
127 |
# File 'lib/lifer.rb', line 127 def parallelism_disabled? = ENV["LIFER_UNPARALLELIZED"].is_a?(String) |
.register_settings(setting, ...) ⇒ void
Register new settings so that they are “safe” and can be read from a Lifer configuration file. Unregistered settings are ignored.
144 |
# File 'lib/lifer.rb', line 144 def register_settings(*settings) = brain.config.register_settings(*settings) |
.setting(..., collection: nil, strict: false) ⇒ String, NilClass
Given a path to a setting, with or without a collection scope, get the current configured value for that setting.
Note that if a collection does not have a setting set, the setting returned will be the Lifer root collection setting or the default setting unless the ‘:strict` keyword argument is set to `true`.
166 167 168 |
# File 'lib/lifer.rb', line 166 def setting(*name, collection: nil, strict: false) brain.setting *name, collection: collection, strict: strict end |
.settings ⇒ Hash
The project’s current settings tree.
173 |
# File 'lib/lifer.rb', line 173 def settings = brain.config.settings |
.tag_manifest ⇒ Set<Lifer::Tag>
A set of all tags added to the project. Prefer using the ‘#tags` method for tag queries.
184 |
# File 'lib/lifer.rb', line 184 def tag_manifest = brain.tag_manifest |
.tags ⇒ Array<Lifer::Tag>
All of the tags represented in Lifer entries for the current project.
178 |
# File 'lib/lifer.rb', line 178 def = brain. |