Server IP : 66.29.132.122 / Your IP : 18.191.176.228 Web Server : LiteSpeed System : Linux business142.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : admazpex ( 531) PHP Version : 7.2.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/self/root/proc/self/root/proc/thread-self/root/proc/thread-self/root/opt/puppetlabs/puppet/lib/ruby/vendor_gems/gems/hocon-1.3.1/lib/ |
Upload File : |
# encoding: utf-8 module Hocon # NOTE: the behavior of this load method differs a bit from the upstream public # API, where a file extension may be the preferred method of determining # the config syntax, even if you specify a Syntax value on ConfigParseOptions. # Here we prefer the syntax (optionally) specified by the user no matter what # the file extension is, and if they don't specify one and the file extension # is unrecognized, we raise an error. def self.load(file, opts = nil) # doing these requires lazily, because otherwise, classes that need to # `require 'hocon'` to get the module into scope will end up recursing # through this require and probably ending up with circular dependencies. require 'hocon/config_factory' require 'hocon/impl/parseable' require 'hocon/config_parse_options' require 'hocon/config_resolve_options' require 'hocon/config_error' syntax = opts ? opts[:syntax] : nil if syntax.nil? unless Hocon::Impl::Parseable.syntax_from_extension(file) raise Hocon::ConfigError::ConfigParseError.new( nil, "Unrecognized file extension '#{File.extname(file)}' and no value provided for :syntax option", nil) end config = Hocon::ConfigFactory.parse_file_any_syntax( file, Hocon::ConfigParseOptions.defaults) else config = Hocon::ConfigFactory.parse_file( file, Hocon::ConfigParseOptions.defaults.set_syntax(syntax)) end resolved_config = Hocon::ConfigFactory.load_from_config( config, Hocon::ConfigResolveOptions.defaults) resolved_config.root.unwrapped end def self.parse(string) # doing these requires lazily, because otherwise, classes that need to # `require 'hocon'` to get the module into scope will end up recursing # through this require and probably ending up with circular dependencies. require 'hocon/config_factory' require 'hocon/config_resolve_options' config = Hocon::ConfigFactory.parse_string(string) resolved_config = Hocon::ConfigFactory.load_from_config( config, Hocon::ConfigResolveOptions.defaults) resolved_config.root.unwrapped end end