Sha256: 98b8e7edcc7ec493b9257180e28dd758b8b7f0464b8e346e88a334abb8acaba8

Contents?: true

Size: 1.55 KB

Versions: 1

Compression:

Stored size: 1.55 KB

Contents

require_relative 'log_helper'
require_relative 'pgyer_shortcut_helper'

module Lhj
  # version info
  class AppVersionInfo
    # @param [Symbol] env
    def initialize(env, build_number, work_path)
      @env = env
      @build_number = build_number
      @work_path = work_path
    end

    # build_app_version (build_app_version_no) (build: build_version)
    def build_info
      "#{build_app_version} (#{build_app_version_no}) (build: #{build_version})"
    end

    def build_app_version
      # app version '1.0.0'
      vers = []
      Dir.glob("#{@work_path}/*.xcodeproj/*.pbxproj").each do |file|
        File.readlines(file).each do |l|
          if /MARKETING_VERSION.*(\d+\.\d+\.\d+)/ =~ l
            ma = l.match(/(\d+\.\d+\.\d+)/)
            vers << ma[0]
          end
        end
      end
      vers[0]
    end

    def build_app_version_no
      # xcode build version
      # ${BUILD_NUMBER} of jenkins
      @build_number || '1'
    end

    def build_version
      # pu gong ying build number
      client = Lhj::PgyerShortcut.new(@env)
      version = 0
      version = client.build_version.to_i if client.build_version
      version += 1
      version.to_s
    end

    def build_updated
      time = Time.now
      time.strftime('%Y-%m-%d %H:%M:%S')
    end

    def branch_name
      Dir.chdir(@work_path) do
        Lhj::LogHelper.instance.current_branch(@work_path)
      end
    end

    def update_log
      Dir.chdir(@work_path) do
        Lhj::Actions.git_log_last_commits(' %an %ar - %s;', 3, :exclude_merges, 'short', false)
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lhj-tools-0.1.54 lib/lhj/helper/app_version_info.rb