Skip to content

Commit a4bc197

Browse files
committed
add pretty print for hashes in issues
1 parent deb99f4 commit a4bc197

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ spec/reports
1515
test/tmp
1616
test/version_tmp
1717
tmp
18+
.ruby-version
1819

1920
# YARD artifacts
2021
.yardoc

Diff for: lib/errbit_plugin/issue_tracker.rb

+17
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,22 @@ def initialize(app, params)
66
@app = app
77
@params = params
88
end
9+
10+
def pretty_hash(hash, nesting = 0)
11+
tab_size = 2
12+
nesting += 1
13+
14+
pretty = "{"
15+
sorted_keys = hash.keys.sort
16+
sorted_keys.each do |key|
17+
val = hash[key].is_a?(Hash) ? pretty_hash(hash[key], nesting) : hash[key].inspect
18+
pretty += "\n#{' '*nesting*tab_size}"
19+
pretty += "#{key.inspect} => #{val}"
20+
pretty += "," unless key == sorted_keys.last
21+
22+
end
23+
nesting -= 1
24+
pretty += "\n#{' '*nesting*tab_size}}"
25+
end
926
end
1027
end

0 commit comments

Comments
 (0)