File: config_document_factory.rb

package info (click to toggle)
ruby-hocon 1.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 768 kB
  • sloc: ruby: 7,903; makefile: 4
file content (36 lines) | stat: -rw-r--r-- 1,060 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# encoding: utf-8

require_relative '../../hocon/parser'
require_relative '../../hocon/impl/parseable'
require_relative '../../hocon/config_parse_options'

#
# Factory for creating {@link
# com.typesafe.config.parser.ConfigDocument} instances.
#
class Hocon::Parser::ConfigDocumentFactory
  #
  # Parses a file into a ConfigDocument instance.
  #
  # @param file
  #       the file to parse
  # @param options
  #       parse options to control how the file is interpreted
  # @return the parsed configuration
  # @throws com.typesafe.config.ConfigException on IO or parse errors
  #
  def self.parse_file(file, options = Hocon::ConfigParseOptions.defaults)
    Hocon::Impl::Parseable.new_file(file, options).parse_config_document
  end

  #
  # Parses a string which should be valid HOCON or JSON.
  #
  # @param s string to parse
  # @param options parse options
  # @return the parsed configuration
  #
  def self.parse_string(s, options = Hocon::ConfigParseOptions.defaults)
    Hocon::Impl::Parseable.new_string(s, options).parse_config_document
  end
end