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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 99b2eea4da4681293e2c23c06758471554c56a34811c6ff6c0fff5381cbbdc88
4
- data.tar.gz: 386ac2862e576b66272a277c44210cceea4b2aac7a25848517e0332f464fd261
3
+ metadata.gz: 6570c678f64e03d6dd6fca6b1bc4800cb7eafc3222ca02784e6f62c148279672
4
+ data.tar.gz: 0ea732a8d48b24527220721fb79bf9f2c28c38a35dc1bfe6953799cef90409db
5
5
  SHA512:
6
- metadata.gz: ff94566dcf96f1228370731ff355934bd38dd2f67a7cb6558ec2829d0fd23060cb25bb639ec8559cb7d2cada4658bd84476654cc848c76b50ac4a4767467c553
7
- data.tar.gz: ece0bd0213983d7619857db074105b950f681f82a395d3ef2acc792f043802987344f9ec684ebfa1a0687b5170cb05cb0ee1bfc7f5be1d975e7ed74becdfc3ec
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
 
@@ -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 = has_complex_type?(lookahead_lines)
35
+ # in rewrite_lines = complex_type_lines?(lookahead_lines)
36
36
  if rewrite_lines
37
- if simple_default_assignment?(l)
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 = has_complex_type?(lookahead_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 has_complex_type?(lines)
75
+ def complex_type_lines?(lines)
76
76
  !!lines.find do |l|
77
- l.match(/object\(/)
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|
@@ -1,3 +1,3 @@
1
1
  module HclParser
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
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.0
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-25 00:00:00.000000000 Z
11
+ date: 2021-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rhcl