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.
9 10 11 12 |
# File 'lib/trmnlp/config/project.rb', line 9 def initialize(paths) @paths = paths reload! end |
Instance Attribute Details
#paths ⇒ Object (readonly)
Returns the value of attribute paths.
7 8 9 |
# File 'lib/trmnlp/config/project.rb', line 7 def paths @paths end |
Instance Method Details
#custom_fields ⇒ Object
30 |
# File 'lib/trmnlp/config/project.rb', line 30 def custom_fields = @config.fetch('custom_fields', {}).transform_values(&:to_s) |
#live_render? ⇒ Boolean
24 |
# File 'lib/trmnlp/config/project.rb', line 24 def live_render? = !watch_paths.empty? |
#reload! ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/trmnlp/config/project.rb', line 14 def reload! if paths.trmnlp_config.exist? @config = YAML.load_file(paths.trmnlp_config) else @config = {} end end |
#time_zone ⇒ Object
40 |
# File 'lib/trmnlp/config/project.rb', line 40 def time_zone = @config['time_zone'] || 'UTC' |
#user_data_overrides ⇒ Object
32 |
# File 'lib/trmnlp/config/project.rb', line 32 def user_data_overrides = @config['variables'] || {} |
#user_filters ⇒ Object
22 |
# File 'lib/trmnlp/config/project.rb', line 22 def user_filters = @config['custom_filters'] || [] |
#watch_paths ⇒ Object
26 27 28 |
# File 'lib/trmnlp/config/project.rb', line 26 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
35 36 37 38 |
# File 'lib/trmnlp/config/project.rb', line 35 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 |