hocon 0.0.7 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +4 -2
- data/lib/hocon.rb +2 -0
- data/lib/hocon/config.rb +1010 -0
- data/lib/hocon/config_error.rb +32 -2
- data/lib/hocon/config_factory.rb +46 -0
- data/lib/hocon/config_include_context.rb +49 -0
- data/lib/hocon/config_includer_file.rb +27 -0
- data/lib/hocon/config_list.rb +49 -0
- data/lib/hocon/config_mergeable.rb +74 -0
- data/lib/hocon/config_object.rb +144 -1
- data/lib/hocon/config_parse_options.rb +33 -9
- data/lib/hocon/config_parseable.rb +51 -0
- data/lib/hocon/config_render_options.rb +4 -2
- data/lib/hocon/config_resolve_options.rb +31 -0
- data/lib/hocon/config_syntax.rb +5 -2
- data/lib/hocon/config_util.rb +73 -0
- data/lib/hocon/config_value.rb +122 -0
- data/lib/hocon/config_value_factory.rb +66 -2
- data/lib/hocon/config_value_type.rb +5 -2
- data/lib/hocon/impl.rb +2 -0
- data/lib/hocon/impl/abstract_config_node.rb +29 -0
- data/lib/hocon/impl/abstract_config_node_value.rb +11 -0
- data/lib/hocon/impl/abstract_config_object.rb +148 -42
- data/lib/hocon/impl/abstract_config_value.rb +251 -11
- data/lib/hocon/impl/array_iterator.rb +19 -0
- data/lib/hocon/impl/config_boolean.rb +7 -1
- data/lib/hocon/impl/config_concatenation.rb +177 -28
- data/lib/hocon/impl/config_delayed_merge.rb +329 -0
- data/lib/hocon/impl/config_delayed_merge_object.rb +274 -0
- data/lib/hocon/impl/config_document_parser.rb +647 -0
- data/lib/hocon/impl/config_double.rb +44 -0
- data/lib/hocon/impl/config_impl.rb +143 -19
- data/lib/hocon/impl/config_impl_util.rb +18 -0
- data/lib/hocon/impl/config_include_kind.rb +10 -0
- data/lib/hocon/impl/config_int.rb +13 -1
- data/lib/hocon/impl/config_node_array.rb +11 -0
- data/lib/hocon/impl/config_node_comment.rb +19 -0
- data/lib/hocon/impl/config_node_complex_value.rb +54 -0
- data/lib/hocon/impl/config_node_concatenation.rb +11 -0
- data/lib/hocon/impl/config_node_field.rb +81 -0
- data/lib/hocon/impl/config_node_include.rb +33 -0
- data/lib/hocon/impl/config_node_object.rb +276 -0
- data/lib/hocon/impl/config_node_path.rb +48 -0
- data/lib/hocon/impl/config_node_root.rb +60 -0
- data/lib/hocon/impl/config_node_simple_value.rb +42 -0
- data/lib/hocon/impl/config_node_single_token.rb +17 -0
- data/lib/hocon/impl/config_null.rb +15 -7
- data/lib/hocon/impl/config_number.rb +43 -4
- data/lib/hocon/impl/config_parser.rb +403 -0
- data/lib/hocon/impl/config_reference.rb +142 -0
- data/lib/hocon/impl/config_string.rb +55 -7
- data/lib/hocon/impl/container.rb +29 -0
- data/lib/hocon/impl/default_transformer.rb +24 -15
- data/lib/hocon/impl/from_map_mode.rb +3 -1
- data/lib/hocon/impl/full_includer.rb +2 -0
- data/lib/hocon/impl/memo_key.rb +42 -0
- data/lib/hocon/impl/mergeable_value.rb +8 -0
- data/lib/hocon/impl/origin_type.rb +8 -2
- data/lib/hocon/impl/parseable.rb +455 -91
- data/lib/hocon/impl/path.rb +181 -59
- data/lib/hocon/impl/path_builder.rb +24 -3
- data/lib/hocon/impl/path_parser.rb +280 -0
- data/lib/hocon/impl/replaceable_merge_stack.rb +22 -0
- data/lib/hocon/impl/resolve_context.rb +254 -0
- data/lib/hocon/impl/resolve_memos.rb +21 -0
- data/lib/hocon/impl/resolve_result.rb +39 -0
- data/lib/hocon/impl/resolve_source.rb +354 -0
- data/lib/hocon/impl/resolve_status.rb +3 -1
- data/lib/hocon/impl/simple_config.rb +264 -10
- data/lib/hocon/impl/simple_config_document.rb +48 -0
- data/lib/hocon/impl/simple_config_list.rb +282 -8
- data/lib/hocon/impl/simple_config_object.rb +424 -88
- data/lib/hocon/impl/simple_config_origin.rb +263 -71
- data/lib/hocon/impl/simple_include_context.rb +31 -1
- data/lib/hocon/impl/simple_includer.rb +196 -1
- data/lib/hocon/impl/substitution_expression.rb +38 -0
- data/lib/hocon/impl/token.rb +17 -4
- data/lib/hocon/impl/token_type.rb +6 -2
- data/lib/hocon/impl/tokenizer.rb +339 -109
- data/lib/hocon/impl/tokens.rb +330 -79
- data/lib/hocon/impl/unmergeable.rb +14 -1
- data/lib/hocon/impl/unsupported_operation_error.rb +6 -0
- data/lib/hocon/impl/url.rb +37 -0
- data/lib/hocon/parser.rb +7 -0
- data/lib/hocon/parser/config_document.rb +92 -0
- data/lib/hocon/parser/config_document_factory.rb +36 -0
- data/lib/hocon/parser/config_node.rb +30 -0
- metadata +67 -43
- data/lib/hocon/impl/config_float.rb +0 -13
- data/lib/hocon/impl/parser.rb +0 -977
- 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
|