Created
January 26, 2013 02:49
-
-
Save spenrose/4639796 to your computer and use it in GitHub Desktop.
Rakefile for Xcode projects.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source "https://rubygems.org" | |
# Rakefile | |
gem "rake" | |
gem "xcoder" | |
gem "open4" | |
gem "spinning_cursor" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require_relative 'Scripts/RakefileHelper.rb' | |
require 'xcoder' | |
# mogenerator paths | |
model_path = "Code/TTSwitch/Models/TTSwitch.xcdatamodeld" | |
model_machine_dir_path = "Code/TTSwitch/Models/Machine" | |
model_human_dir_path = "Code/TTSwitch/Models" | |
task :mogen => 'tools:mogen' | |
namespace :tools do | |
desc "Configure Submodules" | |
task :setup do | |
puts | |
puts 'Updating Development Environment'.cyan | |
Runner.instance.execute 'Updating git submodules', 'git submodule update --init --recursive' | |
Runner.instance.execute 'Building Test Libraries - Specta', 'cd Code/Libraries/Specta ; rake' | |
Runner.instance.execute 'Building Test Libraries - Expecta', 'cd Code/Libraries/Expecta ; rake' | |
puts | |
puts 'Tools Setup Complete'.green | |
end | |
desc "Run mogenerator" | |
task :mogen do | |
puts | |
puts "Updating Model Objects from #{model_path}".cyan | |
Runner.instance.execute "Running mogenerator on model", "mogenerator --model \"#{model_path}\" --machine-dir \"#{model_machine_dir_path}\" --human-dir \"#{model_human_dir_path}\" --template-var arc=true" | |
end | |
end | |
## Test ## | |
namespace :test do | |
desc "Logic Tests" | |
task :logic do | |
config = Xcode.project(:TTSwitch).target(:TTSwitchTests).config(:Debug) | |
builder = config.builder | |
builder.clean | |
builder.test(:sdk => 'iphonesimulator') | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
require "open4" | |
require "spinning_cursor" | |
class String | |
def self.colorize(text, color_code) | |
"\e[#{color_code}m#{text}\e[0m" | |
end | |
def red | |
self.class.colorize(self, 31); | |
end | |
def green | |
self.class.colorize(self, 32); | |
end | |
def yellow | |
self.class.colorize(self, 33); | |
end | |
def cyan | |
self.class.colorize(self, 36); | |
end | |
def grey | |
self.class.colorize(self, 37); | |
end | |
end | |
class Runner | |
attr_accessor :verbose | |
attr_reader :build_dir | |
def self.instance | |
@instance ||= Runner.new | |
end | |
def initialize | |
@verbose = ENV['VERBOSE'] || false | |
end | |
def verbose? | |
self.verbose | |
end | |
def execute(title, command) | |
if verbose? | |
bannerTitle = "- #{title} :: #{command}" | |
else | |
bannerTitle = "- #{title}" | |
end | |
SpinningCursor.start do | |
banner bannerTitle.cyan | |
message "✓ #{title}".green | |
end | |
status = Open4::popen4(command) do |pid, stdin, stdout, stderr| | |
stdout.each_line do |line| | |
if verbose? | |
puts line.yellow | |
end | |
end | |
stderr.each_line do |line| | |
SpinningCursor.set_message "✘ #{line}".red | |
end | |
end | |
SpinningCursor.stop | |
return status.exitstatus | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment