crash_analysis 0.1.2 → 0.1.3

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
  SHA1:
3
- metadata.gz: 121ce33664df8108025e9ea5f6497389c847fa9f
4
- data.tar.gz: 3f6898d5d7f0bd2daf666ee5a1aaaf729c6915d5
3
+ metadata.gz: 71fd0c89a9da5f8cc0a714120a15052f248053b1
4
+ data.tar.gz: 67c79ebf66e6b5eb35eeadde3ecc0efa444666c4
5
5
  SHA512:
6
- metadata.gz: 898307096f3932cdf5a81688fbf7518a152ca8884fb5d8f5d272d3e8452d3612db3a8aa8cee12de0dade70b21d943201623851a36ed60ce7d2c93d8aca4c6d18
7
- data.tar.gz: 9f07866c61f097a3e26c2fd552d65ffa3c88a2dd9705b2c272e0552ce2557572da7484de2113ea8b92d4f43ab1152e9bf37d09232d396efdbb37612e339d24f6
6
+ metadata.gz: 0f4b6fe59bf034fddf38ab7139407e030faa741d658a7b5acca8117826404ad8b6a12b480505f6c815dcbce97b1e0dcf6a806f178404599b5234de39917083db
7
+ data.tar.gz: 25971506e95367aaac9e835ef03f9387b1a17643ccf431517ac7a06608eceb947bf06131a77ef344268a06d983c7135b2271b9067304c92bd4052343da1d0947
data/Gemfile CHANGED
@@ -1,4 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in crash_analysis.gemspec
4
+
4
5
  gemspec
data/bin/crash_analysis CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  require "crash_analysis"
4
4
 
5
- puts CrashAnalysis.run(ARGV[0])
5
+ puts CrashAnalysis.run(ARGV[0], ARGV[1])
@@ -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
@@ -1,3 +1,3 @@
1
1
  module CrashAnalysis
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -1,45 +1,6 @@
1
1
  require "crash_analysis/version"
2
2
 
3
- def traverse(filePath)
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
- def self.run(filePath)
35
+ Version = "0.1.3"
36
+ def self.run(filePath, rawFileSuffix)
76
37
  puts "running..."
77
- if filePath.nil? || filePath.empty?
78
- puts "error: need directory path"
79
- else
80
- if File.directory?(filePath)
81
- crashFileNames = traverse(filePath)
82
- if crashFileNames.nil? || crashFileNames.empty?
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
- AnalysisLog(crashFileNames)
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
- else
88
- puts "error: not a directory"
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.2
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-19 00:00:00.000000000 Z
11
+ date: 2015-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler