Class: Kamal::Commander::Specifics
- Inherits:
-
Object
- Object
- Kamal::Commander::Specifics
- Defined in:
- lib/kamal/commander/specifics.rb
Instance Attribute Summary collapse
-
#hosts ⇒ Object
readonly
Returns the value of attribute hosts.
-
#primary_host ⇒ Object
readonly
Returns the value of attribute primary_host.
-
#primary_role ⇒ Object
readonly
Returns the value of attribute primary_role.
-
#roles ⇒ Object
readonly
Returns the value of attribute roles.
Instance Method Summary collapse
- #accessory_hosts ⇒ Object
-
#initialize(config, specific_hosts, specific_roles) ⇒ Specifics
constructor
A new instance of Specifics.
- #proxy_hosts ⇒ Object
- #roles_on(host) ⇒ Object
Constructor Details
#initialize(config, specific_hosts, specific_roles) ⇒ Specifics
Returns a new instance of Specifics.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/kamal/commander/specifics.rb', line 5 def initialize(config, specific_hosts, specific_roles) @config, @specific_hosts, @specific_roles = config, specific_hosts, specific_roles @roles, @hosts = specified_roles, specified_hosts @primary_host = specific_hosts&.first || primary_specific_role&.primary_host || config.primary_host @primary_role = primary_or_first_role(roles_on(primary_host)) stable_sort!(roles) { |role| role == primary_role ? 0 : 1 } stable_sort!(hosts) { |host| roles_on(host).any? { |role| role == primary_role } ? 0 : 1 } end |
Instance Attribute Details
#hosts ⇒ Object (readonly)
Returns the value of attribute hosts.
2 3 4 |
# File 'lib/kamal/commander/specifics.rb', line 2 def hosts @hosts end |
#primary_host ⇒ Object (readonly)
Returns the value of attribute primary_host.
2 3 4 |
# File 'lib/kamal/commander/specifics.rb', line 2 def primary_host @primary_host end |
#primary_role ⇒ Object (readonly)
Returns the value of attribute primary_role.
2 3 4 |
# File 'lib/kamal/commander/specifics.rb', line 2 def primary_role @primary_role end |
#roles ⇒ Object (readonly)
Returns the value of attribute roles.
2 3 4 |
# File 'lib/kamal/commander/specifics.rb', line 2 def roles @roles end |
Instance Method Details
#accessory_hosts ⇒ Object
25 26 27 |
# File 'lib/kamal/commander/specifics.rb', line 25 def accessory_hosts config.accessories.flat_map(&:hosts) & specified_hosts end |
#proxy_hosts ⇒ Object
21 22 23 |
# File 'lib/kamal/commander/specifics.rb', line 21 def proxy_hosts config.proxy_hosts & specified_hosts end |
#roles_on(host) ⇒ Object
17 18 19 |
# File 'lib/kamal/commander/specifics.rb', line 17 def roles_on(host) roles.select { |role| role.hosts.include?(host.to_s) } end |