crash_analysis 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/bin/crash_analysis +1 -1
- data/crash_analysis.gemspec +1 -0
- data/lib/crash_analysis/version.rb +1 -1
- data/lib/crash_analysis.rb +81 -52
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71fd0c89a9da5f8cc0a714120a15052f248053b1
|
4
|
+
data.tar.gz: 67c79ebf66e6b5eb35eeadde3ecc0efa444666c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f4b6fe59bf034fddf38ab7139407e030faa741d658a7b5acca8117826404ad8b6a12b480505f6c815dcbce97b1e0dcf6a806f178404599b5234de39917083db
|
7
|
+
data.tar.gz: 25971506e95367aaac9e835ef03f9387b1a17643ccf431517ac7a06608eceb947bf06131a77ef344268a06d983c7135b2271b9067304c92bd4052343da1d0947
|
data/Gemfile
CHANGED
data/bin/crash_analysis
CHANGED
data/crash_analysis.gemspec
CHANGED
@@ -27,6 +27,7 @@ Gem::Specification.new do |spec|
|
|
27
27
|
# spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
28
|
spec.executables = ["crash_analysis"]
|
29
29
|
spec.require_paths = ["lib"]
|
30
|
+
# spec.add_runtime_dependency "timers"
|
30
31
|
spec.add_development_dependency "bundler", "~> 1.10"
|
31
32
|
spec.add_development_dependency "rake", "~> 10.0"
|
32
33
|
end
|
data/lib/crash_analysis.rb
CHANGED
@@ -1,45 +1,6 @@
|
|
1
1
|
require "crash_analysis/version"
|
2
2
|
|
3
|
-
|
4
|
-
crashFileNames = Array.new
|
5
|
-
countApp = 0
|
6
|
-
countDSYM = 0
|
7
|
-
if File.directory?(filePath)
|
8
|
-
Dir.foreach(filePath) do |fileName|
|
9
|
-
fileSuffixArray = fileName.strip.split(".")
|
10
|
-
if fileSuffixArray.last == "crash"
|
11
|
-
fileSuffixArray.pop
|
12
|
-
crashFileNames << (filePath + "/" + fileSuffixArray.first)
|
13
|
-
end
|
14
|
-
if fileSuffixArray.last == "app"
|
15
|
-
countApp += 1
|
16
|
-
end
|
17
|
-
if fileSuffixArray.last == "dSYM"
|
18
|
-
countDSYM += 1
|
19
|
-
end
|
20
|
-
end
|
21
|
-
else
|
22
|
-
puts "Files:" + filePath
|
23
|
-
end
|
24
|
-
|
25
|
-
if countApp != 1 || countDSYM !=1
|
26
|
-
puts "error:\n"
|
27
|
-
puts "make sure the directory contains those files: one .app file & one .dSYM file & related crash files"
|
28
|
-
return
|
29
|
-
end
|
30
|
-
|
31
|
-
return crashFileNames
|
32
|
-
end
|
33
|
-
|
34
|
-
def AnalysisLog(crashFileNames)
|
35
|
-
cmd = "/Applications/Xcode.app/Contents/SharedFrameworks/DTDeviceKitBase.framework/Versions/A/Resources/symbolicatecrash"
|
36
|
-
evn = "export DEVELOPER_DIR='/Applications/XCode.app/Contents/Developer'"
|
37
|
-
crashFileNames.prog_each {
|
38
|
-
|fileName|
|
39
|
-
system("#{evn} \n #{cmd} #{fileName}.crash BDPhoneBrowser.app.dSYM > #{fileName}.log")
|
40
|
-
}
|
41
|
-
end
|
42
|
-
|
3
|
+
# Utils
|
43
4
|
class Array
|
44
5
|
def prog_each(&block)
|
45
6
|
bar_length = (`tput cols` || 80).to_i - 30
|
@@ -69,24 +30,92 @@ class Array
|
|
69
30
|
end
|
70
31
|
end
|
71
32
|
|
72
|
-
#
|
73
|
-
|
33
|
+
# Main
|
74
34
|
module CrashAnalysis
|
75
|
-
|
35
|
+
Version = "0.1.3"
|
36
|
+
def self.run(filePath, rawFileSuffix)
|
76
37
|
puts "running..."
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
38
|
+
analysis = Analysis.new()
|
39
|
+
analysis.run(filePath, rawFileSuffix)
|
40
|
+
end
|
41
|
+
|
42
|
+
class Analysis
|
43
|
+
|
44
|
+
def initialize()
|
45
|
+
@percentCount = 0
|
46
|
+
end
|
47
|
+
|
48
|
+
def run(filePath, rawFileSuffix)
|
49
|
+
if rawFileSuffix.nil? || rawFileSuffix.empty?
|
50
|
+
puts "error: need 2 arguments DirPath & raw log file suffix like:txt, log, crash..."
|
83
51
|
return
|
52
|
+
end
|
53
|
+
if filePath.nil? || filePath.empty?
|
54
|
+
puts "error: need directory path"
|
84
55
|
else
|
85
|
-
|
56
|
+
if File.directory?(filePath)
|
57
|
+
crashFileNames = traverse(filePath, rawFileSuffix)
|
58
|
+
if crashFileNames.nil? || crashFileNames.empty?
|
59
|
+
return
|
60
|
+
else
|
61
|
+
AnalysisLog(crashFileNames, rawFileSuffix, filePath)
|
62
|
+
end
|
63
|
+
else
|
64
|
+
puts "error: not a directory"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def traverse(filePath, rawFileSuffix)
|
70
|
+
crashFileNames = Array.new
|
71
|
+
countApp = 0
|
72
|
+
countDSYM = 0
|
73
|
+
if File.directory?(filePath)
|
74
|
+
Dir.foreach(filePath) do |fileName|
|
75
|
+
fileSuffixArray = fileName.strip.split(".")
|
76
|
+
if fileSuffixArray.last == rawFileSuffix
|
77
|
+
fileSuffixArray.pop
|
78
|
+
crashFileNames << (filePath + "/" + fileSuffixArray.first)
|
86
79
|
end
|
87
|
-
|
88
|
-
|
80
|
+
if fileSuffixArray.last == "app"
|
81
|
+
countApp += 1
|
82
|
+
end
|
83
|
+
if fileSuffixArray.last == "dSYM"
|
84
|
+
countDSYM += 1
|
85
|
+
end
|
86
|
+
end
|
87
|
+
else
|
88
|
+
puts "Files:" + filePath
|
89
|
+
end
|
90
|
+
|
91
|
+
if countApp != 1 || countDSYM !=1 || crashFileNames.count < 1
|
92
|
+
puts "error:\n"
|
93
|
+
puts "make sure the directory contains those files: one .app file & one .dSYM file & related crash files"
|
94
|
+
return
|
95
|
+
end
|
96
|
+
|
97
|
+
return crashFileNames
|
98
|
+
end
|
99
|
+
|
100
|
+
def AnalysisLog(crashFileNames, rawFileSuffix, filePath)
|
101
|
+
cmd = "/Applications/Xcode.app/Contents/SharedFrameworks/DTDeviceKitBase.framework/Versions/A/Resources/symbolicatecrash"
|
102
|
+
evn = "export DEVELOPER_DIR='/Applications/XCode.app/Contents/Developer'"
|
103
|
+
logDir = filePath + "/crash_logs"
|
104
|
+
|
105
|
+
if !File.directory?(logDir)
|
106
|
+
Dir.mkdir(logDir)
|
107
|
+
end
|
108
|
+
|
109
|
+
for fileName in crashFileNames
|
110
|
+
shortFileName = fileName.split("/").last
|
111
|
+
outputFile = logDir + "/" + shortFileName +".log"
|
112
|
+
system("#{evn} \n #{cmd} #{fileName}.#{rawFileSuffix} BDPhoneBrowser.app.dSYM > #{outputFile}")
|
113
|
+
@percentCount = @percentCount + 1
|
114
|
+
precent = ((@percentCount.to_f / crashFileNames.count.to_f) * 10000).round / 10000.0
|
115
|
+
str = (precent * 100).to_s
|
116
|
+
print "\r #{str[0,4]}%"
|
89
117
|
end
|
118
|
+
puts "\n Done."
|
90
119
|
end
|
91
120
|
end
|
92
121
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crash_analysis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- HongliYu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|