structurebutcher 0.2.0 → 0.3.0

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 +15 -1
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 371a628ae975aa237e346b792e50c68cddf4ce48
4
- data.tar.gz: be882a48b8efa8cf5a30ec1745abb61b84d34c48
3
+ metadata.gz: a99db9d04f702bb44f5c57cf78854c348cb9f39e
4
+ data.tar.gz: 5fb7630a82a66c40af57fd743201dab002711ce5
5
5
  SHA512:
6
- metadata.gz: 7e9a328a688f72e98ccfaafcdc32e3a5dace7744bdcb7ffabc39c23dfb6ecfa375ba13b08b012de8672fa2df20e23c6f35dda7469cca6898cd30b814a49dd3e9
7
- data.tar.gz: 56af5fe37fd7ab0a0efca707b707cde33f7ad92cf232e30254d904f00d5306fe1afc35a48c208b16075dd1ac99dee372bca5ea6deb8b92253978daf074f09ed3
6
+ metadata.gz: a5153756f0c7fa0b3045efa4fd53443e0380aa6301eb91bb5d7cda82b8bc8c632b77cdf04385989f11871ac19d3f3150e04efcfd28d4a8d9a748f089f4370135
7
+ data.tar.gz: 8913a701324f13fc6f2025eeb2b6766d4462ae0ab975235494e959e82f647a177a63a021b3dd780e9db654193f0d02f0a7625700a420652fcccb57d0d18e0c7e
@@ -25,7 +25,10 @@ class StructureButcher
25
25
  last_key = keys.pop
26
26
  area = body
27
27
  while (key = keys.shift)
28
- area = area[key] #TODO: create hash if not exists
28
+ if area.has_key?(key)
29
+ then area[key] = {}
30
+ end
31
+ area = area[key]
29
32
  end
30
33
  area[last_key] = part
31
34
  end
@@ -52,6 +55,17 @@ class StructureButcher
52
55
  storer = StructureButcher::Storer.new
53
56
  storer.save_structure(body, body_file, "yaml")
54
57
  end
58
+
59
+ def implantate_struct_into_file(body_file, slot, part_struct)
60
+ parser = StructureButcher::Parser.new
61
+ body = parser.load_structure(body_file, "yaml")
62
+
63
+ butcher = StructureButcher.new
64
+ butcher.implantate(body, slot, part_struct)
65
+
66
+ storer = StructureButcher::Storer.new
67
+ storer.save_structure(body, body_file, "yaml")
68
+ end
55
69
  end
56
70
 
57
71
  class StructureButcher::Parser
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: structurebutcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miroslav Tynovsky
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-24 00:00:00.000000000 Z
11
+ date: 2015-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -52,7 +52,7 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.0.2
55
- description: Take config and put it to YAML under specific key
55
+ description: Read a config file and write it to a YAML file under specific key
56
56
  email: tynovsky@avast.com
57
57
  executables: []
58
58
  extensions: []