Class: Calasmash::Compiler
- Inherits:
-
Object
- Object
- Calasmash::Compiler
- Defined in:
- lib/calasmash/compiler.rb
Overview
The calamsash compiler will compiles the Xcode project with the scheme it’s told to compile with.
Instance Attribute Summary collapse
-
#scheme ⇒ Object
Public: the Scheme the compiler is compiling.
Instance Method Summary collapse
-
#compile(&complete) ⇒ Object
The compiler’s heart, executes the compiling with xcodebuild.
-
#initialize(scheme) ⇒ Compiler
constructor
A new instance of Compiler.
Constructor Details
#initialize(scheme) ⇒ Compiler
Returns a new instance of Compiler.
16 17 18 |
# File 'lib/calasmash/compiler.rb', line 16 def initialize(scheme) @scheme = scheme end |
Instance Attribute Details
#scheme ⇒ Object
Public: the Scheme the compiler is compiling
14 15 16 |
# File 'lib/calasmash/compiler.rb', line 14 def scheme @scheme end |
Instance Method Details
#compile(&complete) ⇒ Object
The compiler’s heart, executes the compiling with xcodebuild
@param &complete Compleition block
Returns nothing because it completes with a complete block
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/calasmash/compiler.rb', line 26 def compile(&complete) started status = nil output = "" Open3.popen3 command do |stdin, out, err, wait_thr| [out, err].each do |stream| Thread.new do until (line = stream.gets).nil? do print "." output << line end end end wait_thr.join status = wait_thr.value.exitstatus end if status != 0 puts "\nCompilation failed: \n\n #{output}" exit status else completed complete.call(true) if complete end end |