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]
HELPERS =
[:destination, :xctool?, :xcpretty?, :xcodebuild?]

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



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

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



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

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



167
168
169
170
171
172
# File 'lib/xctasks/test_task.rb', line 167

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

#runner=(runner) ⇒ Object

Raises:



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

def runner=(runner)
  raise ConfigurationError, "Must be :xcodebuild, :xctool or :xcpretty" unless %w{xctool xcodebuild xcpretty}.include?(runner.to_s)
  @runner = runner.to_sym
end

#sdk=(sdk) ⇒ Object

Raises:

  • (ArgumentError)


132
133
134
135
# File 'lib/xctasks/test_task.rb', line 132

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:



150
151
152
# File 'lib/xctasks/test_task.rb', line 150

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

#xcodebuild?Boolean

Returns:

  • (Boolean)


158
159
160
# File 'lib/xctasks/test_task.rb', line 158

def xcodebuild?
  runner == :xcodebuild
end

#xcpretty?Boolean

Returns:

  • (Boolean)


162
163
164
# File 'lib/xctasks/test_task.rb', line 162

def xcpretty?
  runner == :xcpretty
end

#xctool?Boolean

Returns:

  • (Boolean)


154
155
156
# File 'lib/xctasks/test_task.rb', line 154

def xctool?
  runner == :xctool
end