Class: TRMNLP::Config::Project
- Inherits:
-
Object
- Object
- TRMNLP::Config::Project
- Defined in:
- lib/trmnlp/config/project.rb
Instance Attribute Summary collapse
-
#paths ⇒ Object
readonly
Returns the value of attribute paths.
Instance Method Summary collapse
-
#asset_host ⇒ Object
Local override for the framework asset host (offline / mirrored dev).
- #custom_fields ⇒ Object
-
#initialize(paths) ⇒ Project
constructor
A new instance of Project.
- #live_render? ⇒ Boolean
- #reload! ⇒ Object
-
#serverless_daemon_api_key ⇒ Object
Bearer token for the remote transform daemon.
-
#serverless_daemon_url ⇒ Object
Opt-in URL of a remote transform daemon.
- #time_zone ⇒ Object
-
#transform_runtime ⇒ Object
Toggles serverless transform support.
- #user_data_overrides ⇒ Object
- #user_filters ⇒ Object
- #watch_paths ⇒ Object
-
#with_custom_fields(value) ⇒ Object
for interpolating custom_fields into polling_* options.
Constructor Details
#initialize(paths) ⇒ Project
Returns a new instance of Project.
14 15 16 17 |
# File 'lib/trmnlp/config/project.rb', line 14 def initialize(paths) @paths = paths reload! end |
Instance Attribute Details
#paths ⇒ Object (readonly)
Returns the value of attribute paths.
12 13 14 |
# File 'lib/trmnlp/config/project.rb', line 12 def paths @paths end |
Instance Method Details
#asset_host ⇒ Object
Local override for the framework asset host (offline / mirrored dev). Trmnlp-specific (local dev only) — so it stays in .trmnlp.yml. Consumed by Config::Plugin#framework_version.
52 |
# File 'lib/trmnlp/config/project.rb', line 52 def asset_host = @config['framework_asset_host'] || FrameworkVersion::DEFAULT_ASSET_HOST |
#custom_fields ⇒ Object
37 |
# File 'lib/trmnlp/config/project.rb', line 37 def custom_fields = @config.fetch('custom_fields', {}).transform_values { |v| stringify_field_value(v) } |
#live_render? ⇒ Boolean
31 |
# File 'lib/trmnlp/config/project.rb', line 31 def live_render? = !watch_paths.empty? |
#reload! ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/trmnlp/config/project.rb', line 19 def reload! @config = if paths.trmnlp_config.exist? YAML.safe_load_file(paths.trmnlp_config, permitted_classes: [Date, Time]) || {} else {} end rescue Psych::SyntaxError => e raise InvalidConfig, ".trmnlp.yml is not valid YAML: #{e.}" end |
#serverless_daemon_api_key ⇒ Object
Bearer token for the remote transform daemon. Mirrors Config::App’s ENV-first pattern so the secret stays out of version control —$TRMNL_SERVERLESS_DAEMON_API_KEY takes priority, falls through to the .trmnlp.yml key if no env var is set.
73 74 75 76 77 78 |
# File 'lib/trmnlp/config/project.rb', line 73 def serverless_daemon_api_key env_key = ENV.fetch('TRMNL_SERVERLESS_DAEMON_API_KEY', nil) return env_key if env_key && !env_key.empty? @config['serverless_daemon_api_key'] end |
#serverless_daemon_url ⇒ Object
Opt-in URL of a remote transform daemon. When set, transforms POST here instead of running locally — useful for production-fidelity testing or shared team daemons.
67 |
# File 'lib/trmnlp/config/project.rb', line 67 def serverless_daemon_url = @config['serverless_daemon_url'] |
#time_zone ⇒ Object
47 |
# File 'lib/trmnlp/config/project.rb', line 47 def time_zone = @config['time_zone'] || 'UTC' |
#transform_runtime ⇒ Object
Toggles serverless transform support. Enabled by default; set to ‘disabled’ in .trmnlp.yml to turn it off. A transform only runs when a src/transform.* file is also present, so the default is inert until the plugin actually ships one. Transforms run in-process via the bundled python/node/php/ruby interpreters; set serverless_daemon_url to route to a remote transform daemon instead. Lives in .trmnlp.yml because this is purely a local-dev decision.
62 |
# File 'lib/trmnlp/config/project.rb', line 62 def transform_runtime = @config['transform_runtime'] || 'enabled' |
#user_data_overrides ⇒ Object
39 |
# File 'lib/trmnlp/config/project.rb', line 39 def user_data_overrides = @config['variables'] || {} |
#user_filters ⇒ Object
29 |
# File 'lib/trmnlp/config/project.rb', line 29 def user_filters = @config['custom_filters'] || [] |
#watch_paths ⇒ Object
33 34 35 |
# File 'lib/trmnlp/config/project.rb', line 33 def watch_paths (@config['watch'] || []).map { |watch_path| paths.(watch_path) }.uniq end |
#with_custom_fields(value) ⇒ Object
for interpolating custom_fields into polling_* options
42 43 44 45 |
# File 'lib/trmnlp/config/project.rb', line 42 def with_custom_fields(value) custom_fields_with_env = custom_fields.transform_values { |v| with_env(v) } parse_liquid(value).render(custom_fields_with_env) end |