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.



9
10
11
12
# File 'lib/trmnlp/config/project.rb', line 9

def initialize(paths)
  @paths = paths
  reload!
end

Instance Attribute Details

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



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

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

#live_render?Boolean

Returns:

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



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

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

#user_data_overridesObject



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

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

#user_filtersObject



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

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

#watch_pathsObject



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

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



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