structurebutcher 0.8.0 → 0.8.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 +4 -4
- data/lib/structurebutcher.rb +12 -15
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b581968778508a6fbd6650c20392804565bc182
|
4
|
+
data.tar.gz: ccf15aae7b2359db457c26b1e29a982c03be9833
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38403b8d12fbadab67caff911f57cf7e1db0e967446880ef08e8d597a71a0558f61f417e6dc69b1bcd85bea5da110c5ee92daf3d17f50878ec1f1ab59a81968a
|
7
|
+
data.tar.gz: 7664251c48a41de02468c795614f02f5c3b6b7702e1cedd4ba613b39d608893d2f281e19eaba7c74ede01485867c11f34a3263dcb7c2c05590410243338b56e4
|
data/lib/structurebutcher.rb
CHANGED
@@ -10,18 +10,6 @@ require 'base64'
|
|
10
10
|
#amputovat, implantovat
|
11
11
|
#amputate, implantate
|
12
12
|
|
13
|
-
class Hash
|
14
|
-
def sort_by_key(recursive = false, &block)
|
15
|
-
self.keys.sort(&block).reduce({}) do |seed, key|
|
16
|
-
seed[key] = self[key]
|
17
|
-
if recursive && seed[key].is_a?(Hash)
|
18
|
-
seed[key] = seed[key].sort_by_key(true, &block)
|
19
|
-
end
|
20
|
-
seed
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
13
|
class StructureButcher
|
26
14
|
def split_escape(str)
|
27
15
|
output = []
|
@@ -85,7 +73,7 @@ class StructureButcher
|
|
85
73
|
|
86
74
|
storer = StructureButcher::Storer.new
|
87
75
|
|
88
|
-
storer.save_structure(body
|
76
|
+
storer.save_structure(body, body_file, "yaml")
|
89
77
|
end
|
90
78
|
|
91
79
|
def implantate_struct_into_file(body_file, slot, part_struct)
|
@@ -102,7 +90,7 @@ class StructureButcher
|
|
102
90
|
butcher.implantate(body, slot, part_struct)
|
103
91
|
|
104
92
|
storer = StructureButcher::Storer.new
|
105
|
-
storer.save_structure(body
|
93
|
+
storer.save_structure(body, body_file, "yaml")
|
106
94
|
end
|
107
95
|
end
|
108
96
|
|
@@ -216,6 +204,15 @@ class StructureButcher::Storer
|
|
216
204
|
end
|
217
205
|
|
218
206
|
def save_structure(structure, filename, format)
|
219
|
-
|
207
|
+
sorted_structure = {}
|
208
|
+
structure.keys.each do |key|
|
209
|
+
value = structure[key]
|
210
|
+
if value.is_a?(Hash)
|
211
|
+
sorted_structure[key] = Hash[value.sort]
|
212
|
+
else
|
213
|
+
sorted_structure[key] = value
|
214
|
+
end
|
215
|
+
end
|
216
|
+
File.write(filename, structure_in_format(Hash[sorted_structure.sort], format))
|
220
217
|
end
|
221
218
|
end
|