class TargetConfiguration

Attributes

pods[RW]
scripts[RW]

Public Class Methods

new(name, target) click to toggle source
# File lib/target_configuration.rb, line 5
def initialize(name, target)
  @name = name
  @target = target
  @pods = []
  @scripts = []
  @options = {}
end

Public Instance Methods

add_option(name, &block) click to toggle source
# File lib/target_configuration.rb, line 13
def add_option(name, &block)
  @options[name] = block
end
ask_question(question) click to toggle source
# File lib/target_configuration.rb, line 42
def ask_question(question)
  puts question
  get_input()
end
get_input() click to toggle source
# File lib/target_configuration.rb, line 47
def get_input
  STDOUT.flush
  input = STDIN.gets.chomp
  case input.upcase
    when 'Y'
      true
    when 'N'
      false
    else
      puts 'Please enter Y or N'
      get_input
  end
end
process_optional() click to toggle source
# File lib/target_configuration.rb, line 17
def process_optional
  @options.each do |key, obj|
    key_string = key.to_s
      if ask_question "do you want to add #{key_string}? [y/n]"
        raise unless obj.is_a? Proc
        obj.call()
      end
  end
end
process_scripts(project) click to toggle source
# File lib/target_configuration.rb, line 36
def process_scripts(project)
  scripts.each do |hash|
    project.add_shell_script(@target, hash[:name], hash[:script])
  end
end
write_pods(f) click to toggle source
# File lib/target_configuration.rb, line 27
def write_pods(f)
  return if @pods.empty?
  f.puts "target '#{@target.name}', :exclusive => true do"
  pods.flatten.each do |pod|
    f.puts "  pod '#{pod}'"
  end
  f.puts 'end'
end