Class: TRMNLP::Config::Project

Inherits:
Object
  • Object
show all
Defined in:
lib/trmnlp/config/project.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#pathsObject (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_fieldsObject



29
# File 'lib/trmnlp/config/project.rb', line 29

def custom_fields = @config.fetch('custom_fields', {}).transform_values(&:to_s)

#live_render?Boolean

Returns:

  • (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_zoneObject



39
# File 'lib/trmnlp/config/project.rb', line 39

def time_zone = @config['time_zone'] || 'UTC'

#user_data_overridesObject



31
# File 'lib/trmnlp/config/project.rb', line 31

def user_data_overrides = @config['variables'] || {}

#user_filtersObject



21
# File 'lib/trmnlp/config/project.rb', line 21

def user_filters = @config['custom_filters'] || []

#watch_pathsObject



25
26
27
# File 'lib/trmnlp/config/project.rb', line 25

def watch_paths
  (@config['watch'] || []).map { |watch_path| paths.expand(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