Class: ActiveSupport::ConfigurationFile

Inherits:
Object
  • Object
show all
Defined in:
lib/app_config_for/legacy_support.rb

Overview

Note:

This legacy support is only included if the existing ActiveSupport version is below 6.1.0. If your application is using any version of ActiveSupport below 6.1.4 it is strongly suggested you upgrade your application due to security and bug fixes. This backwards compatability is only enough to support AppConfigFor and is not to be considered a full backport of existing features. This support will be removed in the future.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_name) ⇒ ConfigurationFile

Returns a new instance of ConfigurationFile.



40
41
42
43
44
# File 'lib/app_config_for/legacy_support.rb', line 40

def initialize(file_name)
  @file_name = file_name
  @config = File.read(file_name)
  warn(file_name + ' contains invisible non-breaking spaces.') if @config.match?("\u00A0")
end

Class Method Details

.parse(file_name) ⇒ Object

Quick and dirty parse



47
48
49
# File 'lib/app_config_for/legacy_support.rb', line 47

def self.parse(file_name)
  new(file_name).parse
end

Instance Method Details

#parseObject

Quick and dirty parse



52
53
54
55
56
# File 'lib/app_config_for/legacy_support.rb', line 52

def parse
  YAML.load(ERB.new(@config).result) || {}
rescue Psych::SyntaxError => e
  raise "YAML syntax error occurred while parsing #{@file_name}. Error: #{e.message}"
end