app-info 2.0.0.beta1 → 2.0.0.beta3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f09c53a666307caf08ffdb39369ad9f888cdeff01cbbcf2c4e63eff5f396bfd5
4
- data.tar.gz: aff28d8f4b7356f11edd6793a13270f8eac843d3c02c79bf14aaad92218aca9c
3
+ metadata.gz: 70d4913abdb1ced1404730f117fda0fb82ed91d19e291659749d6cb8c50da8e7
4
+ data.tar.gz: 5a9f1b8d786a08e552ae334679639575c1d7fd462d0f2ad6f970b0988b70e028
5
5
  SHA512:
6
- metadata.gz: a89ee897a4b5a3efa228ad73632cd01b6977465ffdc48c13900a4c8cbdb254ff413ce6a27ae96563661d5d9809a1adbdeed7b641254764bd288c875f17de1c7d
7
- data.tar.gz: 939cbe074276c8e708fdfbe3db8cf02bb42933041cf77e2e1b40850e8f77aad6eca5d211d26ff635cde276a9cc6874d945444188922be2589e90d6aff6308e0a
6
+ metadata.gz: 825bb3d01e2e05ac8dce27a343d4329673ee358bcd1dada568c72bf21b1469bfeb66d7cec31de3d2407634e64af1ad6bcc2b2d2bc5ddd314b17d61592e683380
7
+ data.tar.gz: 12a2f90a839ee938b29832272ca1410e0071d852f381353bff3e14f753f2946a108b6e90c04070f89e8966fe5e0cf75b80e42aa44ba735816c8c79ce8c04e55e
@@ -13,10 +13,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
13
13
 
14
14
  - Added .dSYM.zip format support
15
15
  - Added parse mobileprovision in Linux
16
+ - Added `AppInfo.file_type` to detect file type
16
17
 
17
18
  ### Changed
18
19
 
19
- - Parse macho-o header to detect file type instead of file extension name. (Maby be not fully support)
20
+ - Use parse Macho-O header and contents to detect file type instead of file extension name.
20
21
  - Dropped Ruby 2.2 and below versions support
21
22
 
22
23
  ## [1.1.2] (2019-09-19)
@@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.add_dependency 'pngdefry', '~> 0.1.2'
25
25
  spec.add_dependency 'ruby-macho', '~> 2.2.0'
26
26
  spec.add_dependency 'ruby_android', '~> 0.7.7'
27
+ spec.add_dependency 'rubyzip', '>= 1.2', '< 3.0'
27
28
 
28
29
  spec.add_development_dependency 'bundler', '>= 1.12'
29
30
  spec.add_development_dependency 'rake', '>= 10.0'
@@ -2,36 +2,35 @@
2
2
 
3
3
  require 'app_info/version'
4
4
  require 'app_info/parser'
5
+ require 'zip'
5
6
 
6
- #
7
7
  # AppInfo Module
8
8
  module AppInfo
9
9
  class NotFoundError < StandardError; end
10
- class NotAppError < StandardError; end
10
+ class UnkownFileTypeError < StandardError; end
11
11
 
12
12
  # Get a new parser for automatic
13
13
  def self.parse(file)
14
14
  raise NotFoundError, file unless File.exist?(file)
15
15
 
16
- case detect_file_type(file)
16
+ case file_type(file)
17
17
  when :ipa then Parser::IPA.new(file)
18
18
  when :apk then Parser::APK.new(file)
19
19
  when :mobileprovision then Parser::MobileProvision.new(file)
20
20
  when :dsym then Parser::DSYM.new(file)
21
21
  else
22
- raise NotAppError, file
22
+ raise UnkownFileTypeError, "Sorry, AppInfo can not detect file type: #{file}"
23
23
  end
24
24
  end
25
25
  singleton_class.send(:alias_method, :dump, :parse)
26
26
 
27
-
28
27
  # Detect file type by read file header
29
28
  #
30
29
  # TODO: This can be better way to solvt, if anyone knows, tell me please.
31
- def self.detect_file_type(file)
30
+ def self.file_type(file)
32
31
  header_hex = IO.read(file, 100)
33
32
  type = if header_hex =~ /^\x50\x4b\x03\x04/
34
- detect_zip_format(header_hex)
33
+ detect_zip_file(file)
35
34
  else
36
35
  detect_mobileprovision(header_hex)
37
36
  end
@@ -40,16 +39,17 @@ module AppInfo
40
39
  end
41
40
 
42
41
  # :nodoc:
