Class: WifiWand::Platforms::Mac::Helper::Setup
- Inherits:
-
Object
- Object
- WifiWand::Platforms::Mac::Helper::Setup
- Defined in:
- lib/wifi_wand/platforms/mac/helper/setup.rb
Defined Under Namespace
Classes: Result
Constant Summary collapse
- SupportStatus =
Bundle::HelperSupportStatus
Instance Method Summary collapse
-
#check_status ⇒ Result
Inspect the current installation and return a Result value object.
- #helper_support_status ⇒ Object
-
#initialize(out_stream: $stdout, macos_version_reader: nil) ⇒ Setup
constructor
A new instance of Setup.
-
#install_helper ⇒ Object
Install the helper for the first time (or skip if already valid).
-
#open_location_settings ⇒ Object
Open the macOS System Settings pane for Location Services so the user can grant permission to wifiwand-helper.
-
#reinstall_helper ⇒ String
Force-replace the installed bundle regardless of current validity, then re-validate.
-
#remove_helper ⇒ String
Remove the helper application files installed for the current WifiWand version.
Constructor Details
#initialize(out_stream: $stdout, macos_version_reader: nil) ⇒ Setup
Returns a new instance of Setup.
67 68 69 70 |
# File 'lib/wifi_wand/platforms/mac/helper/setup.rb', line 67 def initialize(out_stream: $stdout, macos_version_reader: nil) @out_stream = out_stream @macos_version_reader = macos_version_reader || -> { Bundle.detect_macos_version } end |
Instance Method Details
#check_status ⇒ Result
Inspect the current installation and return a Result value object.
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/wifi_wand/platforms/mac/helper/setup.rb', line 80 def check_status support_status = helper_support_status return unsupported_result(support_status) if support_status.unsupported? helper_path = Bundle.installed_executable_path installed = File.executable?(helper_path) valid = installed && Bundle.helper_installed_and_valid? , = (helper_path, valid) Result.new( installed: installed, valid: valid, authorized: , permission_message: , helper_applicable: true, macos_version: support_status.macos_version ) end |
#helper_support_status ⇒ Object
72 73 74 75 |
# File 'lib/wifi_wand/platforms/mac/helper/setup.rb', line 72 def helper_support_status macos_version = @macos_version_reader&.call Bundle.helper_support_status_for_macos_version(macos_version) end |
#install_helper ⇒ Object
Install the helper for the first time (or skip if already valid). Delegates to Bundle.ensure_helper_installed so that the standard validation + concurrent-install safeguards are honoured.
104 |
# File 'lib/wifi_wand/platforms/mac/helper/setup.rb', line 104 def install_helper = Bundle.ensure_helper_installed(out_stream: @out_stream) |
#open_location_settings ⇒ Object
Open the macOS System Settings pane for Location Services so the user can grant permission to wifiwand-helper.
136 137 138 |
# File 'lib/wifi_wand/platforms/mac/helper/setup.rb', line 136 def open_location_settings system('open', 'x-apple.systempreferences:com.apple.preference.security?Privacy_LocationServices') end |
#reinstall_helper ⇒ String
Force-replace the installed bundle regardless of current validity, then re-validate. Use this for the --reinstall path where the user knows the existing install is stale or macOS TCC has lost track of it.
112 113 114 115 116 117 118 119 120 121 |
# File 'lib/wifi_wand/platforms/mac/helper/setup.rb', line 112 def reinstall_helper Bundle.install_helper_bundle(out_stream: @out_stream, force: true) unless Bundle.helper_installed_and_valid? raise 'Helper reinstallation failed validation. ' \ 'Try running wifiwand-macos-setup again.' end Bundle.installed_bundle_path end |
#remove_helper ⇒ String
Remove the helper application files installed for the current WifiWand version. This intentionally does not try to mutate macOS TCC permission records; users can revoke Location Services access in System Settings.
128 129 130 131 132 |
# File 'lib/wifi_wand/platforms/mac/helper/setup.rb', line 128 def remove_helper install_dir = Bundle.versioned_install_dir FileUtils.rm_rf(install_dir) install_dir end |