module Flappy::Mapping

Public Instance Methods

mapping(*args, options) click to toggle source
# File lib/flappy/util/mapping.rb, line 6
def mapping(*args, options)
  initialize_and_check_mapping_options(args, options)
  check_file_and_token

  logger.info "Creating bughd project's version......."
  logger_info_dividing_line

  logger.info 'Uploading mapping file.......'

  # upload_mapping_file
  logger_info_dividing_line

  logger.info "save mapping succeed"
  logger_info_blank_line
end

Private Instance Methods

check_file_and_token() click to toggle source
# File lib/flappy/util/mapping.rb, line 32
def check_file_and_token
  check_file_exist(@file_path)
  check_token_cannot_be_blank(@token)
  check_project_id_cannot_be_blank
end
check_project_id_cannot_be_blank() click to toggle source
# File lib/flappy/util/mapping.rb, line 38
def check_project_id_cannot_be_blank
  return unless @proj.blank?

  logger.error "Project id can't be blank"
  exit 1
end
dsym_or_txt_file(tmp_file_path) click to toggle source
# File lib/flappy/util/mapping.rb, line 72
def dsym_or_txt_file(tmp_file_path)
  if File.dsym?(@file_path)
    FileUtils.mv(tmp_file_path, tmp_file_path + '.dSYM')
    tmp_file_path += '.dSYM'
  elsif File.text?(@file_path)
    FileUtils.mv(tmp_file_path, tmp_file_path + '.txt')
    tmp_file_path += '.txt'
  end

  tmp_file_path
end
generate_temp_mapping_file() click to toggle source
# File lib/flappy/util/mapping.rb, line 49
def generate_temp_mapping_file
  tmp_file_path = "#{Dir.tmpdir}/flappycli-#{File.basename(@file_path)}"
  FileUtils.cp(@file_path, tmp_file_path)

  tmp_file_path = zip_mapping_file(tmp_file_path)
  tmp_file_path = dsym_or_txt_file(tmp_file_path)

  tmp_file_path
end
initialize_and_check_mapping_options(args, options) click to toggle source
# File lib/flappy/util/mapping.rb, line 24
def initialize_and_check_mapping_options(args, options)
  @file_path = File.absolute_path(args.first.to_s)
  @token     = options[:token] || current_token
  @proj      = options[:proj].to_s
  @version   = options[:version].to_s
  @build     = options[:build].to_s
end
uuid() click to toggle source
# File lib/flappy/util/mapping.rb, line 45
def uuid
  @uuid ||= fetch_user_uuid(@token)
end
zip_mapping_file(tmp_file_path) click to toggle source
# File lib/flappy/util/mapping.rb, line 59
def zip_mapping_file(tmp_file_path)
  if File.size?(tmp_file_path) > 50 * 1000 * 1000
    logger.info 'Zipping mapping file.......'

    system("zip -qr #{tmp_file_path}.zip #{tmp_file_path}")
    tmp_file_path += '.zip'

    logger.info "Zipped Mapping file size - #{File.size?(tmp_file_path)}"
  end

  tmp_file_path
end