Module: Beaker::DSL::Helpers::HoconHelpers
- Included in:
- Beaker::DSL::Helpers
- Defined in:
- lib/beaker/dsl/helpers/hocon_helpers.rb
Overview
For usage guides for these methods, check these sources:
-
Beaker acceptance tests in
acceptance/tests/base/dsl/helpers/hocon_helpers_test.rb
Convenience methods for modifying and reading Hocon configs
Instance Method Summary collapse
-
#hocon_file_edit_in_place_on(hosts, filename) ⇒ Object
Grabs the given hocon file from a SUT, allowing you to edit the file and have those edits saved in-place of the file on the SUT.
-
#hocon_file_edit_on(hosts, filename) {|Host| ... } ⇒ Object
Grabs the given hocon file from a SUT, allowing you to edit the file just like you would a local one in the passed block.
-
#hocon_file_read_on(host, filename) ⇒ Hocon::ConfigValueFactory
Reads the given hocon file from a SUT.
Instance Method Details
#hocon_file_edit_in_place_on(hosts, filename) ⇒ Object
that a the crucial difference between this & #hocon_file_edit_on is that your Proc will need to return the Hocon::ConfigValueFactory doc you want saved for the in-place save to work correctly.
for info about parameters, please checkout #hocon_file_edit_on.
Grabs the given hocon file from a SUT, allowing you to edit the file and have those edits saved in-place of the file on the SUT.
80 81 82 83 84 85 |
# File 'lib/beaker/dsl/helpers/hocon_helpers.rb', line 80 def hocon_file_edit_in_place_on(hosts, filename) hocon_file_edit_on(hosts, filename) do |host, doc| content_doc = yield host, doc create_remote_file(host, filename, content_doc.render) end end |
#hocon_file_edit_on(hosts, filename) {|Host| ... } ⇒ Object
This method does not save the hocon file after editing. Our recommended workflow for that is included in our example. If you’d rather just save a file in-place on a SUT, then #hocon_file_edit_in_place_on is a better method to use.
Grabs the given hocon file from a SUT, allowing you to edit the file just like you would a local one in the passed block.
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/beaker/dsl/helpers/hocon_helpers.rb', line 53 def hocon_file_edit_on(hosts, filename) if not block_given? msg = 'DSL method `hocon_file_edit_on` provides a given block' msg << ' a hocon file to edit. No block was provided.' raise ArgumentError, msg end block_on hosts, {} do |host| doc = hocon_file_read_on(host, filename) yield host, doc end end |
#hocon_file_read_on(host, filename) ⇒ Hocon::ConfigValueFactory
Reads the given hocon file from a SUT
20 21 22 23 24 25 |
# File 'lib/beaker/dsl/helpers/hocon_helpers.rb', line 20 def hocon_file_read_on(host, filename) raise ArgumentError, '#hocon_file_edit_on requires a filename' if filename.nil? || filename.empty? file_contents = on(host, "cat #{filename}").stdout Hocon::Parser::ConfigDocumentFactory.parse_string(file_contents) end |