class Workspace::Config

Attributes

name[R]

Public Class Methods

new(name) click to toggle source
# File lib/bean/config.rb, line 10
def initialize(name)
  @name = name.to_s
  @configs = {}
end

Public Instance Methods

export_options_plist() click to toggle source

The ExportOptions Plist object.

# File lib/bean/config.rb, line 29
def export_options_plist
  return nil unless get_team_identifier

  plist = ExportOptions::Plist.new(@name)
  @configs.each do | key, value |
    # puts "========= key: #{key}"
    # if ExportOptions::Plist.exist?(key)
      # puts "call #{key.to_s}(#{value})"
      plist.send key.to_sym, value
    # end
  end
  File.join(Workspace::TMP_DIR, "#{@name.to_s.capitalize}-ExportOptions.plist")
end
export_path() click to toggle source
# File lib/bean/config.rb, line 43
def export_path
  path = File.join(Dir.pwd, "#{self.scheme}-Archived")
  if self.output_name 
    path = File.join(Dir.pwd, "#{self.output_name}-Archived")
  end
  @configs[:exportPath] = path
  return path
end
method_missing(m, *args) click to toggle source
# File lib/bean/config.rb, line 15
def method_missing(m, *args)
  # puts "config ---- method: #{m.to_s}, args: #{@configs}"
  name = m.to_s
  name = m.to_s.delete('=') if m.to_s =~ /=$/
  return unless %w(workspace scheme output_name compile_bitcode method signing_style team_id thinning).include? name
  if m.to_s =~ /=$/
    add_configuration(name, args.first)
  else
    get_configuration(m.to_s)
  end
end
to_s() click to toggle source
# File lib/bean/config.rb, line 52
def to_s
  Table.new(@configs).table
end

Private Instance Methods

add_configuration(key, value) click to toggle source
# File lib/bean/config.rb, line 70
def add_configuration(key, value)
  key = key.sub(/_\w/) { |e| e.delete('_').upcase } if key.index('_')
  key = key.gsub(/id|Id/, 'ID') if key =~ /id|Id/
  @configs[key.to_sym] = value
end
get_configuration(key) click to toggle source
# File lib/bean/config.rb, line 76
def get_configuration(key)
  key = key.sub(/_\w/) { |e| e.delete('_').upcase } if key.index('_')
  key = key.gsub(/id|Id/, 'ID') if key =~ /id|Id/ 
  @configs[key.to_sym]
end
get_team_identifier() click to toggle source
# File lib/bean/config.rb, line 58
def get_team_identifier
  application_path = File.join(File.expand_path("#{scheme}.xcarchive", Workspace::TMP_DIR), "Products/Applications") 
  # puts application_path.red
  return nil unless File.exist?(application_path)
  mobileprovision = File.join(Dir.glob("#{application_path}/*.app").first, 'embedded.mobileprovision')
  return nil unless File.exist?(mobileprovision)

  # puts "mobileprovision: #{mobileprovision}".red
  team_id = XcodeTool::Mobileprovision.new(mobileprovision).team_identifier
  @configs[:teamID] = team_id.chomp 
end