Class: XCTasks::TestTask::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/xctasks/test_task.rb

Defined Under Namespace

Modules: Delegations

Constant Summary collapse

SETTINGS =
[:workspace, :schemes_dir, :sdk, :runner, :xctool_path, 
:xcodebuild_path, :settings, :destinations, :actions,
:scheme, :ios_versions, :output_log]
HELPERS =
[:destination, :xctool?, :xcpretty?, :xcodebuild?]

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



116
117
118
119
120
121
122
123
124
125
126
# File 'lib/xctasks/test_task.rb', line 116

def initialize
  @sdk = :iphonesimulator
  @schemes_dir = nil
  @xctool_path = '/usr/local/bin/xctool'
  @xcodebuild_path = '/usr/bin/xcodebuild'
  @runner = :xcodebuild
  @settings = {}
  @platform = 'iOS Simulator'
  @destinations = []
  @actions = %w{clean build test}
end

Instance Method Details

#destination(specifier = {}) ⇒ Object



139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/xctasks/test_task.rb', line 139

def destination(specifier = {})
  if specifier.kind_of?(String)
    raise ArgumentError, "Cannot configure a destination via a block when a complete String specifier is provided" if block_given?
    @destinations << specifier.shellescape
  elsif specifier.kind_of?(Hash)
    destination = Destination.new(specifier)
    yield destination if block_given?
    @destinations << destination
  else
    raise ArgumentError, "Cannot configure a destination with a #{specifier}"
  end
end

#dupObject

Deep copy any nested structures



169
170
171
172
173
174
# File 'lib/xctasks/test_task.rb', line 169

def dup
  copy = super
  copy.settings = settings.dup
  copy.destinations = destinations.dup
  return copy
end

#runner=(runner) ⇒ Object

Raises:



128
129
130
131
132
# File 'lib/xctasks/test_task.rb', line 128

def runner=(runner)
  runner_bin = runner.to_s.split(' ')[0]
  raise ConfigurationError, "Must be :xcodebuild, :xctool or :xcpretty" unless %w{xctool xcodebuild xcpretty}.include?(runner_bin)
  @runner = runner
end

#sdk=(sdk) ⇒ Object

Raises:

  • (ArgumentError)


134
135
136
137
# File 'lib/xctasks/test_task.rb', line 134

def sdk=(sdk)
  raise ArgumentError, "Can only assign sdk from a String or Symbol" unless sdk.kind_of?(String) || sdk.kind_of?(Symbol)
  @sdk = sdk.to_sym
end

#validate!Object

Raises:



152
153
154
# File 'lib/xctasks/test_task.rb', line 152

def validate!
  raise ConfigurationError, "Cannot specify iOS versions with an SDK of :macosx" if sdk == :macosx && ios_versions
end

#xcodebuild?Boolean

Returns:

  • (Boolean)


160
161
162
# File 'lib/xctasks/test_task.rb', line 160

def xcodebuild?
  runner =~ /^xcodebuild/
end

#xcpretty?Boolean

Returns:

  • (Boolean)


164
165
166
# File 'lib/xctasks/test_task.rb', line 164

def xcpretty?
  runner =~ /^xcpretty/
end

#xctool?Boolean

Returns:

  • (Boolean)


156
157
158
# File 'lib/xctasks/test_task.rb', line 156

def xctool?
  runner =~ /^xctool/
end