Class: Fastlane::Helper::SyncDevicesHelper::DevicesPatch
- Inherits:
-
Object
- Object
- Fastlane::Helper::SyncDevicesHelper::DevicesPatch
- Defined in:
- lib/fastlane/plugin/sync_devices/helper/sync_devices_helper/devices_patch.rb
Overview
Represents a collection of DevicePatch.
Instance Attribute Summary collapse
- #commands ⇒ Array<DevicePatch> readonly
- #new_devices ⇒ Spaceship::ConnectAPI::Device readonly
- #old_devices ⇒ Spaceship::ConnectAPI::Device readonly
Instance Method Summary collapse
- #apply!(dry_run: false) ⇒ void
-
#initialize(old_devices, new_devices) ⇒ DevicesPatch
constructor
A new instance of DevicesPatch.
Constructor Details
#initialize(old_devices, new_devices) ⇒ DevicesPatch
Returns a new instance of DevicesPatch.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/fastlane/plugin/sync_devices/helper/sync_devices_helper/devices_patch.rb', line 19 def initialize(old_devices, new_devices) # rubocop:disable Metrics/AbcSize @old_devices = old_devices @new_devices = new_devices old_device_by_udid = old_devices.group_by { |d| d.udid.downcase }.transform_values(&:first) new_device_by_udid = new_devices.group_by { |d| d.udid.downcase }.transform_values(&:first) @commands = (old_device_by_udid.keys + new_device_by_udid.keys) .sort .uniq .map do |udid| old_device = old_device_by_udid[udid] new_device = new_device_by_udid[udid] DevicePatch.new(old_device, new_device).command end end |
Instance Attribute Details
#commands ⇒ Array<DevicePatch> (readonly)
15 16 17 |
# File 'lib/fastlane/plugin/sync_devices/helper/sync_devices_helper/devices_patch.rb', line 15 def commands @commands end |
#new_devices ⇒ Spaceship::ConnectAPI::Device (readonly)
13 14 15 |
# File 'lib/fastlane/plugin/sync_devices/helper/sync_devices_helper/devices_patch.rb', line 13 def new_devices @new_devices end |
#old_devices ⇒ Spaceship::ConnectAPI::Device (readonly)
13 14 15 |
# File 'lib/fastlane/plugin/sync_devices/helper/sync_devices_helper/devices_patch.rb', line 13 def old_devices @old_devices end |
Instance Method Details
#apply!(dry_run: false) ⇒ void
This method returns an undefined value.
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/fastlane/plugin/sync_devices/helper/sync_devices_helper/devices_patch.rb', line 37 def apply!(dry_run: false) @commands.each do |command| if dry_run UI.("(dry-run) #{command.description}") else command.run UI.(command.description) end end end |