Module: Unifig::Init
- Defined in:
- lib/unifig/init.rb
Overview
Initializes Unifig with methods based on YAML.
Class Method Summary collapse
-
.load(str, env: nil) ⇒ Object
Loads a string of YAML to configure Unifig.
-
.load_file(file_path, env: nil) ⇒ Object
Loads a YAML file to configure Unifig.
Class Method Details
.load(str, env: nil) ⇒ Object
Loads a string of YAML to configure Unifig.
27 28 29 30 31 32 |
# File 'lib/unifig/init.rb', line 27 def load(str, env: nil) yml = Psych.load(str, symbolize_names: true) exec!(yml, env: env) rescue Psych::SyntaxError, Psych::BadAlias => e raise YAMLSyntaxError, e. end |
.load_file(file_path, env: nil) ⇒ Object
Loads a YAML file to configure Unifig.
43 44 45 46 47 |
# File 'lib/unifig/init.rb', line 43 def load_file(file_path, env: nil) # Ruby 2.7 Psych.load_file doesn't support the :symbolize_names flag. # After Ruby 2.7 this can be changed to Psych.load_file if that's faster. load(File.read(file_path), env: env) end |