app-info 2.6.5 → 2.7.0.beta1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/app_info.rb CHANGED
@@ -1,16 +1,23 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'app_info/util'
4
- require 'app_info/core_ext/object/try'
5
3
  require 'app_info/version'
4
+ require 'app_info/error'
5
+ require 'app_info/core_ext'
6
+ require 'app_info/helper'
7
+
6
8
  require 'app_info/info_plist'
7
9
  require 'app_info/mobile_provision'
10
+
8
11
  require 'app_info/ipa'
9
12
  require 'app_info/ipa/plugin'
10
13
  require 'app_info/ipa/framework'
14
+
11
15
  require 'app_info/apk'
16
+ require 'app_info/aab'
17
+
12
18
  require 'app_info/proguard'
13
19
  require 'app_info/dsym'
20
+
14
21
  require 'app_info/macos'
15
22
 
16
23
  # fix invaild date format warnings
@@ -18,69 +25,75 @@ Zip.warn_invalid_date = false
18
25
 
19
26
  # AppInfo Module
20
27
  module AppInfo
21
- # Get a new parser for automatic
22
- def self.parse(file)
23
- raise NotFoundError, file unless File.exist?(file)
24
-
25
- case file_type(file)
26
- when :ipa then IPA.new(file)
27
- when :apk then APK.new(file)
28
- when :mobileprovision then MobileProvision.new(file)
29
- when :dsym then DSYM.new(file)
30
- when :proguard then Proguard.new(file)
31
- when :macos then Macos.new(file)
32
- else
33
- raise UnkownFileTypeError, "Sorry, AppInfo can not detect file type: #{file}"
28
+ class << self
29
+ # Get a new parser for automatic
30
+ def parse(file)
31
+ raise NotFoundError, file unless File.exist?(file)
32
+
33
+ case file_type(file)
34
+ when :ipa then IPA.new(file)
35
+ when :apk then APK.new(file)
36
+ when :aab then AAB.new(file)
37
+ when :mobileprovision then MobileProvision.new(file)
38
+ when :dsym then DSYM.new(file)
39
+ when :proguard then Proguard.new(file)
40
+ when :macos then Macos.new(file)
41
+ else
42
+ raise UnkownFileTypeError, "Do not detect file type: #{file}"
43
+ end
44
+ end
45
+ alias dump parse
46
+
47
+ # Detect file type by read file header
48
+ #
49
+ # TODO: This can be better solution, if anyone knows, tell me please.
50
+ def file_type(file)
51
+ header_hex = IO.read(file, 100)
52
+ type = if header_hex =~ /^\x50\x4b\x03\x04/
53
+ detect_zip_file(file)
54
+ else
55
+ detect_mobileprovision(header_hex)
56
+ end
57
+
58
+ type || :unkown
34
59
  end
35
- end
36
- singleton_class.send(:alias_method, :dump, :parse)
37
-
38
- # Detect file type by read file header
39
- #
40
- # TODO: This can be better way to solvt, if anyone knows, tell me please.
41
- def self.file_type(file)
42
- header_hex = IO.read(file, 100)
43
- type = if header_hex =~ /^\x50\x4b\x03\x04/
44
- detect_zip_file(file)
45
- else
46
- detect_mobileprovision(header_hex)
47
- end
48
-
49
- type || :unkown
50
- end
51
60
 
52
- # :nodoc:
53
- def self.detect_zip_file(file)
54
- Zip.warn_invalid_date = false
55
- zip_file = Zip::File.open(file)
61
+ private
56
62
 
57
- return :proguard unless zip_file.glob('*mapping*.txt').empty?
58
- return :apk if !zip_file.find_entry('AndroidManifest.xml').nil? &&
59
- !zip_file.find_entry('classes.dex').nil?
63
+ # :nodoc:
64
+ def detect_zip_file(file)
65
+ Zip.warn_invalid_date = false
66
+ zip_file = Zip::File.open(file)
60
67
 
61
- return :macos if !zip_file.glob('*/Contents/MacOS/*').empty? &&
62
- !zip_file.glob('*/Contents/Info.plist').empty?
68
+ return :proguard unless zip_file.glob('*mapping*.txt').empty?
69
+ return :apk if !zip_file.find_entry('AndroidManifest.xml').nil? &&
70
+ !zip_file.find_entry('classes.dex').nil?
63
71
 
