Class: UISpecRunner::Options
- Inherits:
-
Hash
- Object
- Hash
- UISpecRunner::Options
- Defined in:
- lib/uispecrunner/options.rb
Instance Attribute Summary collapse
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
-
#orig_args ⇒ Object
readonly
Returns the value of attribute orig_args.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(args) ⇒ Options
constructor
A new instance of Options.
- #merge(other) ⇒ Object
Constructor Details
#initialize(args) ⇒ Options
Returns a new instance of Options.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 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 58 59 60 61 62 63 64 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 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/uispecrunner/options.rb', line 10 def initialize(args) super() @orig_args = args.clone # Configure default settings self[:run_mode] = :all self[:configuration] = 'Debug' self[:build_dir] = './build' self[:verbose] = false self[:sdk_version] = '4.0' self[:driver] = :waxsim self[:exit_on_finish] = true self[:env] = {} require 'optparse' @opts = OptionParser.new do |o| o. = "Usage: #{File.basename($0)} [options]\ne.g. #{File.basename($0)}" o.separator "" o.separator "Run Modes:" o.on('-s', '--spec [CLASS]', 'Run the specified UISpec class') do |spec| self[:spec] = spec self[:run_mode] = :spec end o.on('-e', '--example [METHOD]', 'Run the specified example method (requires --spec)') do |example| self[:example] = example self[:run_mode] = :example # TODO: Need to raise exception if method is specified without class end o.on('-p', '--protocol [PROTOCOL]', 'Run all UISpec classes implementing the Objective-C protocol') do |protocol| self[:protocol] = protocol self[:run_mode] = :protocol end o.separator "" o.separator "Environment options:" o.on('-a', '--app [APP_PATH]', 'Run the app at the specified path', 'Default: auto-detect the app during the build') do |app_path| self[:app_path] = app_path end o.on('--project [PROJECT_FILE]', 'Run the UISpec target in specified project', 'Default: auto-detect project in current directory') do |project| self[:project] = project end o.on('--workspace [WORKSPACE_PATH]', 'Run the UISpec scheme in the specified Xcode workspace at the path') do |workspace| self[:workspace] = workspace end o.on('--scheme [SCHEME_NAME]', 'Build and run the specified XCode scheme.', 'Default: UISpec (If workspace provided)') do |scheme| self[:scheme] = scheme end o.on('--driver [DRIVER]', [:shell, :osascript, :waxsim], "Select driver (shell, osascript, waxsim)", 'Default: waxsim') do |driver| self[:driver] = driver.to_sym end o.on('--sdk [VERSION]', 'Run the UISpec target against the iPhone SDK version', 'Default: 4.0') do |sdk_version| self[:sdk_version] = sdk_version end o.on('-c', '--configuration [CONFIGURATION]', 'Build with specified XCode configuration.', 'Default: Debug') do |configuration| self[:configuration] = configuration end o.on('-t', '--target [TARGET]', 'Run the specified XCode target.', 'Default: UISpec') do |target| self[:target] = target end o.on('-f', '--family [FAMILY]', 'Utilize the specified device family: iphone or ipad. (Requires --driver waxsim)', 'Default: iphone') do |family| self[:family] = family end o.on('--builddir [BUILD_DIR]', 'Run app in the build directory.', 'Default: ./build') do |build_dir| self[:build_dir] = build_dir end o.on('--securityd', 'Start the securityd daemon before running specs. This allows interaction with the keychain.') do |securityd| self[:securityd] = securityd end o.on('--no-exit', 'Do not exit the process after running the specs') do |exit_on_finish| self[:exit_on_finish] = exit_on_finish end o.on('-S', '--skip-build', 'Do not build the app, just run the specs') do |skip_build| self[:skip_build] = skip_build end o.on('-v', '--[no-]verbose', "Run verbosely") do |v| self[:verbose] = v end o.on('-E', '--env [VARIABLE=VALUE]', 'Specify an environment variable to pass to the application.') do |env| key, value = env.split('=') self[:env][key] = value end o.on('--version', 'Show version') do self[:command] = :version end o.on_tail('-h', '--help', 'Display this help and exit') do self[:command] = :help end end begin @opts.parse!(args) # Set default Scheme name if Workspace was provided if self[:workspace] self[:scheme] ||= 'UISpec' else self[:target] ||= 'UISpec' end # TODO: Support running specific files rescue OptionParser::InvalidOption => e self[:invalid_argument] = e. end end |
Instance Attribute Details
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
3 4 5 |
# File 'lib/uispecrunner/options.rb', line 3 def opts @opts end |
#orig_args ⇒ Object (readonly)
Returns the value of attribute orig_args.
3 4 5 |
# File 'lib/uispecrunner/options.rb', line 3 def orig_args @orig_args end |
Class Method Details
.from_file(options_file) ⇒ Object
5 6 7 8 |
# File 'lib/uispecrunner/options.rb', line 5 def self.from_file() args = File.readlines().map { |l| l.chomp.split(" ", 2)}.flatten UISpecRunner::Options.new(args) end |
Instance Method Details
#merge(other) ⇒ Object
157 158 159 |
# File 'lib/uispecrunner/options.rb', line 157 def merge(other) self.class.new(@orig_args + other.orig_args) end |