structurebutcher 0.8.0 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/structurebutcher.rb +12 -15
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: db853d50c1ba07f0bc5a4e4d990c4586b4ba17d5
4
- data.tar.gz: 337b870faf1fad12a15767be0b246958286442da
3
+ metadata.gz: 5b581968778508a6fbd6650c20392804565bc182
4
+ data.tar.gz: ccf15aae7b2359db457c26b1e29a982c03be9833
5
5
  SHA512:
6
- metadata.gz: b694dce96c8783c94d473fdb581f56b504c4d181985e0bfcf7061cb7b7f5eb5eaad9f1c6f0a627c2a3d9a1f7d09c11647a35c5a1de8a07d43262bcb93af3ee0e
7
- data.tar.gz: 592094360fa418d177bc3e7dbede2832978d16cfa8a17cbfdd07f740e62e472b611d9b5b8a45852125fc2a249814408224178b44d0ca1c043f25957dd2d256b7
6
+ metadata.gz: 38403b8d12fbadab67caff911f57cf7e1db0e967446880ef08e8d597a71a0558f61f417e6dc69b1bcd85bea5da110c5ee92daf3d17f50878ec1f1ab59a81968a
7
+ data.tar.gz: 7664251c48a41de02468c795614f02f5c3b6b7702e1cedd4ba613b39d608893d2f281e19eaba7c74ede01485867c11f34a3263dcb7c2c05590410243338b56e4
@@ -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.sort_by_key(true), body_file, "yaml")
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.sort_by_key(true), body_file, "yaml")
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
- File.write(filename, structure_in_format(structure, format))
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: structurebutcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miroslav Tynovsky