Class: Fastlane::Helper::SyncDevicesHelper::DevicePatch
- Inherits:
-
Object
- Object
- Fastlane::Helper::SyncDevicesHelper::DevicePatch
- Defined in:
- lib/fastlane/plugin/sync_devices/helper/sync_devices_helper/device_patch.rb
Overview
Represents differences between 2 devices.
Instance Attribute Summary collapse
- #new_device ⇒ Spaceship::ConnectAPI::Device readonly
- #old_device ⇒ Spaceship::ConnectAPI::Device readonly
Instance Method Summary collapse
- #command ⇒ Command::Base
- #created? ⇒ Boolean
- #disabled? ⇒ Boolean
- #enabled? ⇒ Boolean
-
#initialize(old_device, new_device) ⇒ DevicePatch
constructor
A new instance of DevicePatch.
- #platform_changed? ⇒ Boolean
- #renamed? ⇒ Boolean
Constructor Details
#initialize(old_device, new_device) ⇒ DevicePatch
Returns a new instance of DevicePatch.
15 16 17 18 |
# File 'lib/fastlane/plugin/sync_devices/helper/sync_devices_helper/device_patch.rb', line 15 def initialize(old_device, new_device) @old_device = old_device @new_device = new_device end |
Instance Attribute Details
#new_device ⇒ Spaceship::ConnectAPI::Device (readonly)
11 12 13 |
# File 'lib/fastlane/plugin/sync_devices/helper/sync_devices_helper/device_patch.rb', line 11 def new_device @new_device end |
#old_device ⇒ Spaceship::ConnectAPI::Device (readonly)
11 12 13 |
# File 'lib/fastlane/plugin/sync_devices/helper/sync_devices_helper/device_patch.rb', line 11 def old_device @old_device end |
Instance Method Details
#command ⇒ Command::Base
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/fastlane/plugin/sync_devices/helper/sync_devices_helper/device_patch.rb', line 47 def command # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity raise UnsupportedOperation.change_platform(old_device, new_device) if platform_changed? case [renamed?, enabled?, disabled?, created?] when [false, false, false, false] Command::Noop.new(old_device) when [false, false, false, true] Command::Create.new(new_device) when [false, false, true, false] Command::Disable.new(old_device) when [false, true, false, false] Command::Enable.new(old_device) when [true, false, false, false] Command::Rename.new(old_device, new_device.name) when [true, false, true, false] Command::DisableAndRename.new(old_device, new_device.name) when [true, true, false, false] Command::EnableAndRename.new(old_device, new_device.name) else # :nocov: raise UnsupportedOperation.internal_inconsistency(self, old_device, new_device) # :nocov: end end |
#created? ⇒ Boolean
36 37 38 |
# File 'lib/fastlane/plugin/sync_devices/helper/sync_devices_helper/device_patch.rb', line 36 def created? old_device.nil? && !!new_device&.enabled? end |
#disabled? ⇒ Boolean
31 32 33 |
# File 'lib/fastlane/plugin/sync_devices/helper/sync_devices_helper/device_patch.rb', line 31 def disabled? !!old_device && old_device.enabled? && !new_device&.enabled? end |
#enabled? ⇒ Boolean
26 27 28 |
# File 'lib/fastlane/plugin/sync_devices/helper/sync_devices_helper/device_patch.rb', line 26 def enabled? !!old_device && !old_device.enabled? && !!new_device&.enabled? end |
#platform_changed? ⇒ Boolean
41 42 43 |
# File 'lib/fastlane/plugin/sync_devices/helper/sync_devices_helper/device_patch.rb', line 41 def platform_changed? !!old_device && !!new_device && old_device.platform != new_device.platform end |
#renamed? ⇒ Boolean
21 22 23 |
# File 'lib/fastlane/plugin/sync_devices/helper/sync_devices_helper/device_patch.rb', line 21 def renamed? !!old_device && !!new_device && old_device.name != new_device.name end |