class WarpEngine::Configuration::DSL
The block form of WarpEngine.configure: WarpEngine.configure do ... end without a block parameter runs here. Every call writes the same settings the c.setting = value form does, so the rest of the engine reads one Configuration either way. The collections (shelves, extras, platforms, ignored user agents) are keyed, so a block that runs again on a reload replaces its entries instead of adding them twice.
Constants
- SETTINGS
-
The settings that map one to one onto a
WarpEngine::Configurationwriter; each gets aDSLmethod of the same name taking the value.
Public Class Methods
Source
# File lib/warp_engine/configuration/dsl.rb, line 23 def self.apply(config, &block) new(config).instance_eval(&block) config end
Evaluates block against a new DSL writing into config and returns config.
Source
# File lib/warp_engine/configuration/dsl.rb, line 29 def initialize(config) @config = config end
Creates a DSL writing into the WarpEngine::Configuration config.
Public Instance Methods
# File lib/warp_engine/configuration/dsl.rb, line 93 def additional_resource(association, on:, label:, multiple: true, &block) builder = AdditionalResourceDSL.new(association, subject: on, label: label, multiple: multiple) builder.instance_eval(&block) if block resource = builder.build @config.additional_resources = Array(@config.additional_resources).reject do |other| other.subject == resource.subject && other.association == resource.association end + [ resource ] end
Adds host fields to an engine admin page.
- association
-
the host association on the engine model
- on
-
the engine resource it hangs on, e.g.
:software - label
-
the fieldset title
- multiple
-
falsefor ahas_oneassociation
The block runs with a WarpEngine::Configuration::AdditionalResourceDSL. An entry with the same subject and association is replaced.
Source
# File lib/warp_engine/configuration/dsl.rb, line 80 def admin_api(&block) AdminApiDSL.new(@config.admin_api).instance_eval(&block) end
Evaluates block with a WarpEngine::Configuration::AdminApiDSL on the admin API settings.
# File lib/warp_engine/configuration/dsl.rb, line 41 def application_tokens(from:, owner: nil) @config.application_token_source = from @config.application_token_owner_class = owner&.to_s end
Sets the /build/* authentication source.
- from
-
:env(the shared update secret) or:database(application tokens) - owner
-
class name of the owner database tokens belong to
Source
# File lib/warp_engine/configuration/dsl.rb, line 106 def ci(adapter, &block) @config.ci_adapter = block ? CIDSL.build(adapter, &block) : adapter end
Sets the CI adapter: ci :none, ci :woodpecker (from ENV), ci SomeAdapter.new, or ci :woodpecker do ... end to name the server and its platforms here (see WarpEngine::Configuration::CIDSL).
# File lib/warp_engine/configuration/dsl.rb, line 60 def ignore_user_agents(*patterns) @config.ignored_user_agents = (Array(@config.ignored_user_agents) + patterns.flatten).uniq end
Adds user agent patterns the download statistics leave out; strings may use * as a wildcard. Duplicates are dropped.
Source
# File lib/warp_engine/configuration/dsl.rb, line 47 def image_class(name) = @config.image_class_name = name.to_s
Sets the class name of the hostβs image model.
# File lib/warp_engine/configuration/dsl.rb, line 76 def register_platform(name, **options) = @config.register_platform(name, **options)
Registers a platform; see WarpEngine::Configuration#register_platform.
Source
# File lib/warp_engine/configuration/dsl.rb, line 67 def shelf(platform, **options) unknown = options.keys - (Shelves::KEYS - [ :platform ]) raise ArgumentError, "unknown shelf keys for #{platform}: #{unknown.join(', ')}" if unknown.any? definition = { platform: platform.to_s, **options } @config.shelves = Array(@config.shelves).reject { |other| other.to_h.symbolize_keys[:path] == definition[:path] } + [ definition ] end
Defines a shelf for platform (see WarpEngine::Shelves for the options). A shelf with the same path is replaced. Raises ArgumentError on an unknown option key.
Source
# File lib/warp_engine/configuration/dsl.rb, line 50 def storage(adapter) = @config.storage_adapter = adapter
Sets the storage adapter: :local or an adapter object (see WarpEngine::Storage).
# File lib/warp_engine/configuration/dsl.rb, line 54 def subject_resolver(callable = nil, &block) @config.subject_resolver = callable || block end
Sets the callable (or the block) that takes a request and returns the subject of its session, for callers without a bearer token.