lib/appium_lib/driver.rb in appium_lib-0.6.2 vs lib/appium_lib/driver.rb in appium_lib-0.6.3
- old
+ new
@@ -3,10 +3,26 @@
Based on simple_test.rb
https://github.com/appium/appium/blob/82995f47408530c80c3376f4e07a1f649d96ba22/sample-code/examples/ruby/simple_test.rb
https://github.com/appium/appium/blob/c58eeb66f2d6fa3b9a89d188a2e657cca7cb300f/LICENSE
=end
+require 'rubygems'
+require 'ap'
+
+# Support OpenStruct in Awesome Print
+# /awesome_print/lib/awesome_print/formatter.rb
+# upstream issue: https://github.com/michaeldv/awesome_print/pull/36
+class AwesomePrint::Formatter
+ remove_const :CORE if defined?(CORE)
+ CORE = [ :array, :hash, :class, :file, :dir, :bigdecimal, :rational, :struct, :openstruct, :method, :unboundmethod ]
+
+ def awesome_openstruct target
+ awesome_hash target.marshal_dump
+ end
+end
+
+
# Load appium.txt (toml format) into system ENV
# the basedir of this file + appium.txt is what's used
# @param opts [Hash] file: '/path/to/appium.txt', verbose: true
# @return [Array<String>] the require files. nil if require doesn't exist
def load_appium_txt opts
@@ -32,11 +48,10 @@
puts "Exists? #{toml_exists}" if verbose
data = nil
if toml_exists
require 'toml'
- require 'ap'
puts "Loading #{toml}" if verbose
# bash requires A="OK"
# toml requires A = "OK"
#
@@ -56,11 +71,14 @@
# Ensure app path is absolute
ENV['APP_PATH'] = File.expand_path ENV['APP_PATH'] if ENV['APP_PATH'] &&
!ENV['APP_PATH'].empty?
+ # device is not case sensitive
+ ENV['DEVICE'] = ENV['DEVICE'].strip.downcase if !ENV['DEVICE'].nil?
if ! %w(ios android selendroid).include? ENV['DEVICE']
- raise 'DEVICE must be ios, android, or selendroid'
+ raise %(DEVICE="#{ENV['DEVICE']}" must be ios, android,
+or selendroid.)
end
end
# return list of require files as an array
# nil if require doesn't exist