Sha256: ae1f643a0a0c0442ff8d30e7e2cd91632b7e06d28ef289248a898805b4e3673b

Contents?: true

Size: 1.98 KB

Versions: 9

Compression:

Stored size: 1.98 KB

Contents

# encoding: utf-8

require_relative './util/http'
require_relative './util/config'
require_relative './util/parser/apk'
require_relative './util/parser/ipa'
require_relative './util/login'
require_relative './util/me'
require_relative './util/info'
require_relative './util/build_common'
require_relative './util/build_ipa'
require_relative './util/build_apk'
require_relative './util/publish'
require_relative './util/mapping'

module FIR
  module Util
    extend ActiveSupport::Concern

    module ClassMethods
      include FIR::Http
      include FIR::Config
      include FIR::Login
      include FIR::Me
      include FIR::Info
      include FIR::BuildCommon
      include FIR::BuildIpa
      include FIR::BuildApk
      include FIR::Publish
      include FIR::Mapping

      attr_accessor :logger

      def fetch_user_info(token)
        get fir_api[:user_url], api_token: token
      end

      def fetch_user_uuid(token)
        user_info = fetch_user_info(token)
        user_info[:uuid]
      end

      def check_file_exist(path)
        return if File.file?(path)

        logger.error 'File does not exist'
        exit 1
      end

      def check_supported_file(path)
        return if APP_FILE_TYPE.include?(File.extname(path))

        logger.error 'Unsupported file type'
        exit 1
      end

      def check_token_cannot_be_blank(token)
        return unless token.blank?

        logger.error 'Token can not be blank'
        exit 1
      end

      def check_logined
        return unless current_token.blank?

        logger.error 'Please use `fir login` first'
        exit 1
      end

      def logger_info_blank_line
        logger.info ''
      end

      def logger_info_dividing_line
        logger.info '✈ -------------------------------------------- ✈'
      end

      def generate_rqrcode string, png_file_path
        qrcode = ::RQRCode::QRCode.new(string.to_s)
        qrcode.as_png(size: 500, border_modules: 2, file: png_file_path)
        png_file_path
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
fir-cli-1.3.4 lib/fir/util.rb
fir-cli-1.3.3 lib/fir/util.rb
fir-cli-1.3.2 lib/fir/util.rb
fir-cli-1.3.1 lib/fir/util.rb
fir-cli-1.3.0 lib/fir/util.rb
fir-cli-1.2.9 lib/fir/util.rb
fir-cli-1.2.8 lib/fir/util.rb
fir-cli-1.2.7 lib/fir/util.rb
fir-cli-1.2.6 lib/fir/util.rb