64
- zip_file.each do |f|
65
- path = f.name
72
+ return :aab if !zip_file.find_entry('base/manifest/AndroidManifest.xml').nil? &&
73
+ !zip_file.find_entry('BundleConfig.pb').nil?
66
74
 
67
- return :ipa if path.include?('Payload/') && path.end_with?('Info.plist')
68
- return :dsym if path.include?('Contents/Resources/DWARF/')
75
+ return :macos if !zip_file.glob('*/Contents/MacOS/*').empty? &&
76
+ !zip_file.glob('*/Contents/Info.plist').empty?
77
+
78
+ zip_file.each do |f|
79
+ path = f.name
80
+
81
+ return :ipa if path.include?('Payload/') && path.end_with?('Info.plist')
82
+ return :dsym if path.include?('Contents/Resources/DWARF/')
83
+ end
84
+ ensure
85
+ zip_file.close
69
86
  end
70
- ensure
71
- zip_file.close
72
- end
73
- private_class_method :detect_zip_file
74
87
 
75
- PLIST_REGEX = /\x3C\x3F\x78\x6D\x6C/.freeze
76
- BPLIST_REGEX = /^\x62\x70\x6C\x69\x73\x74/.freeze
88
+ PLIST_REGEX = /\x3C\x3F\x78\x6D\x6C/.freeze
89
+ BPLIST_REGEX = /^\x62\x70\x6C\x69\x73\x74/.freeze
77
90
 
78
- # :nodoc:
79
- def self.detect_mobileprovision(hex)
80
- case hex
81
- when PLIST_REGEX, BPLIST_REGEX
82
- :mobileprovision
91
+ # :nodoc:
92
+ def detect_mobileprovision(hex)
93
+ case hex
94
+ when PLIST_REGEX, BPLIST_REGEX
95
+ :mobileprovision
96
+ end
83
97
  end
84
98
  end
85
- private_class_method :detect_mobileprovision
86
99
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: app-info
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.5
4
+ version: 2.7.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - icyleaf
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-17 00:00:00.000000000 Z
11
+ date: 2021-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: CFPropertyList
@@ -138,6 +138,20 @@ dependencies:
138
138
  - - "~>"
139
139
  - !ruby/object:Gem::Version
140
140
  version: 0.2.0
141
+ - !ruby/object:Gem::Dependency
142
+ name: google-protobuf
143
+ requirement: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - "~>"
146
+ - !ruby/object:Gem::Version
147
+ version: 3.18.0
148
+ type: :runtime
149
+ prerelease: false
150
+ version_requirements: !ruby/object:Gem::Requirement
151
+ requirements:
152
+ - - "~>"
153
+ - !ruby/object:Gem::Version
154
+ version: 3.18.0
141
155
  - !ruby/object:Gem::Dependency
142
156
  name: bundler
143
157
  requirement: !ruby/object:Gem::Requirement
@@ -218,9 +232,14 @@ files:
218
232
  - exe/app-info
219
233
  - lib/app-info.rb
220
234
  - lib/app_info.rb
235
+ - lib/app_info/aab.rb
221
236
  - lib/app_info/apk.rb
237
+ - lib/app_info/core_ext.rb
222
238
  - lib/app_info/core_ext/object/try.rb
239
+ - lib/app_info/core_ext/string/inflector.rb
223
240
  - lib/app_info/dsym.rb
241
+ - lib/app_info/error.rb
242
+ - lib/app_info/helper.rb
224
243
  - lib/app_info/info_plist.rb
225
244
  - lib/app_info/ipa.rb
226
245
  - lib/app_info/ipa/framework.rb
@@ -229,8 +248,14 @@ files:
229
248
  - lib/app_info/mobile_provision.rb
230
249
  - lib/app_info/png_uncrush.rb
231
250
  - lib/app_info/proguard.rb
251
+ - lib/app_info/protobuf/manifest.rb
252
+ - lib/app_info/protobuf/models/Configuration.proto
253
+ - lib/app_info/protobuf/models/Configuration_pb.rb
254
+ - lib/app_info/protobuf/models/README.md
255
+ - lib/app_info/protobuf/models/Resources.proto
256
+ - lib/app_info/protobuf/models/Resources_pb.rb
257
+ - lib/app_info/protobuf/resources.rb
232
258
  - lib/app_info/shell.rb
