class Objc::Test::XcodeProject

Attributes

runner[R]

Public Class Methods

new(runner) click to toggle source
# File lib/objc/xcode_project.rb, line 6
def initialize(runner)
  @runner = runner
end

Public Instance Methods

add(files) click to toggle source
# File lib/objc/xcode_project.rb, line 16
def add(files)
  project = Xcode.project(project_path)

  puts "Loading files into #{project} at #{project_path}"

  target = project.target(target_name)
  test_group = project.group(group_name)

  source_files_in_project = files.data.map do |path_data|
    test_group.create_file path_data
  end

  files_required_to_be_built = source_files_in_project.reject do |file|
    file.name.end_with?("h")
  end

  target.sources_build_phase do
    files_required_to_be_built.each do |source_file|
      add_build_file source_file
    end
  end

  project.save!
end
execute!() click to toggle source
# File lib/objc/xcode_project.rb, line 42
def execute!
  pid = spawn xctool_command
  Process.wait
end
install!() click to toggle source
# File lib/objc/xcode_project.rb, line 10
def install!
  clean
  extract
end

Private Instance Methods

clean() click to toggle source
# File lib/objc/xcode_project.rb, line 50
def clean
  `rm -rf #{project_root}`
end
extract() click to toggle source
# File lib/objc/xcode_project.rb, line 54
def extract
  `tar -xvf #{project_template_tar_file} -C #{temp_path} > /dev/null 2>&1`
end
group_name() click to toggle source
# File lib/objc/xcode_project.rb, line 78
def group_name
  'test-suite'
end
project_path() click to toggle source
# File lib/objc/xcode_project.rb, line 70
def project_path
  File.expand_path(File.join(project_root,"ExercismTestFixture.xcodeproj"))
end
project_root() click to toggle source
# File lib/objc/xcode_project.rb, line 66
def project_root
  File.expand_path(File.join(temp_path,"ExercismTestFixture"))
end
project_template_tar_file() click to toggle source
# File lib/objc/xcode_project.rb, line 62
def project_template_tar_file
  File.expand_path(File.join(__FILE__,"..","..","..","template","template-project.tar"))
end
target_name() click to toggle source
# File lib/objc/xcode_project.rb, line 74
def target_name
  'test-suite'
end
temp_path() click to toggle source
# File lib/objc/xcode_project.rb, line 58
def temp_path
  @temp_path ||= Dir.tmpdir
end
use_xcodebuild?() click to toggle source
# File lib/objc/xcode_project.rb, line 82
def use_xcodebuild?
  runner == :xcodebuild
end
xctool_command() click to toggle source
# File lib/objc/xcode_project.rb, line 86
def xctool_command
  if use_xcodebuild?
    "xcodebuild -project #{project_path} -scheme IgnoreThisTarget test | xcpretty"
  else
    "xctool -project #{project_path} -scheme IgnoreThisTarget test"
  end
end