rat_trap 0.1.0 → 0.1.1
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 +8 -8
- data/lib/rat_trap.rb +19 -1
- data/lib/rat_trap/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YTgyZmY5YzQ3NTQ3MTI4Yzg5MTY5ZThhZGNiMGRjMGI1YzM3ODU2Mg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZmFiNjVjMzA0Y2M2MmIxODYyMmQzMWM3N2E3NTJmNWIyNGVkZDY3MQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZGE3OGJjYmIyZjMyOWRkNWExYWE5ZDcxNjFhYzdlNTNmMjFhZmE2Njg4ODUy
|
10
|
+
NmJiOTMyMGRmZWZkY2RmNjIyYzYxNDEzNDQyZWYzYTJmZjFkOTcyNTFkMTM0
|
11
|
+
YmQ1ZjQ4NmEyYmJiNTcyNzgzZDdiNzZkOWUwNDRmNmVkNjczOTI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZTUzYWZlZWI1YWY0NzdiM2ViZTBkMWUzMWI0MzI0ZmRhYTExZGI1Nzc2MzUx
|
14
|
+
ZGZkNzM2NGFmZmI2MWM0ZGU1NTE2YWM0YjE3ZTNiZDM5ZmQ5ZjU3NzYzOTA0
|
15
|
+
ZWFlYWU5YTllZTAyNmNkYjQ1YzEzNGMzNmYyMGI3MDM3ZDVjMWI=
|
data/lib/rat_trap.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "rat_trap/version"
|
2
2
|
require 'msgpack'
|
3
|
+
require 'json'
|
3
4
|
|
4
5
|
module RatTrap
|
5
6
|
|
@@ -50,13 +51,30 @@ module RatTrap
|
|
50
51
|
end
|
51
52
|
File.open(path, "wb") do |f|
|
52
53
|
rat = MessagePack.unpack(File.read(file))
|
53
|
-
data =
|
54
|
+
data =
|
55
|
+
case rat
|
56
|
+
when Hash
|
57
|
+
rat.each do |k, v|
|
58
|
+
if v.is_a? Array
|
59
|
+
rat[k] = v.map do |row|
|
60
|
+
row.to_s.gsub('"', '')
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
JSON.pretty_generate(rat)
|
65
|
+
when Array
|
66
|
+
pretty_print_array(rat)
|
67
|
+
end
|
54
68
|
f.write(data)
|
55
69
|
end
|
56
70
|
ensure
|
57
71
|
FileUtils.rm_rf(tempfile) unless options[:retain]
|
58
72
|
end
|
59
73
|
|
74
|
+
def pretty_print_array(as)
|
75
|
+
as.map(&:to_s).join("\n") + "\n"
|
76
|
+
end
|
77
|
+
|
60
78
|
def temp_path(file)
|
61
79
|
FileUtils.mkdir_p(TEMP_DIR)
|
62
80
|
File.join(TEMP_DIR, file)
|
data/lib/rat_trap/version.rb
CHANGED