43
- def self.detect_zip_format(hex)
44
- if hex =~ /\x63\x6C\x61\x73\x73\x65/ ||
45
- hex =~ /\x41\x6E\x64\x72\x6F\x69\x64\x4D\x61\x6E\x69\x66\x65\x73\x74/ ||
46
- hex =~ /\x4D\x45\x54\x41\x2D\x49\x4E\x46/
47
- :apk
48
- elsif hex.slice(13, 1) == "\x48" ||
49
- hex =~ /\x50\x61\x79\x6C\x6F\x61\x64/
50
- :ipa
51
- elsif hex.slice(12, 2) == "\x30\x4f"
52
- :dsym
42
+ def self.detect_zip_file(file)
43
+ Zip.warn_invalid_date = false
44
+ Zip::File.open(file) do |zip_file|
45
+ zip_file.each do |f|
46
+ path = f.name
47
+ name = File.basename(path)
48
+
49
+ return :apk if name == 'AndroidManifest.xml'
50
+ return :ipa if path.include?('Payload/') && name.end_with?('Info.plist')
51
+ return :dsym if path.include?('/DWARF/')
52
+ end
53
53
  end
54
54
  end
55
55
 
@@ -1,3 +1,4 @@
1
+ require 'zip'
1
2
  require 'macho'
2
3
  require 'app_info/core_ext/object/try'
3
4
 
@@ -16,24 +17,24 @@ module AppInfo
16
17
  end
17
18
 
18
19
  def machos
19
- @machos ||= case macho
20
+ @machos ||= case macho_type
20
21
  when ::MachO::MachOFile
21
- [MachO.new(macho, File.size(app_path))]
22
+ [MachO.new(macho_type, File.size(app_path))]
22
23
  else
23
- size = macho.fat_archs.each_with_object([]) do |arch, obj|
24
+ size = macho_type.fat_archs.each_with_object([]) do |arch, obj|
24
25
  obj << arch.size
25
26
  end
26
27
 
27
28
  machos = []
28
- macho.machos.each_with_index do |file, i|
29
+ macho_type.machos.each_with_index do |file, i|
29
30
  machos << MachO.new(file, size[i])
30
31
  end
31
32
  machos
32
33
  end
33
34
  end
34
35
 
35
- def macho
36
- @macho ||= ::MachO.open(app_path)
36
+ def macho_type
37
+ @macho_type ||= ::MachO.open(app_path)
37
38
  end
38
39
 
39
40
  def object
@@ -41,7 +42,13 @@ module AppInfo
41
42
  end
42
43
 
43
44
  def app_path
44
- @app_path ||= Dir.glob(File.join(contents, 'Contents', 'Resources', 'DWARF', '*')).first
45
+ unless @app_path
46
+ path = File.join(contents, 'Contents', 'Resources', 'DWARF')
47
+ name = Dir.entries(path).last
48
+ @app_path = File.join(path, name)
49
+ end
50
+
51
+ @app_path
45
52
  end
46
53
 
47
54
  private
@@ -56,8 +63,8 @@ module AppInfo
56
63
  Zip::File.open(@file) do |zip_file|
57
64
  zip_file.each do |f|
58
65
  dsym_dir ||= f.name
66
+
59
67
  f_path = File.join(@contents, f.name)
60
- FileUtils.mkdir_p(File.dirname(f_path))
61
68
  zip_file.extract(f, f_path) unless File.exist?(f_path)
62
69
  end
63
70
  end
@@ -1,3 +1,4 @@
1
+ require 'zip'
1
2
  require 'pngdefry'
2
3
  require 'fileutils'
3
4
  require 'securerandom'
@@ -202,7 +203,6 @@ module AppInfo
202
203
  Zip::File.open(@file) do |zip_file|
203
204
  zip_file.each do |f|
204
205
  f_path = File.join(@contents, f.name)
205
- FileUtils.mkdir_p(File.dirname(f_path))
206
206
  zip_file.extract(f, f_path) unless File.exist?(f_path)
207
207
  end
208
208
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AppInfo
4
- VERSION = '2.0.0.beta1'
4
+ VERSION = '2.0.0.beta3'
5
5
  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.0.0.beta1
4
+ version: 2.0.0.beta3
5
5
  platform: ruby
6
6
  authors:
7
7
  - icyleaf
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-08 00:00:00.000000000 Z
11
+ date: 2019-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: CFPropertyList
@@ -92,6 +92,26 @@ dependencies:
92
92
  - - "~>"
93
93
  - !ruby/object:Gem::Version
94
94
  version: 0.7.7
95
+ - !ruby/object:Gem::Dependency
96
+ name: rubyzip
97
+ requirement: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '1.2'
102
+ - - "<"
103
+ - !ruby/object:Gem::Version
104
+ version: '3.0'
105
+ type: :runtime
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '1.2'
112
+ - - "<"
113
+ - !ruby/object:Gem::Version
114
+ version: '3.0'
95
115
  - !ruby/object:Gem::Dependency
96
116
  name: bundler
97
117
  requirement: !ruby/object:Gem::Requirement
@@ -162,7 +182,6 @@ files:
162
182
  - lib/app_info/parser/ipa/info_plist.rb
163
183
  - lib/app_info/parser/ipa/mobile_provision.rb
164
184
  - lib/app_info/version.rb
165
- - plist.mobileprovision
166
185
  homepage: http://github.com/icyleaf/app-info
167
186
  licenses:
168
187
  - MIT
File without changes