Best Selenium code snippet using Platform.mac
portal_client.rb
Source:portal_client.rb
...75 def in_house?76 return @in_house unless @in_house.nil?77 @in_house = (team_information['type'] == 'In-House')78 end79 def platform_slug(mac)80 if mac81 'mac'82 else83 'ios'84 end85 end86 private :platform_slug87 #####################################################88 # @!group Apps89 #####################################################90 def apps(mac: false)91 paging do |page_number|92 r = request(:post, "account/#{platform_slug(mac)}/identifiers/listAppIds.action", {93 teamId: team_id,94 pageNumber: page_number,95 pageSize: page_size,96 sort: 'name=asc'97 })98 parse_response(r, 'appIds')99 end100 end101 def details_for_app(app)102 r = request(:post, "account/#{platform_slug(app.mac?)}/identifiers/getAppIdDetail.action", {103 teamId: team_id,104 appIdId: app.app_id105 })106 parse_response(r, 'appId')107 end108 def update_service_for_app(app, service)109 ensure_csrf(Spaceship::Portal::App)110 request(:post, service.service_uri, {111 teamId: team_id,112 displayId: app.app_id,113 featureType: service.service_id,114 featureValue: service.value115 })116 details_for_app(app)117 end118 def associate_groups_with_app(app, groups)119 ensure_csrf(Spaceship::Portal::AppGroup)120 request(:post, 'account/ios/identifiers/assignApplicationGroupToAppId.action', {121 teamId: team_id,122 appIdId: app.app_id,123 displayId: app.app_id,124 applicationGroups: groups.map(&:app_group_id)125 })126 details_for_app(app)127 end128 def associate_cloud_containers_with_app(app, containers)129 ensure_csrf(Spaceship::Portal::CloudContainer)130 request(:post, 'account/ios/identifiers/assignCloudContainerToAppId.action', {131 teamId: team_id,132 appIdId: app.app_id,133 cloudContainers: containers.map(&:cloud_container)134 })135 details_for_app(app)136 end137 def associate_merchants_with_app(app, merchants, mac)138 ensure_csrf(Spaceship::Portal::Merchant)139 request(:post, "account/#{platform_slug(mac)}/identifiers/assignOMCToAppId.action", {140 teamId: team_id,141 appIdId: app.app_id,142 omcIds: merchants.map(&:merchant_id)143 })144 details_for_app(app)145 end146 def valid_name_for(input)147 latinized = input.to_slug.transliterate148 latinized = latinized.gsub(/[^0-9A-Za-z\d\s]/, '') # remove non-valid characters149 # Check if the input string was modified, since it might be empty now150 # (if it only contained non-latin symbols) or the duplicate of another app151 if latinized != input152 latinized << " "153 latinized << Digest::MD5.hexdigest(input)154 end155 latinized156 end157 def create_app!(type, name, bundle_id, mac: false, enable_services: {})158 # We moved the ensure_csrf to the top of this method159 # as we got some users with issues around creating new apps160 # https://github.com/fastlane/fastlane/issues/5813161 ensure_csrf(Spaceship::Portal::App)162 ident_params = case type.to_sym163 when :explicit164 {165 type: 'explicit',166 identifier: bundle_id,167 inAppPurchase: 'on',168 gameCenter: 'on'169 }170 when :wildcard171 {172 type: 'wildcard',173 identifier: bundle_id174 }175 end176 params = {177 name: valid_name_for(name),178 teamId: team_id179 }180 params.merge!(ident_params)181 enable_services.each do |k, v|182 params[v.service_id.to_sym] = v.value183 end184 r = request(:post, "account/#{platform_slug(mac)}/identifiers/addAppId.action", params)185 parse_response(r, 'appId')186 end187 def delete_app!(app_id, mac: false)188 ensure_csrf(Spaceship::Portal::App)189 r = request(:post, "account/#{platform_slug(mac)}/identifiers/deleteAppId.action", {190 teamId: team_id,191 appIdId: app_id192 })193 parse_response(r)194 end195 def update_app_name!(app_id, name, mac: false)196 ensure_csrf(Spaceship::Portal::App)197 r = request(:post, "account/#{platform_slug(mac)}/identifiers/updateAppIdName.action", {198 teamId: team_id,199 appIdId: app_id,200 name: valid_name_for(name)201 })202 parse_response(r, 'appId')203 end204 #####################################################205 # @!group Passbook206 #####################################################207 def passbooks208 paging do |page_number|209 r = request(:post, "account/ios/identifiers/listPassTypeIds.action", {210 teamId: team_id,211 pageNumber: page_number,212 pageSize: page_size,213 sort: 'name=asc'214 })215 parse_response(r, 'passTypeIdList')216 end217 end218 def create_passbook!(name, bundle_id)219 ensure_csrf(Spaceship::Portal::Passbook)220 r = request(:post, "account/ios/identifiers/addPassTypeId.action", {221 name: name,222 identifier: bundle_id,223 teamId: team_id224 })225 parse_response(r, 'passTypeId')226 end227 def delete_passbook!(passbook_id)228 ensure_csrf(Spaceship::Portal::Passbook)229 r = request(:post, "account/ios/identifiers/deletePassTypeId.action", {230 teamId: team_id,231 passTypeId: passbook_id232 })233 parse_response(r)234 end235 #####################################################236 # @!group Website Push237 #####################################################238 def website_push(mac: false)239 paging do |page_number|240 r = request(:post, "account/#{platform_slug(mac)}/identifiers/listWebsitePushIds.action", {241 teamId: team_id,242 pageNumber: page_number,243 pageSize: page_size,244 sort: 'name=asc'245 })246 parse_response(r, 'websitePushIdList')247 end248 end249 def create_website_push!(name, bundle_id, mac: false)250 ensure_csrf(Spaceship::Portal::WebsitePush)251 r = request(:post, "account/#{platform_slug(mac)}/identifiers/addWebsitePushId.action", {252 name: name,253 identifier: bundle_id,254 teamId: team_id255 })256 parse_response(r, 'websitePushId')257 end258 def delete_website_push!(website_id, mac: false)259 ensure_csrf(Spaceship::Portal::WebsitePush)260 r = request(:post, "account/#{platform_slug(mac)}/identifiers/deleteWebsitePushId.action", {261 teamId: team_id,262 websitePushId: website_id263 })264 parse_response(r)265 end266 #####################################################267 # @!group Merchant268 #####################################################269 def merchants(mac: false)270 paging do |page_number|271 r = request(:post, "account/#{platform_slug(mac)}/identifiers/listOMCs.action", {272 teamId: team_id,273 pageNumber: page_number,274 pageSize: page_size,275 sort: 'name=asc'276 })277 parse_response(r, 'identifierList')278 end279 end280 def create_merchant!(name, bundle_id, mac: false)281 ensure_csrf(Spaceship::Portal::Merchant)282 r = request(:post, "account/#{platform_slug(mac)}/identifiers/addOMC.action", {283 name: name,284 identifier: bundle_id,285 teamId: team_id286 })287 parse_response(r, 'omcId')288 end289 def delete_merchant!(merchant_id, mac: false)290 ensure_csrf(Spaceship::Portal::Merchant)291 r = request(:post, "account/#{platform_slug(mac)}/identifiers/deleteOMC.action", {292 teamId: team_id,293 omcId: merchant_id294 })295 parse_response(r)296 end297 #####################################################298 # @!group App Groups299 #####################################################300 def app_groups301 paging do |page_number|302 r = request(:post, 'account/ios/identifiers/listApplicationGroups.action', {303 teamId: team_id,304 pageNumber: page_number,305 pageSize: page_size,306 sort: 'name=asc'307 })308 parse_response(r, 'applicationGroupList')309 end310 end311 def create_app_group!(name, group_id)312 ensure_csrf(Spaceship::Portal::AppGroup)313 r = request(:post, 'account/ios/identifiers/addApplicationGroup.action', {314 name: valid_name_for(name),315 identifier: group_id,316 teamId: team_id317 })318 parse_response(r, 'applicationGroup')319 end320 def delete_app_group!(app_group_id)321 ensure_csrf(Spaceship::Portal::AppGroup)322 r = request(:post, 'account/ios/identifiers/deleteApplicationGroup.action', {323 teamId: team_id,324 applicationGroup: app_group_id325 })326 parse_response(r)327 end328 #####################################################329 # @!group Cloud Containers330 #####################################################331 def cloud_containers332 paging do |page_number|333 r = request(:post, 'account/cloudContainer/listCloudContainers.action', {334 teamId: team_id,335 pageNumber: page_number,336 pageSize: page_size,337 sort: 'name=asc'338 })339 result = parse_response(r, 'cloudContainerList')340 csrf_cache[Spaceship::Portal::CloudContainer] = self.csrf_tokens341 result342 end343 end344 def create_cloud_container!(name, identifier)345 ensure_csrf(Spaceship::Portal::CloudContainer)346 r = request(:post, 'account/cloudContainer/addCloudContainer.action', {347 name: valid_name_for(name),348 identifier: identifier,349 teamId: team_id350 })351 parse_response(r, 'cloudContainer')352 end353 #####################################################354 # @!group Team355 #####################################################356 def team_members357 response = request(:post) do |req|358 req.url("/services-account/#{PROTOCOL_VERSION}/account/getTeamMembers")359 req.body = {360 teamId: team_id361 }.to_json362 req.headers['Content-Type'] = 'application/json'363 end364 parse_response(response)365 end366 def team_invited367 response = request(:post) do |req|368 req.url("/services-account/#{PROTOCOL_VERSION}/account/getInvites")369 req.body = {370 teamId: team_id371 }.to_json372 req.headers['Content-Type'] = 'application/json'373 end374 parse_response(response)375 end376 def team_set_role(team_member_id, role)377 ensure_csrf(Spaceship::Portal::Persons)378 response = request(:post) do |req|379 req.url("/services-account/#{PROTOCOL_VERSION}/account/setTeamMemberRoles")380 req.body = {381 teamId: team_id,382 role: role,383 teamMemberIds: [team_member_id]384 }.to_json385 req.headers['Content-Type'] = 'application/json'386 end387 parse_response(response)388 end389 def team_remove_member!(team_member_id)390 ensure_csrf(Spaceship::Portal::Persons)391 response = request(:post) do |req|392 req.url("/services-account/#{PROTOCOL_VERSION}/account/removeTeamMembers")393 req.body = {394 teamId: team_id,395 teamMemberIds: [team_member_id]396 }.to_json397 req.headers['Content-Type'] = 'application/json'398 end399 parse_response(response)400 end401 def team_invite(email, role)402 ensure_csrf(Spaceship::Portal::Persons)403 response = request(:post) do |req|404 req.url("/services-account/#{PROTOCOL_VERSION}/account/sendInvites")405 req.body = {406 invites: [407 { recipientEmail: email, recipientRole: role }408 ],409 teamId: team_id410 }.to_json411 req.headers['Content-Type'] = 'application/json'412 end413 parse_response(response)414 end415 #####################################################416 # @!group Devices417 #####################################################418 def devices(mac: false, include_disabled: false)419 paging do |page_number|420 r = request(:post, "account/#{platform_slug(mac)}/device/listDevices.action", {421 teamId: team_id,422 pageNumber: page_number,423 pageSize: page_size,424 sort: 'name=asc',425 includeRemovedDevices: include_disabled426 })427 result = parse_response(r, 'devices')428 csrf_cache[Spaceship::Portal::Device] = self.csrf_tokens429 result430 end431 end432 def devices_by_class(device_class, include_disabled: false)433 paging do |page_number|434 r = request(:post, 'account/ios/device/listDevices.action', {435 teamId: team_id,436 pageNumber: page_number,437 pageSize: page_size,438 sort: 'name=asc',439 deviceClasses: device_class,440 includeRemovedDevices: include_disabled441 })442 parse_response(r, 'devices')443 end444 end445 def create_device!(device_name, device_id, mac: false)446 ensure_csrf(Spaceship::Portal::Device)447 req = request(:post, "account/#{platform_slug(mac)}/device/addDevices.action", {448 teamId: team_id,449 deviceClasses: mac ? 'mac' : 'iphone',450 deviceNumbers: device_id,451 deviceNames: device_name,452 register: 'single'453 })454 devices = parse_response(req, 'devices')455 return devices.first unless devices.empty?456 validation_messages = parse_response(req, 'validationMessages').map { |message| message["validationUserMessage"] }.compact.uniq457 raise UnexpectedResponse.new, validation_messages.join('\n') unless validation_messages.empty?458 raise UnexpectedResponse.new, "Couldn't register new device, got this: #{parse_response(req)}"459 end460 def disable_device!(device_id, device_udid, mac: false)461 request(:post, "https://developer.apple.com/services-account/#{PROTOCOL_VERSION}/account/#{platform_slug(mac)}/device/deleteDevice.action", {462 teamId: team_id,463 deviceId: device_id464 })465 end466 def enable_device!(device_id, device_udid, mac: false)467 req = request(:post, "https://developer.apple.com/services-account/#{PROTOCOL_VERSION}/account/#{platform_slug(mac)}/device/enableDevice.action", {468 teamId: team_id,469 displayId: device_id,470 deviceNumber: device_udid471 })472 parse_response(req, 'device')473 end474 #####################################################475 # @!group Certificates476 #####################################################477 def certificates(types, mac: false)478 paging do |page_number|479 r = request(:post, "account/#{platform_slug(mac)}/certificate/listCertRequests.action", {480 teamId: team_id,481 types: types.join(','),482 pageNumber: page_number,483 pageSize: page_size,484 sort: 'certRequestStatusCode=asc'485 })486 parse_response(r, 'certRequests')487 end488 end489 def create_certificate!(type, csr, app_id = nil, mac = false)490 ensure_csrf(Spaceship::Portal::Certificate)491 r = request(:post, "account/#{platform_slug(mac)}/certificate/submitCertificateRequest.action", {492 teamId: team_id,493 type: type,494 csrContent: csr,495 appIdId: app_id, # optional496 specialIdentifierDisplayId: app_id, # For requesting Web Push certificates497 })498 parse_response(r, 'certRequest')499 end500 def download_certificate(certificate_id, type, mac: false)501 { type: type, certificate_id: certificate_id }.each { |k, v| raise "#{k} must not be nil" if v.nil? }502 r = request(:get, "account/#{platform_slug(mac)}/certificate/downloadCertificateContent.action", {503 teamId: team_id,504 certificateId: certificate_id,505 type: type506 })507 a = parse_response(r)508 if r.success? && a.include?("Apple Inc")509 return a510 else511 raise UnexpectedResponse.new, "Couldn't download certificate, got this instead: #{a}"512 end513 end514 def revoke_certificate!(certificate_id, type, mac: false)515 ensure_csrf(Spaceship::Portal::Certificate)516 r = request(:post, "account/#{platform_slug(mac)}/certificate/revokeCertificate.action", {517 teamId: team_id,518 certificateId: certificate_id,519 type: type520 })521 parse_response(r, 'certRequests')522 end523 #####################################################524 # @!group Provisioning Profiles525 #####################################################526 def provisioning_profiles(mac: false)527 paging do |page_number|528 req = request(:post, "account/#{platform_slug(mac)}/profile/listProvisioningProfiles.action", {529 teamId: team_id,530 pageNumber: page_number,531 pageSize: page_size,532 sort: 'name=asc',533 includeInactiveProfiles: true,534 onlyCountLists: true535 })536 result = parse_response(req, 'provisioningProfiles')537 csrf_cache[Spaceship::Portal::ProvisioningProfile] = self.csrf_tokens538 result539 end540 end541 ##542 # this endpoint is used by Xcode to fetch provisioning profiles.543 # The response is an xml plist but has the added benefit of containing the appId of each provisioning profile.544 #545 # Use this method over `provisioning_profiles` if possible because no secondary API calls are necessary to populate the ProvisioningProfile data model.546 def provisioning_profiles_via_xcode_api(mac: false)547 req = request(:post) do |r|548 r.url("https://developerservices2.apple.com/services/#{PROTOCOL_VERSION}/#{platform_slug(mac)}/listProvisioningProfiles.action")549 r.params = {550 teamId: team_id,551 includeInactiveProfiles: true,552 onlyCountLists: true553 }554 end555 result = parse_response(req, 'provisioningProfiles')556 csrf_cache[Spaceship::Portal::ProvisioningProfile] = self.csrf_tokens557 result558 end559 def provisioning_profile_details(provisioning_profile_id: nil, mac: false)560 r = request(:post, "account/#{platform_slug(mac)}/profile/getProvisioningProfile.action", {561 teamId: team_id,562 provisioningProfileId: provisioning_profile_id563 })564 parse_response(r, 'provisioningProfile')565 end566 def create_provisioning_profile!(name, distribution_method, app_id, certificate_ids, device_ids, mac: false, sub_platform: nil, template_name: nil)567 ensure_csrf(Spaceship::Portal::ProvisioningProfile) do568 fetch_csrf_token_for_provisioning569 end570 params = {571 teamId: team_id,572 provisioningProfileName: name,573 appIdId: app_id,574 distributionType: distribution_method,575 certificateIds: certificate_ids,576 deviceIds: device_ids577 }578 params[:subPlatform] = sub_platform if sub_platform579 # if `template_name` is nil, Default entitlements will be used580 params[:template] = template_name if template_name581 r = request(:post, "account/#{platform_slug(mac)}/profile/createProvisioningProfile.action", params)582 parse_response(r, 'provisioningProfile')583 end584 def download_provisioning_profile(profile_id, mac: false)585 ensure_csrf(Spaceship::Portal::ProvisioningProfile) do586 fetch_csrf_token_for_provisioning587 end588 r = request(:get, "account/#{platform_slug(mac)}/profile/downloadProfileContent", {589 teamId: team_id,590 provisioningProfileId: profile_id591 })592 a = parse_response(r)593 if r.success? && a.include?("DOCTYPE plist PUBLIC")594 return a595 else596 raise UnexpectedResponse.new, "Couldn't download provisioning profile, got this instead: #{a}"597 end598 end599 def delete_provisioning_profile!(profile_id, mac: false)600 fetch_csrf_token_for_provisioning601 r = request(:post, "account/#{platform_slug(mac)}/profile/deleteProvisioningProfile.action", {602 teamId: team_id,603 provisioningProfileId: profile_id604 })605 parse_response(r)606 end607 def repair_provisioning_profile!(profile_id, name, distribution_method, app_id, certificate_ids, device_ids, mac: false, sub_platform: nil, template_name: nil)608 fetch_csrf_token_for_provisioning609 params = {610 teamId: team_id,611 provisioningProfileId: profile_id,612 provisioningProfileName: name,613 appIdId: app_id,614 distributionType: distribution_method,615 certificateIds: certificate_ids.join(','),616 deviceIds: device_ids617 }618 params[:subPlatform] = sub_platform if sub_platform619 # if `template_name` is nil, Default entitlements will be used620 params[:template] = template_name if template_name621 r = request(:post, "account/#{platform_slug(mac)}/profile/regenProvisioningProfile.action", params)622 parse_response(r, 'provisioningProfile')623 end624 #####################################################625 # @!group Keys626 #####################################################627 def list_keys628 paging do |page_number|629 response = request(:post, 'account/auth/key/list', {630 teamId: team_id,631 pageNumber: page_number,632 pageSize: page_size,633 sort: 'name=asc'634 })635 parse_response(response, 'keys')636 end637 end638 def get_key(id: nil)639 response = request(:post, 'account/auth/key/get', { teamId: team_id, keyId: id })640 # response contains a list of keys with 1 item641 parse_response(response, 'keys').first642 end643 def download_key(id: nil)644 response = request(:get, 'account/auth/key/download', { teamId: team_id, keyId: id })645 parse_response(response)646 end647 def create_key!(name: nil, service_configs: nil)648 fetch_csrf_token_for_keys649 params = {650 name: name,651 serviceConfigurations: service_configs,652 teamId: team_id653 }654 response = request(:post, 'account/auth/key/create') do |req|655 req.headers['Content-Type'] = 'application/json'656 req.body = params.to_json657 end658 # response contains a list of keys with 1 item659 parse_response(response, 'keys').first660 end661 def revoke_key!(id: nil)662 fetch_csrf_token_for_keys663 response = request(:post, 'account/auth/key/revoke', { teamId: team_id, keyId: id })664 parse_response(response)665 end666 private667 # This is a cache of entity type (App, AppGroup, Certificate, Device) to csrf_tokens668 def csrf_cache669 @csrf_cache ||= {}670 end671 # Ensures that there are csrf tokens for the appropriate entity type672 # Relies on store_csrf_tokens to set csrf_tokens to the appropriate value673 # then stores that in the correct place in cache674 # This method also takes a block, if you want to send a custom request, instead of675 # calling `.all` on the given klass. This is used for provisioning profiles.676 def ensure_csrf(klass)677 if csrf_cache[klass]678 self.csrf_tokens = csrf_cache[klass]679 return680 end681 self.csrf_tokens = nil682 # If we directly create a new resource (e.g. app) without querying anything before683 # we don't have a valid csrf token, that's why we have to do at least one request684 block_given? ? yield : klass.all685 csrf_cache[klass] = self.csrf_tokens686 end687 # We need a custom way to fetch the csrf token for the provisioning profile requests, since688 # we use a separate API endpoint (host of Xcode API) to fetch the provisioning profiles689 # All we do is fetch one profile (if exists) to get a valid csrf token with its time stamp690 # This method is being called from all requests that modify, create or downloading provisioning691 # profiles.692 # Source https://github.com/fastlane/fastlane/issues/5903693 def fetch_csrf_token_for_provisioning(mac: false)694 response = request(:post, "account/#{platform_slug(mac)}/profile/listProvisioningProfiles.action", {695 teamId: team_id,696 pageNumber: 1,697 pageSize: 1,698 sort: 'name=asc'699 })700 parse_response(response, 'provisioningProfiles')701 return nil702 end703 def fetch_csrf_token_for_keys704 response = request(:post, 'account/auth/key/list', {705 teamId: team_id,706 pageNumber: 1,707 pageSize: 1,708 sort: 'name=asc'...
register_devices.rb
Source:register_devices.rb
2module Fastlane3 module Actions4 class RegisterDevicesAction < Action5 def self.is_supported?(platform)6 [:ios, :mac].include?(platform)7 end8 def self.run(params)9 require 'spaceship'10 devices = params[:devices]11 devices_file = params[:devices_file]12 mac = params[:platform] == "mac"13 credentials = CredentialsManager::AccountManager.new(user: params[:username])14 Spaceship.login(credentials.user, credentials.password)15 Spaceship.select_team16 UI.message("Fetching list of currently registered devices...")17 existing_devices = Spaceship::Device.all(mac: mac)18 if devices19 device_objs = devices.map do |k, v|20 next if existing_devices.map(&:udid).include?(v)21 try_create_device(name: k, udid: v, mac: mac)22 end23 elsif devices_file24 require 'csv'25 devices_file = CSV.read(File.expand_path(File.join(devices_file)), col_sep: "\t")26 UI.user_error!("Please provide a file according to the Apple Sample UDID file (https://devimages.apple.com.edgekey.net/downloads/devices/Multiple-Upload-Samples.zip)") unless devices_file.first == ['Device ID', 'Device Name']27 device_objs = devices_file.drop(1).map do |device|28 next if existing_devices.map(&:udid).include?(device[0])29 UI.user_error!("Invalid device line, please provide a file according to the Apple Sample UDID file (http://devimages.apple.com/downloads/devices/Multiple-Upload-Samples.zip)") unless device.count == 230 try_create_device(name: device[1], udid: device[0], mac: mac)31 end32 else33 UI.user_error!("You must pass either a valid `devices` or `devices_file`. Please check the readme.")34 end35 UI.success("Successfully registered new devices.")36 return device_objs37 end38 def self.try_create_device(name: nil, udid: nil, mac: false)39 Spaceship::Device.create!(name: name, udid: udid, mac: mac)40 rescue => ex41 UI.error(ex.to_s)42 UI.crash!("Failed to register new device (name: #{name}, UDID: #{udid})")43 end44 def self.description45 "Registers new devices to the Apple Dev Portal"46 end47 def self.available_options48 user = CredentialsManager::AppfileConfig.try_fetch_value(:apple_dev_portal_id)49 user ||= CredentialsManager::AppfileConfig.try_fetch_value(:apple_id)50 platform = Actions.lane_context[Actions::SharedValues::PLATFORM_NAME].to_s51 [52 FastlaneCore::ConfigItem.new(key: :devices,53 env_name: "FL_REGISTER_DEVICES_DEVICES",54 description: "A hash of devices, with the name as key and the UDID as value",55 is_string: false,56 type: Hash,57 optional: true),58 FastlaneCore::ConfigItem.new(key: :devices_file,59 env_name: "FL_REGISTER_DEVICES_FILE",60 description: "Provide a path to a file with the devices to register. For the format of the file see the examples",61 optional: true,62 verify_block: proc do |value|63 UI.user_error!("Could not find file '#{value}'") unless File.exist?(value)64 end),65 FastlaneCore::ConfigItem.new(key: :team_id,66 env_name: "REGISTER_DEVICES_TEAM_ID",67 code_gen_sensitive: true,68 default_value: CredentialsManager::AppfileConfig.try_fetch_value(:team_id),69 default_value_dynamic: true,70 description: "The ID of your Developer Portal team if you're in multiple teams",71 optional: true,72 verify_block: proc do |value|73 ENV["FASTLANE_TEAM_ID"] = value.to_s74 end),75 FastlaneCore::ConfigItem.new(key: :team_name,76 env_name: "REGISTER_DEVICES_TEAM_NAME",77 description: "The name of your Developer Portal team if you're in multiple teams",78 optional: true,79 code_gen_sensitive: true,80 default_value: CredentialsManager::AppfileConfig.try_fetch_value(:team_name),81 default_value_dynamic: true,82 verify_block: proc do |value|83 ENV["FASTLANE_TEAM_NAME"] = value.to_s84 end),85 FastlaneCore::ConfigItem.new(key: :username,86 env_name: "DELIVER_USER",87 description: "Optional: Your Apple ID",88 default_value: user,89 default_value_dynamic: true),90 FastlaneCore::ConfigItem.new(key: :platform,91 env_name: "REGISTER_DEVICES_PLATFORM",92 description: "The platform to use (optional)",93 optional: true,94 default_value: platform.empty? ? "ios" : platform,95 verify_block: proc do |value|96 UI.user_error!("The platform can only be ios or mac") unless %('ios', 'mac').include?(value)97 end)98 ]99 end100 def self.details101 [102 "This will register iOS/Mac devices with the Developer Portal so that you can include them in your provisioning profiles.",103 "This is an optimistic action, in that it will only ever add new devices to the member center, and never remove devices. If a device which has already been registered within the member center is not passed to this action, it will be left alone in the member center and continue to work.",104 "The action will connect to the Apple Developer Portal using the username you specified in your `Appfile` with `apple_id`, but you can override it using the `username` option, or by setting the env variable `ENV['DELIVER_USER']`."105 ].join("\n")106 end107 def self.author108 "lmirosevic"109 end110 def self.example_code111 [112 'register_devices(113 devices: {114 "Luka iPhone 6" => "1234567890123456789012345678901234567890",115 "Felix iPad Air 2" => "abcdefghijklmnopqrstvuwxyzabcdefghijklmn"116 }117 ) # Simply provide a list of devices as a Hash',118 'register_devices(119 devices_file: "./devices.txt"120 ) # Alternatively provide a standard UDID export .txt file, see the Apple Sample (http://devimages.apple.com/downloads/devices/Multiple-Upload-Samples.zip)',121 'register_devices(122 devices_file: "./devices.txt", # You must pass in either `devices_file` or `devices`.123 team_id: "XXXXXXXXXX", # Optional, if you"re a member of multiple teams, then you need to pass the team ID here.124 username: "luka@goonbee.com" # Optional, lets you override the Apple Member Center username.125 )',126 'register_devices(127 devices: {128 "Luka MacBook" => "12345678-1234-1234-1234-123456789012",129 "Felix MacBook Pro" => "ABCDEFGH-ABCD-ABCD-ABCD-ABCDEFGHIJKL"130 },131 platform: "mac"132 ) # Register devices for Mac'133 ]134 end135 def self.category136 :code_signing137 end138 end139 end140end...
base_helpers.rb
Source:base_helpers.rb
1module Pry::Helpers; end2# rubocop:disable Metrics/ModuleLength3module Pry::Helpers::BaseHelpers4 extend self5 @mac_osx_warn = false6 # @deprecated Use {Pry::Helpers::Platform.mac_osx?} instead.7 def mac_osx?8 unless @mac_osx_warn9 loc = caller_locations(1..1).first10 warn(11 "#{loc.path}:#{loc.lineno}: warning: method BaseHelpers##{__method__} " \12 "is deprecated. Use Pry:Helpers::Platform.#{__method__} instead"13 )14 @mac_osx_warn = true15 end16 Pry::Helpers::Platform.mac_osx?17 end18 @linux_warn = false19 # @deprecated Use {Pry::Helpers::Platform.mac_osx?} instead.20 def linux?21 unless @linux_warn22 loc = caller_locations(1..1).first23 warn(24 "#{loc.path}:#{loc.lineno}: warning: method BaseHelpers##{__method__} " \25 "is deprecated. Use Pry:Helpers::Platform.#{__method__} instead"26 )27 @linux_warn = true28 end29 Pry::Helpers::Platform.linux?30 end31 @windows_warn = false32 # @deprecated Use {Pry::Helpers::Platform.windows?} instead.33 def windows?...
bundle.rb
Source:bundle.rb
...7 command "explicitAllPlatformString" do |cmd|8 cmd.scope = "foo"9 cmd.invoke.all= "echo 'explicitAllPlatformString'"10 end11 command "macAndImplicitAllPlatformString" do |cmd|12 cmd.scope = "foo"13 cmd.invoke.mac = "echo 'macAndImplicitAllPlatformString'"14 cmd.invoke = "echo 'macAndImplicitAllPlatformString'"15 end16 command "macAndExplicitAllPlatformString" do |cmd|17 cmd.scope = "foo"18 cmd.invoke.mac = "echo 'macAndExplicitAllPlatformString'"19 cmd.invoke = "echo 'macAndExplicitAllPlatformString'"20 end21 command "macOnlyPlatformString" do |cmd|22 cmd.scope = "foo"23 cmd.invoke.mac = "echo 'macOnlyPlatformString'"24 end25 command "windowsAndImplicitAllPlatformString" do |cmd|26 cmd.scope = "foo"27 cmd.invoke.windows = "echo 'windowsAndImplicitAllPlatformString'"28 cmd.invoke = "echo 'windowsAndImplicitAllPlatformString'"29 end30 command "windowsAndExplicitAllPlatformString" do |cmd|31 cmd.scope = "foo"32 cmd.invoke.windows = "echo 'windowsAndExplicitAllPlatformString'"33 cmd.invoke = "echo 'windowsAndExplicitAllPlatformString'"34 end35 command "windowsOnlyPlatformString" do |cmd|36 cmd.scope = "foo"37 cmd.invoke.windows = "echo 'windowsOnlyPlatformString'"38 end39 command "linuxAndImplicitAllPlatformString" do |cmd|40 cmd.scope = "foo"41 cmd.invoke.linux = "echo 'linuxAndImplicitAllPlatformString'"42 cmd.invoke = "echo 'linuxAndImplicitAllPlatformString'"43 end44 command "linuxAndExplicitAllPlatformString" do |cmd|45 cmd.scope = "foo"46 cmd.invoke.linux = "echo 'linuxAndExplicitAllPlatformString'"47 cmd.invoke = "echo 'linuxAndExplicitAllPlatformString'"48 end49 command "linuxOnlyPlatformString" do |cmd|50 cmd.scope = "foo"51 cmd.invoke.linux = "echo 'linuxOnlyPlatformString'"52 end53 command "unixAndImplicitAllPlatformString" do |cmd|54 cmd.scope = "foo"55 cmd.invoke.unix = "echo 'unixAndImplicitAllPlatformString'"56 cmd.invoke = "echo 'unixAndImplicitAllPlatformString'"57 end58 command "unixAndExplicitAllPlatformString" do |cmd|59 cmd.scope = "foo"60 cmd.invoke.unix = "echo 'unixAndExplicitAllPlatformString'"61 cmd.invoke = "echo 'unixAndExplicitAllPlatformString'"62 end63 command "unixOnlyPlatformString" do |cmd|64 cmd.scope = "foo"65 cmd.invoke.unix = "echo 'unixOnlyPlatformString'"66 end67 command "implicitAllPlatformBlock" do |cmd|68 cmd.scope = "foo"69 cmd.invoke do 'implicitAllPlatformBlock' end70 end71 command "explicitAllPlatformBlock" do |cmd|72 cmd.scope = "foo"73 cmd.invoke.all do 'explicitAllPlatformBlock' end74 end75 command "macAndImplicitAllPlatformBlock" do |cmd|76 cmd.scope = "foo"77 cmd.invoke.mac do 'macAndImplicitAllPlatformBlock' end78 cmd.invoke do 'macAndImplicitAllPlatformBlock' end79 end80 command "macAndExplicitAllPlatformBlock" do |cmd|81 cmd.scope = "foo"82 cmd.invoke.mac do 'macAndExplicitAllPlatformBlock' end83 cmd.invoke do 'macAndExplicitAllPlatformBlock' end84 end85 command "macOnlyPlatformBlock" do |cmd|86 cmd.scope = "foo"87 cmd.invoke.mac do 'macOnlyPlatformBlock' end88 end89 command "windowsAndImplicitAllPlatformBlock" do |cmd|90 cmd.scope = "foo"91 cmd.invoke.windows do 'windowsAndImplicitAllPlatformBlock' end92 cmd.invoke do 'windowsAndImplicitAllPlatformBlock' end93 end94 command "windowsAndExplicitAllPlatformBlock" do |cmd|95 cmd.scope = "foo"96 cmd.invoke.windows do 'windowsAndExplicitAllPlatformBlock' end97 cmd.invoke do 'windowsAndExplicitAllPlatformBlock' end98 end99 command "windowsOnlyPlatformBlock" do |cmd|100 cmd.scope = "foo"101 cmd.invoke.windows do 'windowsOnlyPlatformBlock' end...
Rakefile
Source:Rakefile
...3end4def project_name5 'ChartsDemo-iOS/ChartsDemo-iOS.xcodeproj'6end7def macos_project_name8 'ChartsDemo-macOS/ChartsDemo-macOS.xcodeproj'9end10def configuration11 'Debug'12end13def test_platforms14 %i[15 iOS16 tvOS17 ]18end19def build_platforms20 [21 :macOS22 ]23end24def build_schemes25 %w[26 Charts27 ]28end29def build_demo_schemes30 %i[31 ChartsDemo-iOS32 ChartsDemo-iOS-Swift33 ]34end35def build_macos_demo_schemes36 [37 'ChartsDemo-macOS'38 ]39end40def test_schemes41 [42 'ChartsTests'43 ]44end45def devices46 {47 iOS: {48 sdk: 'iphonesimulator',49 device: "name='iPhone 7'",50 name: 'iPhone 7'51 },52 macOS: {53 sdk: 'macosx',54 device: "arch='x86_64'",55 uuid: nil56 },57 tvOS: {58 sdk: 'appletvsimulator',59 device: "name='Apple TV'",60 name: 'Apple TV'61 }62 }63end64def open_simulator_and_sleep(uuid)65 return if uuid.nil? # Don't need a sleep on macOS because it runs first.66 sh "xcrun instruments -w '#{uuid}' || sleep 15"67end68def xcodebuild(type, name, scheme, configuration, sdk, destination, tasks, xcprety_args)69 # set either workspace or project flag for xcodebuild70 case type71 when :project72 project_type = '-project'73 when :workspace74 project_type = '-workspace'75 else76 abort 'Invalid project type, use `:project` for xcodeproj and `:workspace` for xcworkspace.'77 end78 sh "set -o pipefail && xcodebuild #{project_type} '#{name}' -scheme '#{scheme}' -configuration '#{configuration}' -sdk #{sdk} -destination #{destination} #{tasks} | bundle exec xcpretty -c #{xcprety_args}"79end80def run_xcodebuild(tasks, destination, is_build_demo, xcprety_args)81 sdk = destination[:sdk]82 device = destination[:device]83 uuid = destination[:uuid]84 is_test = tasks.include?('test')85 is_macos = sdk == 'macosx'86 project = is_macos ? macos_project_name : project_name87 schemes_to_execute = []88 if is_test89 schemes_to_execute = test_schemes90 elsif is_build_demo91 schemes_to_execute = is_macos ? build_macos_demo_schemes : build_demo_schemes92 else93 schemes_to_execute = build_schemes94 end95 open_simulator_and_sleep uuid if is_test96 schemes_to_execute.each do |scheme|97 xcodebuild type, project, scheme, configuration, sdk, device, tasks, xcprety_args98 end99end100def execute(tasks, platform, is_build_demo = false, xcprety_args: '')101 # platform specific settings102 destination = devices[platform]103 # check if xcodebuild needs to be run on multiple devices104 if destination.is_a?(Array)105 destination.each do |destination|106 run_xcodebuild tasks, destination, is_build_demo, xcprety_args107 end108 else109 run_xcodebuild tasks, destination, is_build_demo, xcprety_args110 end111end112def arg_to_key(string_key)113 case string_key.downcase114 when 'ios'115 :iOS116 when 'tvos'117 :tvOS118 when 'macos'119 :macOS120 when 'watchos'121 :watchOS122 else123 abort 'Invalid platform, use `iOS`, `tvOS`, `macOS` or `watchOS`'124 end125end126desc 'Run CI tasks. Build and test or build depending on the platform.'127task :ci, [:platform] do |_task, args|128 platform = arg_to_key(args[:platform]) if args.key?(:platform)129 is_build_demo = test_platforms.include?(platform) || build_platforms.include?(platform)130 if test_platforms.include?(platform) # iOS and tvOS131 if platform == :iOS132 execute 'clean', platform, is_build_demo133 execute 'build', platform, is_build_demo134 execute 'test', platform # not use demo specifically135 else136 execute 'clean test', platform137 end138 elsif build_platforms.include?(platform) # macOS139 execute 'clean build', platform, is_build_demo140 else141 test_platforms.each do |platform|142 execute 'clean test', platform143 end144 build_platforms.each do |platform|145 execute 'clean build', platform146 end147 end148end149desc 'updated the podspec on cocoapods'150task :update_pod do151 sh 'bundle exec pod trunk push Charts.podspec --allow-warnings'152end...
ios_test.rb
Source:ios_test.rb
...7 assert browser.safari?8 assert browser.webkit?9 assert browser.modern?10 assert browser.platform.ios?11 refute browser.platform.mac?12 assert_equal "3.0", browser.full_version13 assert_equal "3", browser.version14 end15 test "detects safari" do16 browser = Browser.new(Browser["SAFARI"])17 assert_equal "Safari", browser.name18 assert browser.safari?19 assert browser.webkit?20 assert browser.modern?21 assert_equal "5.0.1", browser.full_version22 assert_equal "5", browser.version23 end24 test "detects safari in webapp mode" do25 browser = Browser.new(Browser["SAFARI_IPAD_WEBAPP_MODE"])26 refute browser.safari?27 assert browser.platform.ios_webview?28 browser = Browser.new(Browser["SAFARI_IPHONE_WEBAPP_MODE"])29 refute browser.safari?30 assert browser.platform.ios_webview?31 end32 test "detects ipod" do33 browser = Browser.new(Browser["IPOD"])34 assert_equal "Safari", browser.name35 assert browser.safari?36 assert browser.webkit?37 assert browser.platform.ios?38 refute browser.device.tablet?39 refute browser.platform.mac?40 assert_equal "3.0", browser.full_version41 assert_equal "3", browser.version42 end43 test "detects ipad" do44 browser = Browser.new(Browser["IPAD"])45 assert_equal "Safari", browser.name46 assert browser.safari?47 assert browser.webkit?48 assert browser.modern?49 assert browser.platform.ios?50 refute browser.platform.mac?51 assert_equal "4.0.4", browser.full_version52 assert_equal "4", browser.version53 end54 test "detects ios4" do55 browser = Browser.new(Browser["IOS4"])56 assert browser.platform.ios?57 assert browser.platform.ios?(4)58 refute browser.platform.mac?59 end60 test "detects ios5" do61 browser = Browser.new(Browser["IOS5"])62 assert browser.platform.ios?63 assert browser.platform.ios?(5)64 refute browser.platform.mac?65 end66 test "detects ios6" do67 browser = Browser.new(Browser["IOS6"])68 assert browser.platform.ios?69 assert browser.platform.ios?(6)70 refute browser.platform.mac?71 end72 test "detects ios7" do73 browser = Browser.new(Browser["IOS7"])74 assert browser.platform.ios?75 assert browser.platform.ios?(7)76 refute browser.platform.mac?77 end78 test "detects ios8" do79 browser = Browser.new(Browser["IOS8"])80 assert browser.platform.ios?81 assert browser.platform.ios?(8)82 refute browser.platform.mac?83 end84 test "detects ios9" do85 browser = Browser.new(Browser["IOS9"])86 assert browser.platform.ios?87 assert browser.platform.ios?(9)88 refute browser.platform.mac?89 end90 test "detects ios12" do91 browser = Browser.new(Browser["IOS12"])92 assert browser.platform.ios?93 assert browser.platform.ios?(12)94 refute browser.platform.mac?95 end96 test "don't detect as two different versions" do97 browser = Browser.new(Browser["IOS8"])98 assert browser.platform.ios?(8)99 refute browser.platform.ios?(7)100 end101 test "returns string representation for iphone" do102 browser = Browser.new(Browser["IPHONE"])103 meta = browser.to_s104 assert meta.include?("webkit")105 assert meta.include?("ios")106 assert meta.include?("safari")107 assert meta.include?("safari3")108 assert meta.include?("modern")...
gobby.rb
Source:gobby.rb
...20 depends_on "gtksourceview3"21 depends_on "hicolor-icon-theme"22 depends_on "libinfinity"23 depends_on "libxml++"24 # Necessary to remove mandatory gtk-mac-integration25 # it's badly broken as it depends on an ancient version of ige-mac-integration26 # since it depends on gtk3, it doesn't even need gtk-mac-integration anymore27 # This has already been fixed upstream: gtk2 support has been dropped completely28 # and all traces of ige-mac-integration have been removed from the code29 patch :DATA30 needs :cxx1131 def install32 ENV.cxx1133 system "./configure", "--disable-dependency-tracking",34 "--prefix=#{prefix}", "--with-gtk3"35 system "make", "install"36 end37 test do38 # executable (GUI)39 system bin/"gobby-0.5", "--version"40 end41end42__END__43diff --git a/code/core/header.cpp b/code/core/header.cpp44index eba2fb1..510608e 10064445--- a/code/core/header.cpp46+++ b/code/core/header.cpp47@@ -24,10 +24,6 @@48 #include <gtksourceview/gtksourcelanguage.h>49 #include <gdk/gdkkeysyms.h>50-#ifdef PLATFORM_OSX_NATIVE51-#include <ige-mac-menu.h>52-#endif53-54 namespace {55 Glib::ustring ui_desc =56 "<ui>"57@@ -519,28 +515,7 @@ Gobby::Header::Header(Preferences& preferences,58 );59 }60-#ifdef PLATFORM_OSX_NATIVE61- ige_mac_menu_set_menu_bar(GTK_MENU_SHELL(m_menubar->gobj()));62-63- ige_mac_menu_set_quit_menu_item(GTK_MENU_ITEM(64- m_ui_manager->get_widget(65- "/MenuMainBar/MenuFile/FileQuit")->gobj()));66-67- ige_mac_menu_add_app_menu_item(68- ige_mac_menu_add_app_menu_group(), GTK_MENU_ITEM(69- m_ui_manager->get_widget(70- "/MenuMainBar/MenuHelp/HelpAbout")->gobj()),71- NULL);72-73- ige_mac_menu_add_app_menu_item(74- ige_mac_menu_add_app_menu_group(), GTK_MENU_ITEM(75- m_ui_manager->get_widget(76- "/MenuMainBar/MenuEdit/EditPreferences")77- ->gobj()),78- NULL);79-#else80 pack_start(*m_menubar, Gtk::PACK_SHRINK);81-#endif82 pack_start(*m_toolbar, Gtk::PACK_SHRINK);83 m_toolbar->set_toolbar_style(preferences.appearance.toolbar_style);84diff --git a/configure b/configure85index 7dabb26..0987444 10075586--- a/configure87+++ b/configure88@@ -4955,7 +4955,7 @@ $as_echo "#define PLATFORM_OSX 1" >>confdefs.h89 $as_echo "#define PLATFORM_OSX_NATIVE 1" >>confdefs.h90- required_libs="$required_libs ige-mac-integration"91+ required_libs="$required_libs"92 fi93 fi94 cat >confcache <<\_ACEOF...
platform_spec.rb
Source:platform_spec.rb
...28 @plugin.run29 end30 it "should set platform to ProductName, downcased with _ for \\s" do31 @plugin.run32 expect(@plugin[:platform]).to eq("mac_os_x")33 end34 35 it "should set platform_version to ProductVersion" do36 @plugin.run37 expect(@plugin[:platform_version]).to eq("10.5.5")38 end39 40 it "should set platform_build to BuildVersion" do41 @plugin.run42 expect(@plugin[:platform_build]).to eq("9F33")43 end44 it "should set platform_family to mac_os_x" do45 @plugin.run46 expect(@plugin[:platform_family]).to eq("mac_os_x")47 end48 describe "on os x server" do49 before(:each) do50 @plugin[:os] = "darwin"51 @stdout = "ProductName: Mac OS X Server\nProductVersion: 10.6.8\nBuildVersion: 10K549"52 allow(@plugin).to receive(:shell_out).with("/usr/bin/sw_vers").and_return(mock_shell_out(0, @stdout, ""))53 end54 it "should set platform to mac_os_x_server" do55 @plugin.run56 expect(@plugin[:platform]).to eq("mac_os_x_server")57 end58 it "should set platform_family to mac_os_x" do59 @plugin.run60 expect(@plugin[:platform_family]).to eq("mac_os_x")61 end62 end63end...
mac
Using AI Code Generation
1 RUBY_PLATFORM.downcase.include?("darwin")2 RUBY_PLATFORM.downcase.include?("mswin")3 RUBY_PLATFORM.downcase.include?("linux")4Traceback (most recent call last):51.rb:1:in `require': cannot load such file -- platform (LoadError)6$LOAD_PATH = ['.', File.expand_path(File.dirname(__FILE__))]
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!