whatbug 0.0.1 → 0.0.2

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/whatbug +24 -17
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1e95630e8ed7dd2bf91f11e7373386edfc20b1b5
4
- data.tar.gz: 4b8d89d58408c3503ae76d68d89257cc1b35c4f6
3
+ metadata.gz: 6291b4ad75ed3a0cd9a6b3e97e76b15dfb863823
4
+ data.tar.gz: e6d217e66bf3f62b2224090c4360b219a3693741
5
5
  SHA512:
6
- metadata.gz: e141682dcd4d9511cbb4927a1777a486c00f5800914fbf911c4e95846b604651accc66c437c280b221d385357a8ad3a90c6ce8008192fd374e7e17d7eee5fc71
7
- data.tar.gz: c1a58b2dafa4085a244bb1dc4a556e5d6ed59ff628cf18c750863be97906ade0d2bde0af0dc5a46b07165cfe4ac287b203d97d67c6592d06c8d8e96bef467eba
6
+ metadata.gz: cc7cd9d0add3f6189d8a1c7eaac271b1aac2c8ddc803051a143e25f05a54a0d497c5013b85b016d721c799baa8188105fc9fb021ccd783f0b8af4e5817445c37
7
+ data.tar.gz: cf4521d3c8a9a65d7d0aef6b4343d2fa63d988471a59c47bedf6fbd42b63d28d45f95c982bab77d0ffcccf5c0afb193d522201a90de68085bfd3102c8113f965
data/bin/whatbug CHANGED
@@ -76,8 +76,29 @@ def map_code(file, func, line, cutoff)
76
76
  end
77
77
  end
78
78
 
79
+ def render(traced_functions)
80
+ traced_functions
81
+ .reduce([]) do |acc, (file_name, funcs)|
82
+ funcs.each do |func_name, func|
83
+ trace_line = func.detect { |l| l[:in_trace] }
84
+
85
+ acc << "#{file_name}:#{trace_line[:line_num]} - #{func_name}"
86
+ func.each do |line|
87
+ line_num = line[:line_num].to_s.rjust(3, " ")
88
+ change_sym = line[:changed] ? "+" : " "
89
+ trace_sym = line[:in_trace] ? "X" : " "
90
+
91
+ acc << "#{change_sym}#{trace_sym}#{line_num}) #{line[:text]}"
92
+ end
93
+ end
94
+ acc
95
+ end
96
+ end
97
+
79
98
  def main(error_id, cutoff)
80
99
  cutoff = cutoff.nil? ? (Date.today - 7).to_datetime : DateTime.parse(cutoff)
100
+ project_root = ENV["PROJECT_ROOT"] || Dir.pwd
101
+
81
102
  tracer = Tracer.new()
82
103
 
83
104
  error = get_error(error_id)
@@ -85,7 +106,7 @@ def main(error_id, cutoff)
85
106
  .map { |trace| trace[:file] }
86
107
  .uniq
87
108
  .reduce({}) do |acc, file|
88
- parts = File.split(ENV["PROJECT_ROOT"]) + file.split("/")
109
+ parts = File.split(project_root) + file.split("/")
89
110
  path = File.join(*parts)
90
111
  code = File.read(path)
91
112
  acc[file] = {
@@ -96,7 +117,7 @@ def main(error_id, cutoff)
96
117
  acc
97
118
  end
98
119
 
99
- Dir.chdir(ENV["PROJECT_ROOT"])
120
+ Dir.chdir(project_root)
100
121
  traced_functions = error[:stack_trace]
101
122
  .reduce({}) do |acc, trace|
102
123
  file = files[trace[:file]]
@@ -112,21 +133,7 @@ def main(error_id, cutoff)
112
133
  acc
113
134
  end
114
135
 
115
- traced_functions
116
- .each do |file_name, funcs|
117
- funcs.each do |func_name, func|
118
- trace_line = func.detect { |l| l[:in_trace] }
119
-
120
- puts "#{file_name}:#{trace_line[:line_num]} - #{func_name}"
121
- func.each do |line|
122
- line_num = line[:line_num].to_s.rjust(3, " ")
123
- change_sym = line[:changed] ? "+" : " "
124
- trace_sym = line[:in_trace] ? "X" : " "
125
-
126
- puts "#{change_sym}#{trace_sym}#{line_num}) #{line[:text]}"
127
- end
128
- end
129
- end
136
+ STDOUT.puts render(traced_functions)
130
137
  end
131
138
 
132
139
  main(ARGV[0], ARGV[1])
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: whatbug
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Yahn