Class: ForemanAnsibleDirector::AnsibleContent::ParsedAnsibleContentUnit
- Inherits:
-
Object
- Object
- ForemanAnsibleDirector::AnsibleContent::ParsedAnsibleContentUnit
- Defined in:
- app/lib/foreman_ansible_director/ansible_content/parsed_ansible_content_unit.rb
Instance Attribute Summary collapse
-
#scm ⇒ Object
readonly
Returns the value of attribute scm.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#src ⇒ Object
readonly
Returns the value of attribute src.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#unit_type ⇒ Object
readonly
Returns the value of attribute unit_type.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #collection_file ⇒ Object
- #git? ⇒ Boolean
-
#initialize(unit_type, **kwargs) ⇒ ParsedAnsibleContentUnit
constructor
A new instance of ParsedAnsibleContentUnit.
-
#name ⇒ Object
Full name of the content unit “theforeman.operations” –> “theforeman.operations”.
- #role_url ⇒ Object
-
#unit_name ⇒ Object
Name of the content unit with respect to the namespace: “theforeman.operations” –> “operations”.
-
#unit_namespace ⇒ Object
Namespace of the content unit “theforeman.operations” –> “theforeman”.
Constructor Details
#initialize(unit_type, **kwargs) ⇒ ParsedAnsibleContentUnit
Returns a new instance of ParsedAnsibleContentUnit.
8 9 10 11 12 13 14 15 16 |
# File 'app/lib/foreman_ansible_director/ansible_content/parsed_ansible_content_unit.rb', line 8 def initialize(unit_type, **kwargs) @unit_type = unit_type @name = kwargs['name'] @version = kwargs['version'] @source = kwargs['source'] || Setting[:ad_default_galaxy_url] @type = kwargs['type'] @src = kwargs['src'] @scm = kwargs['scm'] end |
Instance Attribute Details
#scm ⇒ Object (readonly)
Returns the value of attribute scm.
6 7 8 |
# File 'app/lib/foreman_ansible_director/ansible_content/parsed_ansible_content_unit.rb', line 6 def scm @scm end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
6 7 8 |
# File 'app/lib/foreman_ansible_director/ansible_content/parsed_ansible_content_unit.rb', line 6 def source @source end |
#src ⇒ Object (readonly)
Returns the value of attribute src.
6 7 8 |
# File 'app/lib/foreman_ansible_director/ansible_content/parsed_ansible_content_unit.rb', line 6 def src @src end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
6 7 8 |
# File 'app/lib/foreman_ansible_director/ansible_content/parsed_ansible_content_unit.rb', line 6 def type @type end |
#unit_type ⇒ Object (readonly)
Returns the value of attribute unit_type.
6 7 8 |
# File 'app/lib/foreman_ansible_director/ansible_content/parsed_ansible_content_unit.rb', line 6 def unit_type @unit_type end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
6 7 8 |
# File 'app/lib/foreman_ansible_director/ansible_content/parsed_ansible_content_unit.rb', line 6 def version @version end |
Instance Method Details
#collection_file ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'app/lib/foreman_ansible_director/ansible_content/parsed_ansible_content_unit.rb', line 53 def collection_file return unless @unit_type == :collection YAML.dump( { 'collections' => [ { 'name' => @name, 'version' => @version, 'source' => @source, 'type' => @type, }.compact, ] } ) end |
#git? ⇒ Boolean
18 19 20 21 22 23 24 25 |
# File 'app/lib/foreman_ansible_director/ansible_content/parsed_ansible_content_unit.rb', line 18 def git? case @unit_type when :role true if @scm == 'git' when :collection true if @type == 'git' end end |
#name ⇒ Object
Full name of the content unit “theforeman.operations” –> “theforeman.operations”
29 30 31 32 |
# File 'app/lib/foreman_ansible_director/ansible_content/parsed_ansible_content_unit.rb', line 29 def name return @name if @name infer_name_from_source end |
#role_url ⇒ Object
46 47 48 49 50 51 |
# File 'app/lib/foreman_ansible_director/ansible_content/parsed_ansible_content_unit.rb', line 46 def role_url return unless @unit_type == :role split = @name.split('.') # TODO: global param, version restriction "https://galaxy.ansible.com/api/v1/roles/?owner__username=#{split[0]}&name=#{split[1]}" end |
#unit_name ⇒ Object
Name of the content unit with respect to the namespace: “theforeman.operations” –> “operations”
36 37 38 |
# File 'app/lib/foreman_ansible_director/ansible_content/parsed_ansible_content_unit.rb', line 36 def unit_name name.split('.').last end |
#unit_namespace ⇒ Object
Namespace of the content unit “theforeman.operations” –> “theforeman”
42 43 44 |
# File 'app/lib/foreman_ansible_director/ansible_content/parsed_ansible_content_unit.rb', line 42 def unit_namespace name.split('.').first end |