hocon 0.0.7 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +4 -2
  3. data/lib/hocon.rb +2 -0
  4. data/lib/hocon/config.rb +1010 -0
  5. data/lib/hocon/config_error.rb +32 -2
  6. data/lib/hocon/config_factory.rb +46 -0
  7. data/lib/hocon/config_include_context.rb +49 -0
  8. data/lib/hocon/config_includer_file.rb +27 -0
  9. data/lib/hocon/config_list.rb +49 -0
  10. data/lib/hocon/config_mergeable.rb +74 -0
  11. data/lib/hocon/config_object.rb +144 -1
  12. data/lib/hocon/config_parse_options.rb +33 -9
  13. data/lib/hocon/config_parseable.rb +51 -0
  14. data/lib/hocon/config_render_options.rb +4 -2
  15. data/lib/hocon/config_resolve_options.rb +31 -0
  16. data/lib/hocon/config_syntax.rb +5 -2
  17. data/lib/hocon/config_util.rb +73 -0
  18. data/lib/hocon/config_value.rb +122 -0
  19. data/lib/hocon/config_value_factory.rb +66 -2
  20. data/lib/hocon/config_value_type.rb +5 -2
  21. data/lib/hocon/impl.rb +2 -0
  22. data/lib/hocon/impl/abstract_config_node.rb +29 -0
  23. data/lib/hocon/impl/abstract_config_node_value.rb +11 -0
  24. data/lib/hocon/impl/abstract_config_object.rb +148 -42
  25. data/lib/hocon/impl/abstract_config_value.rb +251 -11
  26. data/lib/hocon/impl/array_iterator.rb +19 -0
  27. data/lib/hocon/impl/config_boolean.rb +7 -1
  28. data/lib/hocon/impl/config_concatenation.rb +177 -28
  29. data/lib/hocon/impl/config_delayed_merge.rb +329 -0
  30. data/lib/hocon/impl/config_delayed_merge_object.rb +274 -0
  31. data/lib/hocon/impl/config_document_parser.rb +647 -0
  32. data/lib/hocon/impl/config_double.rb +44 -0
  33. data/lib/hocon/impl/config_impl.rb +143 -19
  34. data/lib/hocon/impl/config_impl_util.rb +18 -0
  35. data/lib/hocon/impl/config_include_kind.rb +10 -0
  36. data/lib/hocon/impl/config_int.rb +13 -1
  37. data/lib/hocon/impl/config_node_array.rb +11 -0
  38. data/lib/hocon/impl/config_node_comment.rb +19 -0
  39. data/lib/hocon/impl/config_node_complex_value.rb +54 -0
  40. data/lib/hocon/impl/config_node_concatenation.rb +11 -0
  41. data/lib/hocon/impl/config_node_field.rb +81 -0
  42. data/lib/hocon/impl/config_node_include.rb +33 -0
  43. data/lib/hocon/impl/config_node_object.rb +276 -0
  44. data/lib/hocon/impl/config_node_path.rb +48 -0
  45. data/lib/hocon/impl/config_node_root.rb +60 -0
  46. data/lib/hocon/impl/config_node_simple_value.rb +42 -0
  47. data/lib/hocon/impl/config_node_single_token.rb +17 -0
  48. data/lib/hocon/impl/config_null.rb +15 -7
  49. data/lib/hocon/impl/config_number.rb +43 -4
  50. data/lib/hocon/impl/config_parser.rb +403 -0
  51. data/lib/hocon/impl/config_reference.rb +142 -0
  52. data/lib/hocon/impl/config_string.rb +55 -7
  53. data/lib/hocon/impl/container.rb +29 -0
  54. data/lib/hocon/impl/default_transformer.rb +24 -15
  55. data/lib/hocon/impl/from_map_mode.rb +3 -1
  56. data/lib/hocon/impl/full_includer.rb +2 -0
  57. data/lib/hocon/impl/memo_key.rb +42 -0
  58. data/lib/hocon/impl/mergeable_value.rb +8 -0
  59. data/lib/hocon/impl/origin_type.rb +8 -2
  60. data/lib/hocon/impl/parseable.rb +455 -91
  61. data/lib/hocon/impl/path.rb +181 -59
  62. data/lib/hocon/impl/path_builder.rb +24 -3
  63. data/lib/hocon/impl/path_parser.rb +280 -0
  64. data/lib/hocon/impl/replaceable_merge_stack.rb +22 -0
  65. data/lib/hocon/impl/resolve_context.rb +254 -0
  66. data/lib/hocon/impl/resolve_memos.rb +21 -0
  67. data/lib/hocon/impl/resolve_result.rb +39 -0
  68. data/lib/hocon/impl/resolve_source.rb +354 -0
  69. data/lib/hocon/impl/resolve_status.rb +3 -1
  70. data/lib/hocon/impl/simple_config.rb +264 -10
  71. data/lib/hocon/impl/simple_config_document.rb +48 -0
  72. data/lib/hocon/impl/simple_config_list.rb +282 -8
  73. data/lib/hocon/impl/simple_config_object.rb +424 -88
  74. data/lib/hocon/impl/simple_config_origin.rb +263 -71
  75. data/lib/hocon/impl/simple_include_context.rb +31 -1
  76. data/lib/hocon/impl/simple_includer.rb +196 -1
  77. data/lib/hocon/impl/substitution_expression.rb +38 -0
  78. data/lib/hocon/impl/token.rb +17 -4
  79. data/lib/hocon/impl/token_type.rb +6 -2
  80. data/lib/hocon/impl/tokenizer.rb +339 -109
  81. data/lib/hocon/impl/tokens.rb +330 -79
  82. data/lib/hocon/impl/unmergeable.rb +14 -1
  83. data/lib/hocon/impl/unsupported_operation_error.rb +6 -0
  84. data/lib/hocon/impl/url.rb +37 -0
  85. data/lib/hocon/parser.rb +7 -0
  86. data/lib/hocon/parser/config_document.rb +92 -0
  87. data/lib/hocon/parser/config_document_factory.rb +36 -0
  88. data/lib/hocon/parser/config_node.rb +30 -0
  89. metadata +67 -43
  90. data/lib/hocon/impl/config_float.rb +0 -13
  91. data/lib/hocon/impl/parser.rb +0 -977
  92. data/lib/hocon/impl/properties_parser.rb +0 -83
