Module: Soltius::Utils::Json2Hcl
- Included in:
- Hcl
- Defined in:
- lib/soltius/utils/hcl.rb
Overview
HCL Parser, using json2hcl binary (github.com/kvz/json2hcl)
Constant Summary collapse
- PATH =
File.('../../../ext/json2hcl.rb', __dir__)
- EXISTS =
File.exists?(PATH)
Instance Method Summary collapse
-
#file_to_json(file) ⇒ Object
Reads a HCL file and parses it into JSON.
-
#json2hcl ⇒ Object
Returns the full path to binary json2hcl from ext/json2hcl.rb.
-
#to_json(str) ⇒ Object
Parses a HCL String into JSON.
Instance Method Details
#file_to_json(file) ⇒ Object
Reads a HCL file and parses it into JSON
59 60 61 |
# File 'lib/soltius/utils/hcl.rb', line 59 def file_to_json(file) `#{json2hcl} -reverse < #{file}` end |
#json2hcl ⇒ Object
Returns the full path to binary json2hcl from ext/json2hcl.rb
41 42 43 |
# File 'lib/soltius/utils/hcl.rb', line 41 def json2hcl File.read(PATH) end |
#to_json(str) ⇒ Object
Parses a HCL String into JSON
50 51 52 |
# File 'lib/soltius/utils/hcl.rb', line 50 def to_json(str) `echo #{str} | #{json2hcl} -reverse` end |