structurebutcher 0.6.0 → 0.7.0
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 +57 -25
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8de11b61a4cff11073f600d70e13e1166df5ce85
|
4
|
+
data.tar.gz: 41461e5a17c76349926ce05accae503b16cc6415
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc1b1156c46e0ffcd9cfe568682f830aa3e5959f2b7cea466f7f3f9baf4b35cd02ad779ef39a568a879629630bc9514efd930f5debc272c51ead24d7fbfe4189
|
7
|
+
data.tar.gz: 16e70c42509b4c928433ac61afb873429d8d28236cd07bc7a27615330e97fdce4727bbdb6a0f0c27a0504760a652183238cac8ccde1c548cfb65e75a2e51c93c
|
data/lib/structurebutcher.rb
CHANGED
@@ -64,9 +64,9 @@ class StructureButcher
|
|
64
64
|
|
65
65
|
# make sure we work with hash
|
66
66
|
# it does not make sense to work with anything else
|
67
|
-
|
68
|
-
|
69
|
-
|
67
|
+
if not body.is_a?(Hash)
|
68
|
+
body = Hash.new
|
69
|
+
end
|
70
70
|
|
71
71
|
butcher = StructureButcher.new
|
72
72
|
part = butcher.implantate(body, slot, part)
|
@@ -81,9 +81,9 @@ class StructureButcher
|
|
81
81
|
|
82
82
|
# make sure we work with hash
|
83
83
|
# it does not make sense to work with anything else
|
84
|
-
|
85
|
-
|
86
|
-
|
84
|
+
if not body.is_a?(Hash)
|
85
|
+
body = Hash.new
|
86
|
+
end
|
87
87
|
|
88
88
|
butcher = StructureButcher.new
|
89
89
|
butcher.implantate(body, slot, part_struct)
|
@@ -95,21 +95,25 @@ end
|
|
95
95
|
|
96
96
|
class StructureButcher::Parser
|
97
97
|
def load_structure(filename, format)
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
98
|
+
begin
|
99
|
+
case format
|
100
|
+
when "json"
|
101
|
+
return load_json(filename)
|
102
|
+
when "yaml"
|
103
|
+
return load_yaml(filename)
|
104
|
+
when "properties"
|
105
|
+
return load_properties(filename)
|
106
|
+
when "javaprops"
|
107
|
+
return load_properties(filename)
|
108
|
+
when "hocon"
|
109
|
+
return load_hocon(filename)
|
110
|
+
when "base64"
|
111
|
+
return load_base64(filename)
|
112
|
+
else
|
113
|
+
raise "Not implemented"
|
114
|
+
end
|
115
|
+
rescue Exception => e
|
116
|
+
abort(e.message)
|
113
117
|
end
|
114
118
|
end
|
115
119
|
|
@@ -132,19 +136,47 @@ class StructureButcher::Parser
|
|
132
136
|
|
133
137
|
def load_json(filename)
|
134
138
|
file = File.read(filename)
|
135
|
-
|
139
|
+
result = nil
|
140
|
+
begin
|
141
|
+
result = recursive_stringify_keys(JSON.parse(file))
|
142
|
+
rescue
|
143
|
+
msg = "Error parsing '" + filename + "': " + $!.message
|
144
|
+
raise ArgumentError.new(msg)
|
145
|
+
end
|
146
|
+
return result
|
136
147
|
end
|
137
148
|
|
138
149
|
def load_yaml(filename)
|
139
|
-
|
150
|
+
result = nil
|
151
|
+
begin
|
152
|
+
result = recursive_stringify_keys(YAML.load_file(filename))
|
153
|
+
rescue
|
154
|
+
msg = "Error parsing '" + filename + "': " + $!.message
|
155
|
+
raise AbortException.new(msg)
|
156
|
+
end
|
157
|
+
return result
|
140
158
|
end
|
141
159
|
|
142
160
|
def load_properties(filename)
|
143
|
-
|
161
|
+
result = nil
|
162
|
+
begin
|
163
|
+
result = recursive_stringify_keys(JavaProperties.load(filename))
|
164
|
+
rescue
|
165
|
+
msg = "Error parsing '" + filename + "': " + $!.message
|
166
|
+
raise AbortException.new(msg)
|
167
|
+
end
|
168
|
+
return result
|
144
169
|
end
|
145
170
|
|
146
171
|
def load_hocon(filename)
|
147
|
-
|
172
|
+
result = nil
|
173
|
+
begin
|
174
|
+
result = recursive_stringify_keys(Hocon.load(filename))
|
175
|
+
rescue
|
176
|
+
msg = "Error parsing '" + filename + "': " + $!.message
|
177
|
+
raise AbortException.new(msg)
|
178
|
+
end
|
179
|
+
return result
|
148
180
|
end
|
149
181
|
|
150
182
|
def load_base64(filename)
|
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.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miroslav Tynovsky
|
@@ -79,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
79
|
version: '0'
|
80
80
|
requirements: []
|
81
81
|
rubyforge_project:
|
82
|
-
rubygems_version: 2.
|
82
|
+
rubygems_version: 2.2.2
|
83
83
|
signing_key:
|
84
84
|
specification_version: 4
|
85
85
|
summary: Config saver/restorer
|