Class: M365ActiveStorage::Generators::CheckGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- M365ActiveStorage::Generators::CheckGenerator
- Defined in:
- lib/generators/m365_active_storage/check/check_generator.rb
Overview
init the m365 active storage gem
Instance Method Summary collapse
-
#check_for_m365_credentials ⇒ Object
Validate m365 credentials and connectivity by making a test API call to Microsoft Graph.
-
#check_for_site_and_drive ⇒ Object
Validate that the configured sharepoint site and drive are accessible.
-
#check_service_set_to_sharepoint ⇒ Object
Check if the storage service is set to SharePoint.
-
#final_message ⇒ Object
Final message if all checks pass.
Instance Method Details
#check_for_m365_credentials ⇒ Object
Validate m365 credentials and connectivity by making a test API call to Microsoft Graph
14 15 16 17 18 19 20 21 22 |
# File 'lib/generators/m365_active_storage/check/check_generator.rb', line 14 def check_for_m365_credentials m365 = M365.new m365.ping? rescue RuntimeError => e say "MS Graph API connectivity failed.", :red say "Please check your credentials and configuration.", :red say e., :red exit end |
#check_for_site_and_drive ⇒ Object
Validate that the configured sharepoint site and drive are accessible
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/generators/m365_active_storage/check/check_generator.rb', line 25 def check_for_site_and_drive m365 = M365.new site_id, drive_id = m365.config_site_and_drive_id site = m365.find_site_by_id(site_id) drive = m365.find_sharepoint_drive_by_id(site_id, drive_id) if site unless site && drive say "Cannot connect to SharePoint site and document library.", :red say "Check your site and drive configuration.", :red exit end say "Site: #{site["displayName"]}, drive: #{drive["name"]}", :green end |
#check_service_set_to_sharepoint ⇒ Object
Check if the storage service is set to SharePoint. Just notify if not.
39 40 41 42 43 44 45 |
# File 'lib/generators/m365_active_storage/check/check_generator.rb', line 39 def check_service_set_to_sharepoint current_service = Rails.application.config.active_storage.service return if current_service == :sharepoint say "config.active_storage.service is set to #{current_service}", :yellow exit end |
#final_message ⇒ Object
Final message if all checks pass
48 49 50 |
# File 'lib/generators/m365_active_storage/check/check_generator.rb', line 48 def say "M365 Active Storage installation completed successfully!", :green end |