lhj-tools 0.2.56 → 0.2.57

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 82c93a210742ecf72d29fac19fdcf217bcc49009f524ec0c0024953b9072aa5f
4
- data.tar.gz: a7fd691691e09f01d76e04d67998a540a5051d38a617b35001e0f86876ea49f6
3
+ metadata.gz: 1522e2e897fadad490a8c1b9baaff75d7472a3d7deeadf7bdb790ff310bcd56d
4
+ data.tar.gz: fa96344cdf3abd706ac13f0b349a3c9b0eb3e745d4da0befb1dc0ef4fcc0d57f
5
5
  SHA512:
6
- metadata.gz: 995f03687c2891e11cea349bb6979c930b595d0e9a27f5382f931780fe0b6103a2dabb476471e48e467fde94ceeb5067568127a7d9dd555fbb535250810fe63e
7
- data.tar.gz: 2d55f0ed870d359e3a982fcdc4c90a6f328fb118f83c1c30926596109df1941e0d8b36e780d46cf6048e0dfd817610ab7b10105ad76184f44a8c0b03a8f453ed
6
+ metadata.gz: f8c8b06eb183abc0969c0ec0d09fccff56c2977ccc3f55923e49180759ac36dbce014f1a98297afd84e93f5befc8eda5f219c09e9792d65780b8af8949d25134
7
+ data.tar.gz: 9d7caf469da443e5be5b0aa963848cc0ce9f5eac7ae60542d67bdafee2841a7aa3bc8bfa0aca0f4f6422417e3144d300f5341ac38f39aaaf6052d4a8e0ff8eec
@@ -5,14 +5,14 @@ require_relative 'team_member_config'
5
5
  module Lhj
6
6
  # version info
7
7
  class AppVersionInfo
8
+
9
+ VERSION_REGEX = /^(?<begin>[^#]*MARKETING_VERSION\s*=\s*)(?<value>(?<major>[0-9]+)(\.(?<minor>[0-9]+))?(\.(?<patch>[0-9]+))?(?<appendix>(\.[0-9]+)*)?(-(?<prerelease>(.+)))?)(?<end>)/
10
+
8
11
  # @param [Symbol] env
9
12
  def initialize(env, build_number, work_path)
10
13
  @env = env
11
14
  @build_number = build_number
12
15
  @work_path = work_path
13
-
14
- version_var_name = 'MARKETING_VERSION'
15
- @version_regex = /^(?<begin>[^#]*#{version_var_name}\s*=\s*)(?<value>(?<major>[0-9]+)(\.(?<minor>[0-9]+))?(\.(?<patch>[0-9]+))?(?<appendix>(\.[0-9]+)*)?(-(?<prerelease>(.+)))?)(?<end>)/i
16
16
  modify_code
17
17
  end
18
18
 
@@ -70,25 +70,27 @@ module Lhj
70
70
  "#{build_app_version} (#{build_app_version_no}) (build: #{build_version})"
71
71
  end
72
72
 
73
- def build_app_version
74
- # app version '1.0.0'
73
+ def self.all_app_version(path)
75
74
  vers = []
76
- Dir.glob("#{@work_path}/*.xcodeproj/*.pbxproj").each do |file|
75
+ Dir.glob("#{path}/*.xcodeproj/*.pbxproj").each do |file|
77
76
  File.readlines(file).each do |l|
78
77
  next unless /MARKETING_VERSION/ =~ l
79
78
 
80
- version_match = @version_regex.match(l)
81
- major = version_match[:major].to_i
82
- minor = version_match[:minor].to_i || 0
83
- patch = version_match[:patch].to_i || 0
84
- vers << { value: version_match[:value], major: major, minor: minor, patch: patch }
79
+ vers << fetch_version(l)
85
80
  end
86
81
  end
87
- list = max_version(vers)
88
- list.last[:value]
82
+ sort_version_list(vers)
89
83
  end
90
84
 
91
- def max_version(list)
85
+ def self.fetch_version(line)
86
+ version_match = VERSION_REGEX.match(line)
87
+ major = version_match[:major].to_i
88
+ minor = version_match[:minor].to_i || 0
89
+ patch = version_match[:patch].to_i || 0
90
+ { value: version_match[:value], major: major, minor: minor, patch: patch }
91
+ end
92
+
93
+ def self.sort_version_list(list)
92
94
  list.sort do |a, b|
93
95
  ma = a[:major] <=> b[:major]
94
96
  ma = a[:minor] <=> b[:minor] if ma.zero?
@@ -97,6 +99,12 @@ module Lhj
97
99
  end
98
100
  end
99
101
 
102
+ def build_app_version
103
+ # app version '1.0.0'
104
+ vers = AppVersionInfo.all_app_version(@work_path)
105
+ vers.last[:value]
106
+ end
107
+
100
108
  def build_app_version_no
101
109
  # xcode build version
102
110
  # ${BUILD_NUMBER} of jenkins
data/lib/lhj/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Lhj
4
- VERSION = '0.2.56'
4
+ VERSION = '0.2.57'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lhj-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.56
4
+ version: 0.2.57
5
5
  platform: ruby
6
6
  authors:
7
7
  - lihaijian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-12 00:00:00.000000000 Z
11
+ date: 2023-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xcodeproj