Class: Scan::DetectValues
- Inherits:
-
Object
- Object
- Scan::DetectValues
- Defined in:
- lib/scan/detect_values.rb
Overview
This class detects all kinds of default values
Class Method Summary collapse
- .default_device ⇒ Object
-
.detect_destination ⇒ Object
Is it an iOS device or a Mac?.
-
.set_additional_default_values ⇒ Object
This is needed as these are more complex default values Returns the finished config object.
Class Method Details
.default_device ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/scan/detect_values.rb', line 25 def self.default_device config = Scan.config if config[:device] # make sure it actually exists device = config[:device].to_s.strip.tr('()', '') # Remove parenthesis found = FastlaneCore::Simulator.all.find { |d| (d.name + " " + d.ios_version).include? device } if found Scan.device = found return else Helper.log.error "Couldn't find simulator '#{config[:device]}' - falling back to default simulator".red end end sims = FastlaneCore::Simulator.all xcode_target = Scan.project.build_settings(key: "IPHONEOS_DEPLOYMENT_TARGET") # Filter out any simulators that are not the same major version of our deployment target if xcode_target.to_s.length > 0 min_target = xcode_target.split(".").first.to_i sims = sims.select { |s| s.ios_version.to_i >= min_target } end # An iPhone 5s is reasonable small and useful for tests found = sims.find { |d| d.name == "iPhone 5s" } found ||= sims.first # anything is better than nothing Scan.device = found raise "No simulators found".red unless Scan.device end |
.detect_destination ⇒ Object
Is it an iOS device or a Mac?
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/scan/detect_values.rb', line 60 def self.detect_destination if Scan.config[:destination] Helper.log.info "It's not recommended to set the `destination` value directly".yellow Helper.log.info "Instead use the other options available in `scan --help`".yellow Helper.log.info "Using your value '#{Scan.config[:destination]}' for now".yellow Helper.log.info "because I trust you know what you're doing...".yellow return end # building up the destination now if Scan.project.ios? Scan.config[:destination] = "platform=iOS Simulator,id=#{Scan.device.udid}" else Scan.config[:destination] = "platform=OS X" end end |
.set_additional_default_values ⇒ Object
This is needed as these are more complex default values Returns the finished config object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/scan/detect_values.rb', line 6 def self.set_additional_default_values config = Scan.config FastlaneCore::Project.detect_projects(config) Scan.project = FastlaneCore::Project.new(config) # Go into the project's folder Dir.chdir(File.("..", Scan.project.path)) do config.load_configuration_file(Scan.scanfile_name) end Scan.project.select_scheme default_device if Scan.project.ios? detect_destination return config end |