Class: Lifer::Builder
- Inherits:
-
Object
- Object
- Lifer::Builder
- Includes:
- Shared::FinderMethods
- Defined in:
- lib/lifer/builder.rb,
lib/lifer/builder/html/from_any.rb
Overview
Builders are a core part of Lifer. Builders are configured by users in the configuration file and take the content of a Lifer project and turn it into built stuff. That could be feeds, HTML documents, or other weird files.
This base class includes some special functionality for running all builders when a Lifer build is executed. But it also sets in stone the public API for implementing builder classes. (In short: an ‘.execute` class method and an `#execute` instance method.)
Defined Under Namespace
Modules: InitializeBuilder Classes: HTML, RSS, TXT
Class Attribute Summary collapse
-
.name ⇒ Object
Returns the value of attribute name.
-
.settings ⇒ Object
Returns the value of attribute settings.
Class Method Summary collapse
-
.build!(*builder_names, root:) ⇒ void
Given a list of builder names, we execute every builder based on the configured Lifer project root.
-
.execute(root:) ⇒ NotImplementedError
Every builder class must have execute method.
-
.prebuild!(*commands, root:) ⇒ void
Given a list of prebuild commands, execute each one in the shell.
Instance Method Summary collapse
-
#execute ⇒ NotImplementedError
Every builder class must have execute instance method.
Class Attribute Details
.name ⇒ Object
Returns the value of attribute name.
16 17 18 |
# File 'lib/lifer/builder.rb', line 16 def name @name end |
.settings ⇒ Object
Returns the value of attribute settings.
16 17 18 |
# File 'lib/lifer/builder.rb', line 16 def settings @settings end |
Class Method Details
.build!(*builder_names, root:) ⇒ void
This method returns an undefined value.
Given a list of builder names, we execute every builder based on the configured Lifer project root.
33 34 35 36 37 |
# File 'lib/lifer/builder.rb', line 33 def build!(*builder_names, root:) builder_names.each do |builder| Lifer::Builder.find(builder).execute root: root end end |
.execute(root:) ⇒ NotImplementedError
Every builder class must have execute method. This is the entrypoint for instantiating and executing any builder.
25 |
# File 'lib/lifer/builder.rb', line 25 def execute(root:) = (raise NotImplementedError) |
.prebuild!(*commands, root:) ⇒ void
This method returns an undefined value.
Given a list of prebuild commands, execute each one in the shell. This is meant to be run once before ‘.build!` is run once.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/lifer/builder.rb', line 45 def prebuild!(*commands, root:) commands.each do |command| puts command _stdin, stdout, stderr, _wait_thread = Open3.popen3(command) if ( = stderr.readlines).any? raise .join("\n") end stdout.readlines.each { puts _1 } end rescue => exception raise I18n.t("builder.prebuild_failure", exception:) end |
Instance Method Details
#execute ⇒ NotImplementedError
Every builder class must have execute instance method. This is where the core logic of the builder runs from after initialization.
83 |
# File 'lib/lifer/builder.rb', line 83 def execute = (raise NotImplementedError) |