Class: Zucchini::Config
- Inherits:
-
Object
- Object
- Zucchini::Config
- Defined in:
- lib/zucchini/config.rb
Class Method Summary collapse
- .app ⇒ Object
- .base_path ⇒ Object
- .base_path=(base_path) ⇒ Object
- .default_device_name ⇒ Object
- .device(device_name = nil) ⇒ Object
- .devices ⇒ Object
- .resolution_name(dimension) ⇒ Object
- .template ⇒ Object
Class Method Details
.app ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/zucchini/config.rb', line 22 def self.app device_name = ENV['ZUCCHINI_DEVICE'] || @@default_device_name device = devices[device_name] app_path = File.absolute_path(device['app'] || @@config['app'] || ENV['ZUCCHINI_APP']) if (device_name == 'iOS Simulator' || device['simulator']) && !File.exists?(app_path) raise "Can't find application at path #{app_path}" end app_path end |
.base_path ⇒ Object
6 7 8 |
# File 'lib/zucchini/config.rb', line 6 def self.base_path @@base_path end |
.base_path=(base_path) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/zucchini/config.rb', line 10 def self.base_path=(base_path) @@base_path = base_path @@config = YAML::load(ERB::new(File::read("#{base_path}/support/config.yml")).result) @@default_device_name = nil devices.each do |device_name, device| if device['default'] raise "Default device already provided" if @@default_device_name @@default_device_name = device_name end end end |
.default_device_name ⇒ Object
41 42 43 |
# File 'lib/zucchini/config.rb', line 41 def self.default_device_name @@default_device_name end |
.device(device_name = nil) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/zucchini/config.rb', line 45 def self.device(device_name = nil) device_name ||= @@default_device_name raise "Neither default device nor ZUCCHINI_DEVICE environment variable was set" unless device_name raise "Device '#{device_name}' not listed in config.yml" unless (device = devices[device_name]) { :name => device_name, :udid => device['UDID'], :screen => device['screen'], :simulator => device['simulator'], :orientation => device['orientation'] || 'portrait' } end |
.devices ⇒ Object
37 38 39 |
# File 'lib/zucchini/config.rb', line 37 def self.devices @@config['devices'] end |
.resolution_name(dimension) ⇒ Object
33 34 35 |
# File 'lib/zucchini/config.rb', line 33 def self.resolution_name(dimension) @@config['resolutions'][dimension.to_i] end |
.template ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/zucchini/config.rb', line 58 def self.template locations = [ `xcode-select -print-path`.gsub(/\n/, '') + "/Platforms/iPhoneOS.platform/Developer/Library/Instruments", "/Applications/Xcode.app/Contents/Applications/Instruments.app/Contents" # Xcode 4.5 ].map do |start_path| "#{start_path}/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate" end locations.each { |path| return path if File.exists?(path) } raise "Can't find Instruments template (tried #{locations.join(', ')})" end |