Class: Hive::Worker::Ios
- Inherits:
-
Hive::Worker
- Object
- Hive::Worker
- Hive::Worker::Ios
- Defined in:
- lib/hive/worker/ios.rb
Instance Attribute Summary collapse
-
#device ⇒ Object
Returns the value of attribute device.
Instance Method Summary collapse
- #alter_project(project_path) ⇒ Object
-
#autogenerated_queues ⇒ Object
def device_status.
- #hive_mind_device_identifiers ⇒ Object
-
#initialize(device) ⇒ Ios
constructor
A new instance of Ios.
- #job_message_klass ⇒ Object
- #post_script(job, file_system, script) ⇒ Object
- #pre_script(job, file_system, script) ⇒ Object
- #replace_project_data(options = {}) ⇒ Object
Constructor Details
#initialize(device) ⇒ Ios
Returns a new instance of Ios.
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/hive/worker/ios.rb', line 23 def initialize(device) @serial = device['serial'] @queue_prefix = device['queue_prefix'].to_s == '' ? '' : "#{device['queue_prefix']}-" @model = device['model'].downcase.gsub(/\s/, '_') @device_range = device['device_range'].downcase @os_version = device['os_version'] @worker_ports = PortReserver.new set_device_status('happy') self.device = device super(device) end |
Instance Attribute Details
#device ⇒ Object
Returns the value of attribute device.
21 22 23 |
# File 'lib/hive/worker/ios.rb', line 21 def device @device end |
Instance Method Details
#alter_project(project_path) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/hive/worker/ios.rb', line 35 def alter_project(project_path) dev_team = @options['development_team'] || '' signing_identity = @options['signing_identity'] || '' provisioning_profile = @options['provisioning_profile'] || '' helper = FruityBuilder::IOS::Helper.new(project_path) # Check to see if a project has been passed in return unless helper.has_project? helper.build.replace_bundle_id(@options['bundle_id']) helper.build.replace_dev_team(dev_team) helper.build.replace_code_sign_identity(signing_identity) helper.build.replace_provisioning_profile(provisioning_profile) helper.build.save_project_properties end |
#autogenerated_queues ⇒ Object
def device_status
end
def set_device_status(status)
end
136 137 138 139 140 141 142 143 144 145 |
# File 'lib/hive/worker/ios.rb', line 136 def autogenerated_queues [ "#{@queue_prefix}#{@model}", "#{@queue_prefix}ios", "#{@queue_prefix}ios-#{@os_version}", "#{@queue_prefix}ios-#{@os_version}-#{@model}", "#{@queue_prefix}#{@device_range}", "#{@queue_prefix}#{@device_range}-#{@os_version}" ] end |
#hive_mind_device_identifiers ⇒ Object
147 148 149 150 151 152 |
# File 'lib/hive/worker/ios.rb', line 147 def hive_mind_device_identifiers { serial: @serial, device_type: 'Mobile' } end |
#job_message_klass ⇒ Object
116 117 118 |
# File 'lib/hive/worker/ios.rb', line 116 def Hive::Messages::IosJob end |
#post_script(job, file_system, script) ⇒ Object
120 121 122 123 124 125 126 |
# File 'lib/hive/worker/ios.rb', line 120 def post_script(job, file_system, script) @log.info('Post script') @worker_ports.ports.each do |name, port| @port_allocator.release_port(port) end set_device_status('happy') end |
#pre_script(job, file_system, script) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/hive/worker/ios.rb', line 65 def pre_script(job, file_system, script) set_device_status('busy') device = DeviceAPI::IOS.device(self.device['serial']) if job.build FileUtils.mkdir(file_system.home_path + '/build') app_path = file_system.home_path + '/build/' + 'build.ipa' file_system.fetch_build(job.build, app_path) entitlements = FruityBuilder::IOS::Signing.enable_get_tasks(app_path) FruityBuilder::IOS::Signing.sign_app({ cert: @options['signing_identity'], entitlements: entitlements, app: app_path } ) app_info = FruityBuilder::IOS::Plistutil.get_bundle_id_from_app(app_path) app_bundle = app_info['CFBundleIdentifier'] device.install(app_path) script.set_env 'BUNDLE_ID', app_bundle else alter_project(file_system.home_path + '/test_code/code/') end ip_address = DeviceAPI::IOS::IPAddress.address(self.device['serial']) if ip_address.nil? # There is a bug in the IPAddress app that stopping the IP address from being # returned when it's first run, however it works the second time around. # This is a *temporary* fix until that issue can be resolved. ip_address = DeviceAPI::IOS::IPAddress.address(self.device['serial']) end script.set_env 'CHARLES_PROXY_PORT', @worker_ports.reserve(queue_name: 'Charles') { @port_allocator.allocate_port } # TODO: Allow the scheduler to specify the ports to use script.set_env 'APPIUM_PORT', @worker_ports.reserve(queue_name: 'Appium') { @port_allocator.allocate_port } script.set_env 'BOOTSTRAP_PORT', @worker_ports.reserve(queue_name: 'Bootstrap') { @port_allocator.allocate_port } script.set_env 'CHROMEDRIVER_PORT', @worker_ports.reserve(queue_name: 'Chromedriver') { @port_allocator.allocate_port } script.set_env 'APP_PATH', app_path script.set_env 'APP_BUNDLE_PATH', app_path script.set_env 'DEVICE_TARGET', self.device['serial'] # Required for Calabash testing script.set_env 'DEVICE_ENDPOINT', "http://#{ip_address}:37265" unless ip_address.nil? # Required for Appium testing script.set_env 'DEVICE_NAME', device.name script.set_env 'PLATFORM_NAME', 'iOS' script.set_env 'PLATFORM_VERSION', device.version "#{self.device['serial']} #{@worker_ports.ports['Appium']} #{app_path} #{file_system.results_path}" end |
#replace_project_data(options = {}) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/hive/worker/ios.rb', line 53 def replace_project_data( = {}) regex = Regexp.new([:regex]) replacements = [:data].scan(regex).uniq.flatten result = [:data] replacements.each do |to_replace| result = result.gsub(to_replace, [:new_value]) end result end |