Class: Proxy::AnsibleDirector::Helpers::ExecutionEnvironmentHelpers
- Inherits:
-
Object
- Object
- Proxy::AnsibleDirector::Helpers::ExecutionEnvironmentHelpers
- Defined in:
- lib/smart_proxy_ansible_director/helpers/execution_environment_helpers.rb
Class Method Summary collapse
- .format_content(content_units) ⇒ Object
- .reserialize_execution_environment(execution_environment_json) ⇒ Object
- .reserialize_inventory(inventory_json) ⇒ Object
- .reserialize_playbook(playbook_json) ⇒ Object
Class Method Details
.format_content(content_units) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/smart_proxy_ansible_director/helpers/execution_environment_helpers.rb', line 8 def format_content(content_units) collections = [] roles = [] content_units.each do |content_unit| formatted_unit = { name: content_unit['identifier'], version: content_unit['version'], source: content_unit['source'] } case content_unit['type'] when 'collection' collections << formatted_unit when 'role' roles << formatted_unit end end { collections: collections.length.positive? ? collections : nil, roles: roles.length.positive? ? roles : nil }.compact! end |
.reserialize_execution_environment(execution_environment_json) ⇒ Object
40 41 42 |
# File 'lib/smart_proxy_ansible_director/helpers/execution_environment_helpers.rb', line 40 def reserialize_execution_environment(execution_environment_json) YAML.dump(JSON.parse(execution_environment_json.to_h.to_json)) end |
.reserialize_inventory(inventory_json) ⇒ Object
32 33 34 |
# File 'lib/smart_proxy_ansible_director/helpers/execution_environment_helpers.rb', line 32 def reserialize_inventory(inventory_json) YAML.dump(JSON.parse(inventory_json.to_h.to_json)) end |
.reserialize_playbook(playbook_json) ⇒ Object
36 37 38 |
# File 'lib/smart_proxy_ansible_director/helpers/execution_environment_helpers.rb', line 36 def reserialize_playbook(playbook_json) YAML.dump(JSON.parse(playbook_json.to_json)) end |