class Guard::Xcode
Constants
- VERSION
Attributes
Build an Xcode
project on file change
Should be initialised with ‘guard xcode’ in the target project’s directory
Public Class Methods
Initialize a Guard
. @param [Array<Guard::Watcher>] watchers the Guard
file watchers @param [Hash] options the custom Guard
options
# File lib/guard/xcode.rb, line 16 def initialize(watchers = [], options = {}) super @config = options[:configuration] @scheme = options[:scheme] @arch = options[:arch] @sdk = options[:sdk] @suppress_all_output = options[:suppress_all_output] or false @all = options[:all] or false @target = options[:target] unless @all @workspace = options[:workspace] unless @all @quiet = options[:quiet] or false @clean = options[:clean] or false end
Public Instance Methods
# File lib/guard/xcode.rb, line 31 def get_build_line # generate the build line from the initialised options build_line = 'xcodebuild ' ## configure build options unless nil == @config build_line += "-configuration #{@config} " end unless nil == @target build_line += "-target #{@target} " end unless nil == @workspace build_line += "-workspace #{@workspace} " end if @all build_line += "-alltargets " end unless nil == @scheme build_line += "-scheme #{@scheme} " end unless nil == @arch build_line += "-arch #{@arch} " end unless nil == @sdk build_line += "-sdk #{@sdk} " end if @clean build_line += "clean " end build_line += "build" end
Called when ‘reload|r|z + enter` is pressed. This method should be mainly used for “reload” (really!) actions like reloading passenger/spork/bundler/… @raise [:task_has_failed] when reload has failed
# File lib/guard/xcode.rb, line 127 def reload end
Called when just ‘enter` is pressed This method should be principally used for long action like running all specs/tests/… @raise [:task_has_failed] when run_all
has failed
# File lib/guard/xcode.rb, line 133 def run_all run_build(get_build_line) end
# File lib/guard/xcode.rb, line 71 def run_build(build_line) # run the build, returning a list of alerts # # returns: # a list of symbols; possible values include :errors and :warnings which # indicate the build included warnings or errors. Returning an empty list # means no errors were detected. alerts = [] puts "building..." unless @suppress_all_output unless @quiet or @suppress_all_output UI.info "guard-xcode: starting build" Notifier.notify("kicking off build with:\n#{build_line}", :image => :pending) end output = `#{build_line} 2>&1` res = $? if not ((not 0 == res or output =~ /errors? generated/) or (output =~ /warnings? generated/)) UI.info "guard-xcode: Build succeeded!" unless @quiet or @suppress_all_output Notifier.notify("Build succeeded!") unless @quiet or @suppress_all_output end unless @quiet or @suppress_all_output puts output end if not 0 == res or output =~ /errors? generated/ UI.info "guard-xcode: Errors in build." unless @suppress_all_output Notifier.notify("Errors in build.", :image => :failed) unless @suppress_all_output alerts.push :errors end if output =~ /warnings? generated/ UI.info "guard-xcode: Warnings in build." unless @suppress_all_output Notifier.notify("Warnings in build.", :image => :failed) unless @suppress_all_output alerts.push :warnings end puts "build finished." unless @suppress_all_output alerts end
Called on file(s) modifications that the Guard
watches. @param [Array<String>] paths the changes files or paths @raise [:task_has_failed] when run_on_change has failed
# File lib/guard/xcode.rb, line 140 def run_on_changes(paths) run_build(get_build_line) end
Called on file(s) deletions that the Guard
watches. @param [Array<String>] paths the deleted files or paths @raise [:task_has_failed] when run_on_change has failed
# File lib/guard/xcode.rb, line 147 def run_on_removals(paths) run_build(get_build_line) end
Call once when Guard
starts. Please override initialize method to init stuff. @raise [:task_has_failed] when start has failed
# File lib/guard/xcode.rb, line 116 def start end
Called when ‘stop|quit|exit|s|q|e + enter` is pressed (when Guard
quits). @raise [:task_has_failed] when stop has failed
# File lib/guard/xcode.rb, line 121 def stop end