File: config_util.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 (73 lines) | stat: -rw-r--r-- 2,265 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
require_relative '../hocon/impl/config_impl_util'


# Contains static utility methods
class Hocon::ConfigUtil
  #
  # Quotes and escapes a string, as in the JSON specification.
  #
  # @param string
  #            a string
  # @return the string quoted and escaped
  #
  def self.quote_string(string)
    Hocon::Impl::ConfigImplUtil.render_json_string(string)
  end

  #
  # Converts a list of keys to a path expression, by quoting the path
  # elements as needed and then joining them separated by a period. A path
  # expression is usable with a {@link Config}, while individual path
  # elements are usable with a {@link ConfigObject}.
  # <p>
  # See the overview documentation for {@link Config} for more detail on path
  # expressions vs. keys.
  #
  # @param elements
  #            the keys in the path
  # @return a path expression
  # @throws ConfigException
  #             if there are no elements
  #
  def self.join_path(*elements)
    Hocon::Impl::ConfigImplUtil.join_path(*elements)
  end

  #
  # Converts a list of strings to a path expression, by quoting the path
  # elements as needed and then joining them separated by a period. A path
  # expression is usable with a {@link Config}, while individual path
  # elements are usable with a {@link ConfigObject}.
  # <p>
  # See the overview documentation for {@link Config} for more detail on path
  # expressions vs. keys.
  #
  # @param elements
  #            the keys in the path
  # @return a path expression
  # @throws ConfigException
  #             if the list is empty
  #
  def self.join_path_from_list(elements)
    self.join_path(*elements)
  end

  #
  # Converts a path expression into a list of keys, by splitting on period
  # and unquoting the individual path elements. A path expression is usable
  # with a {@link Config}, while individual path elements are usable with a
  # {@link ConfigObject}.
  # <p>
  # See the overview documentation for {@link Config} for more detail on path
  # expressions vs. keys.
  #
  # @param path
  #            a path expression
  # @return the individual keys in the path
  # @throws ConfigException
  #             if the path expression is invalid
  #
  def self.split_path(path)
    Hocon::Impl::ConfigImplUtil.split_path(path)
  end
end