Class: Mayday::TargetIntegrator

Inherits:
Object
  • Object
show all
Defined in:
lib/mayday/target_integrator.rb

Instance Method Summary collapse

Constructor Details

#initialize(project, script_generator) ⇒ TargetIntegrator

Returns a new instance of TargetIntegrator.



6
7
8
9
# File 'lib/mayday/target_integrator.rb', line 6

def initialize(project, script_generator)
  @project = project
  @script_generator = script_generator
end

Instance Method Details

#benchmarkObject



37
38
39
40
41
42
43
44
# File 'lib/mayday/target_integrator.rb', line 37

def benchmark
  ENV["SRCROOT"] = @project.path.parent.to_s

  require 'benchmark'
  Benchmark.bm(7) do |benchmarker| 
    benchmarker.report('Mayday') { eval(@script_generator.to_ruby(:exit_after => false, :output => false)) }
  end
end

#deintegrateObject



23
24
25
26
27
28
29
# File 'lib/mayday/target_integrator.rb', line 23

def deintegrate
  native_targets_to_integrate.each do |native_target_to_integrate|
    phase = existing_mayday_build_phase_for_native_target(native_target_to_integrate)
    phase.remove_from_project if phase
  end
  @project.save
end

#integrateObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/mayday/target_integrator.rb', line 11

def integrate
  if runs_successfully?
    native_targets_to_integrate.each do |native_target_to_integrate|
      phase = existing_mayday_build_phase_for_native_target(native_target_to_integrate) || native_target_to_integrate.new_shell_script_build_phase(mayday_build_phase_name)
      phase.shell_path = "/usr/bin/ruby"
      phase.shell_script = @script_generator.to_ruby
      phase.show_env_vars_in_log = '0'
    end
    @project.save
  end
end

#runObject



46
47
48
49
# File 'lib/mayday/target_integrator.rb', line 46

def run
  ENV["SRCROOT"] = @project.path.parent.to_s
  eval(@script_generator.to_ruby(:exit_after => false, :output => true))
end

#runs_successfully?Boolean

Returns:

  • (Boolean)


31
32
33
34
35
# File 'lib/mayday/target_integrator.rb', line 31

def runs_successfully?
  ENV["SRCROOT"] = @project.path.parent.to_s
  eval(@script_generator.to_ruby(:exit_after => false, :output => false))
  true
end