@@ -1,83 +0,0 @@
1
- require 'hocon/impl'
2
- require 'hocon/config_error'
3
- require 'hocon/impl/config_impl'
4
-
5
- class Hocon::Impl::PropertiesParser
6
- def from_path_map(origin, path_map, converted_from_properties)
7
- # First, build a list of paths that will have values, either string or
8
- # object values.
9
- scope_paths = Set.new
10
- value_paths = Set.new
11
- path_map.each_key do |path|
12
- value_paths.add(path)
13
-
14
- next_path = path.parent
15
- while not next_path.nil? do
16
- scope_paths.add(next_path)
17
- next_path = next_path.parent
18
- end
19
- end
20
-
21
- if converted_from_properties
22
- # If any string values are also objects containing other values,
23
- # drop those string values - objects "win".
24
- value_paths = value_paths - scope_paths
25
- else
26
- # If we didn't start out as properties, then this is an error.
27
- value_paths.each do |path|
28
- if scope_paths.include?(path)
29
- raise ConfigBugOrBrokenError.new("In the map, path '#{path.render}' occurs as both" +
30
- " the parent object of a value and as a value. Because Map " +
31
- "has no defined ordering, this is a broken situation.", nil)
32
- end
33
- end
34
- end
35
-
36
- # Create maps for the object-valued values.
37
- root = Hash.new
38
- scopes = Hash.new
39
-
40
- value_paths.each do |path|
41
- parent_path = path.parent
42
- parent = (not parent_path.nil?) ? scopes[parent_path] : root
43
-
44
- last = path.last
45
- raw_value = path_map.get(path)
46
- if converted_from_properties
47
- if raw_value.is_a?(String)
48
- value = Hocon::Impl::ConfigString.new(origin, raw_value)
49
- else
50
- value = nil
51
- end
52
- else
53
- value = Hocon::Impl::ConfigImpl.from_any_ref_impl(path_map[path], origin, Hocon::Impl::FromMapMode::KEYS_ARE_PATHS)
54
- end
55
- if not value.nil?
56
- parent[last, value]
57
- end
58
- end
59
-
60
- # Make a list of scope paths from longest to shortest, so children go
61
- # before parents.
62
- sorted_scope_paths = Array.new
63
- sorted_scope_paths = sorted_scope_paths + scope_paths
64
- sorted_scope_paths.sort! do |a,b|
65
- b.length <=> a.length
66
- end
67
-
68
- # Create ConfigObject for each scope map, working from children to
69
- # parents to avoid modifying any already-created ConfigObject. This is
70
- # where we need the sorted list.
71
- sorted_scope_paths.each do |scope_path|
72
- scope = scopes[scope_path]
73
-
74
- parent_path = scope_path.parent
75
- parent = (not parent_path.nil?) ? scopes[parent_path] : root
76
-
77
- o = Hocon::Impl::SimpleConfigObject.new(origin, scope, Hocon::Impl::ResolveStatus::RESOLVED, false)
78
- parent[scope_path.last, o]
79
- end
80
-
81
- Hocon::Impl::SimpleConfigObject.new(origin, root, Hocon::Impl::ResolveStatus::RESOLVED, false)
82
- end
83
- end