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
- #custom_fields ⇒ Object
-
#initialize(paths) ⇒ Project
constructor
A new instance of Project.
- #live_render? ⇒ Boolean
- #reload! ⇒ Object
- #time_zone ⇒ Object
- #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.
8 9 10 11 |
# File 'lib/trmnlp/config/project.rb', line 8 def initialize(paths) @paths = paths reload! end |
Instance Attribute Details
#paths ⇒ Object (readonly)
Returns the value of attribute paths.
6 7 8 |
# File 'lib/trmnlp/config/project.rb', line 6 def paths @paths end |
Instance Method Details
#custom_fields ⇒ Object
29 |
# File 'lib/trmnlp/config/project.rb', line 29 def custom_fields = @config.fetch('custom_fields', {}).transform_values(&:to_s) |
#live_render? ⇒ Boolean
23 |
# File 'lib/trmnlp/config/project.rb', line 23 def live_render? = !watch_paths.empty? |
#reload! ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/trmnlp/config/project.rb', line 13 def reload! if paths.trmnlp_config.exist? @config = YAML.load_file(paths.trmnlp_config) else @config = {} end end |
#time_zone ⇒ Object
39 |
# File 'lib/trmnlp/config/project.rb', line 39 def time_zone = @config['time_zone'] || 'UTC' |
#user_data_overrides ⇒ Object
31 |
# File 'lib/trmnlp/config/project.rb', line 31 def user_data_overrides = @config['variables'] || {} |
#user_filters ⇒ Object
21 |
# File 'lib/trmnlp/config/project.rb', line 21 def user_filters = @config['custom_filters'] || [] |
#watch_paths ⇒ Object
25 26 27 |
# File 'lib/trmnlp/config/project.rb', line 25 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
34 35 36 37 |
# File 'lib/trmnlp/config/project.rb', line 34 def with_custom_fields(value) custom_fields_with_env = custom_fields.transform_values { |v| with_env(v) } Liquid::Template.parse(value).render(custom_fields_with_env) end |