codeclimate-yaml 0.2.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cc/yaml/nodes.rb +1 -0
- data/lib/cc/yaml/nodes/engine_config.rb +1 -1
- data/lib/cc/yaml/nodes/mapping.rb +12 -8
- data/lib/cc/yaml/nodes/nested_config.rb +24 -0
- data/lib/cc/yaml/nodes/open_mapping.rb +1 -1
- data/lib/cc/yaml/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71d782fa25bad738efd94fcc20f94902ac73d485
|
4
|
+
data.tar.gz: c22fdb5275b93887fefd1f6cb11a925089fd4a30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e876bb9daf725313ac2ded6d0ded54464b4bfe57e38e4dff07aaf371d2daa51dd646dd19fd3bdc4202f3a4c05c80f1f55ede032e8cad96c6a388a4f23b01c7b3
|
7
|
+
data.tar.gz: bc1ff4e054002bb4b3c100805100de89adee6fd9438538860134d3a2d3c61865299f43004f69f74b53044bfc72cab9d7f2965c1d14ace12df4181acf2a4f0a83
|
data/lib/cc/yaml/nodes.rb
CHANGED
@@ -10,6 +10,7 @@ module CC
|
|
10
10
|
autoload :GlobList, "cc/yaml/nodes/glob_list"
|
11
11
|
autoload :LanguageList, "cc/yaml/nodes/language_list"
|
12
12
|
autoload :Mapping, "cc/yaml/nodes/mapping"
|
13
|
+
autoload :NestedConfig, "cc/yaml/nodes/nested_config"
|
13
14
|
autoload :Node, "cc/yaml/nodes/node"
|
14
15
|
autoload :OpenMapping, "cc/yaml/nodes/open_mapping"
|
15
16
|
autoload :Ratings, "cc/yaml/nodes/ratings"
|
@@ -35,7 +35,7 @@ module CC::Yaml
|
|
35
35
|
define_method("#{key}?") { | | !!self[key] } unless method_defined? "#{key}?"
|
36
36
|
end
|
37
37
|
|
38
|
-
def self.
|
38
|
+
def self.subnode_for_key(key)
|
39
39
|
mapping[aliases.fetch(key.to_s, key.to_s)]
|
40
40
|
end
|
41
41
|
|
@@ -72,13 +72,12 @@ module CC::Yaml
|
|
72
72
|
end
|
73
73
|
|
74
74
|
def visit_key_value(visitor, key, value)
|
75
|
-
node =
|
76
|
-
|
77
|
-
visitor.accept(node, value)
|
75
|
+
node = subnode_for_key(key)
|
76
|
+
assign_node_and_visit(node, key, value, visitor)
|
78
77
|
end
|
79
78
|
|
80
79
|
def set_warnings(key)
|
81
|
-
if
|
80
|
+
if subnode_for_key(key)
|
82
81
|
check_duplicates(key)
|
83
82
|
else
|
84
83
|
warning("unexpected key %p, dropping", key)
|
@@ -114,8 +113,8 @@ module CC::Yaml
|
|
114
113
|
self.class.mapping.include? key
|
115
114
|
end
|
116
115
|
|
117
|
-
def
|
118
|
-
type = self.class.
|
116
|
+
def subnode_for_key(key)
|
117
|
+
type = self.class.subnode_for_key(key)
|
119
118
|
type.new(self) if type
|
120
119
|
end
|
121
120
|
|
@@ -141,7 +140,7 @@ module CC::Yaml
|
|
141
140
|
def verify_required
|
142
141
|
self.class.required.each do |key|
|
143
142
|
next if @mapping.include? key
|
144
|
-
type = self.class.
|
143
|
+
type = self.class.subnode_for_key(key)
|
145
144
|
if type.has_default?
|
146
145
|
warning "missing key %p, defaulting to %p", key, type.default
|
147
146
|
@mapping[key] = type.new(self)
|
@@ -183,6 +182,11 @@ module CC::Yaml
|
|
183
182
|
|
184
183
|
protected
|
185
184
|
|
185
|
+
def assign_node_and_visit(node, key, value, visitor)
|
186
|
+
self[key] = node
|
187
|
+
visitor.accept(node, value)
|
188
|
+
end
|
189
|
+
|
186
190
|
def dup_values
|
187
191
|
duped_mapping = @mapping.map { |key, value| [key.dup, value.dup] }
|
188
192
|
@mapping = Hash[duped_mapping]
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module CC
|
2
|
+
module Yaml
|
3
|
+
module Nodes
|
4
|
+
class NestedConfig < OpenMapping
|
5
|
+
def visit_key_value(visitor, key, value)
|
6
|
+
node = subnode_for_pair(key, value)
|
7
|
+
assign_node_and_visit(node, key, value, visitor)
|
8
|
+
end
|
9
|
+
|
10
|
+
protected
|
11
|
+
|
12
|
+
def subnode_for_pair(key, value)
|
13
|
+
if value.is_a?(::Psych::Nodes::Mapping)
|
14
|
+
NestedConfig.new(self)
|
15
|
+
elsif value.is_a?(::Psych::Nodes::Sequence)
|
16
|
+
Sequence.new(self)
|
17
|
+
else
|
18
|
+
subnode_for_key(key)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/cc/yaml/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: codeclimate-yaml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code Climate
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: secure_string
|
@@ -55,6 +55,7 @@ files:
|
|
55
55
|
- lib/cc/yaml/nodes/glob_list.rb
|
56
56
|
- lib/cc/yaml/nodes/language_list.rb
|
57
57
|
- lib/cc/yaml/nodes/mapping.rb
|
58
|
+
- lib/cc/yaml/nodes/nested_config.rb
|
58
59
|
- lib/cc/yaml/nodes/node.rb
|
59
60
|
- lib/cc/yaml/nodes/open_mapping.rb
|
60
61
|
- lib/cc/yaml/nodes/ratings.rb
|