233
- - lib/app_info/util.rb
234
259
  - lib/app_info/version.rb
235
260
  homepage: http://github.com/icyleaf/app-info
236
261
  licenses:
@@ -247,9 +272,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
247
272
  version: '2.5'
248
273
  required_rubygems_version: !ruby/object:Gem::Requirement
249
274
  requirements:
250
- - - ">="
275
+ - - ">"
251
276
  - !ruby/object:Gem::Version
252
- version: '0'
277
+ version: 1.3.1
253
278
  requirements: []
254
279
  rubygems_version: 3.1.4
255
280
  signing_key:
data/lib/app_info/util.rb DELETED
@@ -1,98 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'zip'
4
- require 'fileutils'
5
- require 'securerandom'
6
-
7
- module AppInfo
8
- class Error < StandardError; end
9
-
10
- class NotFoundError < Error; end
11
-
12
- class UnkownFileTypeError < Error; end
13
-
14
- # App Platform
15
- module Platform
16
- MACOS = 'macOS'
17
- IOS = 'iOS'
18
- ANDROID = 'Android'
19
- DSYM = 'dSYM'
20
- PROGUARD = 'Proguard'
21
- end
22
-
23
- # Device Type
24
- module Device
25
- MACOS = 'macOS'
26
- IPHONE = 'iPhone'
27
- IPAD = 'iPad'
28
- UNIVERSAL = 'Universal'
29
- end
30
-
31
- # Icon Key
32
- ICON_KEYS = {
33
- AppInfo::Device::IPHONE => ['CFBundleIcons'],
34
- AppInfo::Device::IPAD => ['CFBundleIcons~ipad'],
35
- AppInfo::Device::UNIVERSAL => ['CFBundleIcons', 'CFBundleIcons~ipad'],
36
- AppInfo::Device::MACOS => %w[CFBundleIconFile CFBundleIconName]
37
- }.freeze
38
-
39
- FILE_SIZE_UNITS = %w[B KB MB GB TB].freeze
40
-
41
- # AppInfo Util
42
- module Util
43
- def self.format_key(key)
44
- key = key.to_s
45
- return key unless key.include?('_')
46
-
47
- key.split('_').map(&:capitalize).join
48
- end
49
-
50
- def self.file_size(file, human_size)
51
- file_size = File.size(file)
52
- human_size ? size_to_human_size(file_size) : file_size
53
- end
54
-
55
- def self.size_to_human_size(number)
56
- if number.to_i < 1024
57
- exponent = 0
58
- else
59
- max_exp = FILE_SIZE_UNITS.size - 1
60
- exponent = (Math.log(number) / Math.log(1024)).to_i
61
- exponent = max_exp if exponent > max_exp
62
- number = format('%<number>.2f', number: (number / (1024**exponent.to_f)))
63
- end
64
-
65
- "#{number} #{FILE_SIZE_UNITS[exponent]}"
66
- end
67
-
68
- # Unarchive zip file
69
- #
70
- # source: https://github.com/soffes/lagunitas/blob/master/lib/lagunitas/ipa.rb
71
- def self.unarchive(file, path: nil)
72
- path = path ? "#{path}-" : ''
73
- root_path = "#{Dir.mktmpdir}/AppInfo-#{path}#{SecureRandom.hex}"
74
- Zip::File.open(file) do |zip_file|
75
- if block_given?
76
- yield root_path, zip_file
77
- else
78
- zip_file.each do |f|
79
- f_path = File.join(root_path, f.name)
80
- FileUtils.mkdir_p(File.dirname(f_path))
81
- zip_file.extract(f, f_path) unless File.exist?(f_path)
82
- end
83
- end
84
- end
85
-
86
- root_path
87
- end
88
-
89
- def self.tempdir(file, prefix:)
90
- dest_path ||= File.join(File.dirname(file), prefix)
91
- dest_file = File.join(dest_path, File.basename(file))
92
-
93
- Dir.mkdir(dest_path, 0_700) unless Dir.exist?(dest_path)
94
-
95
- dest_file
96
- end
97
- end
98
- end