hcl_parser 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/hcl_parser/loader.rb +11 -7
- data/lib/hcl_parser/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6570c678f64e03d6dd6fca6b1bc4800cb7eafc3222ca02784e6f62c148279672
|
4
|
+
data.tar.gz: 0ea732a8d48b24527220721fb79bf9f2c28c38a35dc1bfe6953799cef90409db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 778963fb140bc4fb1457370d930569a4901f0831c5471af1a977abba845d78a7ce732661eacd2abf1986b5fe26c907b27a7dd8c88876d0cce21c6927d51c4e63
|
7
|
+
data.tar.gz: 702c25648f6259a3f8dbae407768692b9969c033792e92d167f9d5f335b939c773829015536382b406afe69e3c73568ed9e6fa57ccca48adfadfb070034490c4
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,9 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
This project *loosely tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
|
5
5
|
|
6
|
+
## [0.2.1] - 2021-11-28
|
7
|
+
- [#2](https://github.com/boltops-tools/hcl_parser/pull/2) improve complex type parser: handle any
|
8
|
+
|
6
9
|
## [0.2.0] - 2021-11-25
|
7
10
|
- [#1](https://github.com/boltops-tools/hcl_parser/pull/1) Complex types
|
8
11
|
|
data/lib/hcl_parser/loader.rb
CHANGED
@@ -32,14 +32,14 @@ module HclParser
|
|
32
32
|
lines.each_with_index do |l,i|
|
33
33
|
# We dont rewrite lines until the next line/iteration
|
34
34
|
# This is actually the next iteration since we set rewrite_lines = true previously
|
35
|
-
# in rewrite_lines =
|
35
|
+
# in rewrite_lines = complex_type_lines?(lookahead_lines)
|
36
36
|
if rewrite_lines
|
37
|
-
if
|
38
|
-
results << l
|
39
|
-
elsif simple_default_assignment?(l)
|
37
|
+
if complex_type_line?(l)
|
40
38
|
# Doesnt matter what the default value is as long as there is one
|
41
39
|
# Doing this in case the default value spans multiple lines
|
42
40
|
results << ' default = "any"'
|
41
|
+
elsif simple_default_assignment?(l)
|
42
|
+
results << l
|
43
43
|
else
|
44
44
|
results << "# #{l}"
|
45
45
|
end
|
@@ -54,7 +54,7 @@ module HclParser
|
|
54
54
|
variable_start_index = i
|
55
55
|
variable_end_index = variable_end_index(lines, variable_start_index)
|
56
56
|
lookahead_lines = lines[variable_start_index..variable_end_index]
|
57
|
-
rewrite_lines =
|
57
|
+
rewrite_lines = complex_type_lines?(lookahead_lines)
|
58
58
|
end
|
59
59
|
|
60
60
|
# Disable rewriting before reaching the end of the variable definition so: i + 1
|
@@ -72,12 +72,16 @@ module HclParser
|
|
72
72
|
line.match(/default\s*=\s*("|'|null)/)
|
73
73
|
end
|
74
74
|
|
75
|
-
def
|
75
|
+
def complex_type_lines?(lines)
|
76
76
|
!!lines.find do |l|
|
77
|
-
l
|
77
|
+
complex_type_line?(l)
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
|
+
def complex_type_line?(l)
|
82
|
+
l.match(/object\(/) || l.match(/=\s*"any/)
|
83
|
+
end
|
84
|
+
|
81
85
|
def variable_end_index(lines, variable_start_index)
|
82
86
|
end_variable_index = nil
|
83
87
|
lines.each_with_index do |l,i|
|
data/lib/hcl_parser/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hcl_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tung Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-11-
|
11
|
+
date: 2021-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rhcl
|