Sha256: 91840b2eadd8963e0bfdb769be680c1f6f4c107a857e17576f09b1f7eadbe8ea
Contents?: true
Size: 1.28 KB
Versions: 4
Compression:
Stored size: 1.28 KB
Contents
# HclParser Parse HCL files. The scope of this library is to only handle `variables.tf` and `backend.tf` files, as that's what's needed for Terraspace currently. ## Usage ```ruby require "hcl_parser" code =<<EOL variable "project" { description = "The name of the GCP Project" default = "test" type = "string" } variable "name_prefix" { type = "string" } EOL parser = HclParser::Loader.new(code) parser.load # Returns => # # {"variable"=> # {"project"=> # {"description"=>"The name of project", # "default"=>"test", # "type"=>"string"}, # "name_prefix"=>{"type"=>"string"}}} ``` ## Installation ```ruby gem 'hcl_parser' ``` ## Notes * Tried a few different Ruby HCL parsers: [hcl-checker](https://github.com/mfcastellani/hcl-checker), [hcl-rb](https://github.com/Ruin0x11/hcl-rb), [rhcl](https://github.com/winebarrel/rhcl), [ruby-hcl](https://github.com/sikula/ruby-hcl). They all seem to have one issue or another. * This library preprocesses the text fed to the parser to workaround the parser issues. It's a workaround. * Able to handle simple variable types and most complex types. * Not able to handle multi-line complex variable types. There's a spec to document this. * Will have to fix one of these parsers or write a new one. * Open to PRs to help.
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
hcl_parser-0.2.2 | README.md |
hcl_parser-0.2.1 | README.md |
hcl_parser-0.2.0 | README.md |
hcl_parser-0.1.0 | README.md |