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

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



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

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}
  @env = {}
end

Instance Method Details

#destination(specifier = {}) ⇒ Object



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

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



171
172
173
174
175
176
# File 'lib/xctasks/test_task.rb', line 171

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

#runner=(runner) ⇒ Object

Raises:



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

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)


136
137
138
139
# File 'lib/xctasks/test_task.rb', line 136

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:



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

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

#xcodebuild?Boolean

Returns:

  • (Boolean)


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

def xcodebuild?
  runner =~ /^xcodebuild/
end

#xcpretty?Boolean

Returns:

  • (Boolean)


166
167
168
# File 'lib/xctasks/test_task.rb', line 166

def xcpretty?
  runner =~ /^xcpretty/
end

#xctool?Boolean

Returns:

  • (Boolean)


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

def xctool?
  runner =~ /^xctool/
end