bimbly 1.2.1 → 1.3.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/bimbly.rb +74 -2
- 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: 73d9be79026f790ae5d9ef131774fb81d15b7ac2
|
4
|
+
data.tar.gz: ecee06ae7896ac18b9c46876c4cdf8d99b33bd4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ddc0e539932fb6c30b6ca7ebaa2dd11addab6130db31f0d3015a1b67f4d298f60986e9fc66c55e097c294bdc2d28326d74e2f15d0a69d3b53d85554ef8f11e3e
|
7
|
+
data.tar.gz: 5e47a884eb91b74850e7f0772b7de5d045b37a8977e03b64a11587db0a32a1b12f43d121bf53223416181908d82429b5d827f2641d3e8ba49c8add41baa964a6
|
data/lib/bimbly.rb
CHANGED
@@ -7,8 +7,8 @@ require 'pp'
|
|
7
7
|
class Bimbly
|
8
8
|
attr_reader :data_type, :error_codes, :error_names, :obj_sets
|
9
9
|
attr_accessor :array, :base_url, :cert, :doc_pointer, :file, :file_select, :headers, :mando_array,
|
10
|
-
:meth_name, :menu, :param_pointer, :password, :pointer, :port, :req_pointer,
|
11
|
-
:verb
|
10
|
+
:meth_name, :menu, :param_pointer, :password, :pointer, :port, :req_pointer,
|
11
|
+
:saved_array, :user, :verb
|
12
12
|
|
13
13
|
MANDO_EXCEPT = { create_volumes: ['size'] }
|
14
14
|
|
@@ -26,6 +26,7 @@ class Bimbly
|
|
26
26
|
end
|
27
27
|
|
28
28
|
@meth_name = nil
|
29
|
+
@saved_array = []
|
29
30
|
|
30
31
|
@base_url = "NotConnected"
|
31
32
|
@menu = []
|
@@ -161,6 +162,8 @@ class Bimbly
|
|
161
162
|
@meth_name = nil
|
162
163
|
@doc_pointer = @obj_sets
|
163
164
|
@param_pointer = @obj_sets
|
165
|
+
|
166
|
+
return nil
|
164
167
|
end
|
165
168
|
|
166
169
|
def details
|
@@ -214,6 +217,74 @@ class Bimbly
|
|
214
217
|
return nil
|
215
218
|
end
|
216
219
|
|
220
|
+
def save
|
221
|
+
#Method to save call to array
|
222
|
+
method_array = @meth_name.to_s.split("_")
|
223
|
+
|
224
|
+
operation = method_array.shift
|
225
|
+
|
226
|
+
if method_array.last == "id"
|
227
|
+
method_array.pop(2)
|
228
|
+
elsif method_array.last == "detailed"
|
229
|
+
method_array.pop
|
230
|
+
end
|
231
|
+
|
232
|
+
object = method_array.join("_")
|
233
|
+
|
234
|
+
operations_hash = {}
|
235
|
+
|
236
|
+
if @meth_name.match(/_by_id/)
|
237
|
+
id = @uri.match(/#{object}\/(.*)/)[1]
|
238
|
+
id = id.split("/")[0]
|
239
|
+
operations_hash['id'] = id unless id.nil?
|
240
|
+
end
|
241
|
+
|
242
|
+
operations_hash['params'] = extract_params if @uri.match(/\?/)
|
243
|
+
operations_hash['request'] = @payload unless @payload.nil?
|
244
|
+
|
245
|
+
if operations_hash.empty?
|
246
|
+
@saved_array << { operation => [ object ] }
|
247
|
+
else
|
248
|
+
@saved_array << { operation => [ object => operations_hash ] }
|
249
|
+
end
|
250
|
+
|
251
|
+
reset
|
252
|
+
end
|
253
|
+
|
254
|
+
def review
|
255
|
+
#Method to review calls that are saved
|
256
|
+
@saved_array.each do |ele|
|
257
|
+
pp ele
|
258
|
+
end
|
259
|
+
|
260
|
+
return nil
|
261
|
+
end
|
262
|
+
|
263
|
+
def create_playbook(file)
|
264
|
+
#Method to output saved calls to a yaml formated playbook
|
265
|
+
raise ArgumentError, "Supply #create_playbook with a file name" if file.nil?
|
266
|
+
File.write(file, @saved_array.to_yaml)
|
267
|
+
|
268
|
+
return nil
|
269
|
+
end
|
270
|
+
|
271
|
+
def create_template(file)
|
272
|
+
#Method to take saved calls, scrub data, and create a yml template for them
|
273
|
+
raise ArgumentError, "Supply #create_template with a file name" if file.nil?
|
274
|
+
end
|
275
|
+
|
276
|
+
def extract_params
|
277
|
+
params_hash = {}
|
278
|
+
params = @uri.split("?")[1]
|
279
|
+
params_array = params.split("&")
|
280
|
+
params_array.each do |param|
|
281
|
+
key, value = param.split("=")
|
282
|
+
|
283
|
+
params_hash[key] = value
|
284
|
+
end
|
285
|
+
params_hash
|
286
|
+
end
|
287
|
+
|
217
288
|
def build_params(hash)
|
218
289
|
raise ArgumentError, "Please provide a valid hash for parameters" unless
|
219
290
|
hash.instance_of? Hash and hash != {}
|
@@ -284,6 +355,7 @@ class Bimbly
|
|
284
355
|
if not payload.nil?
|
285
356
|
payload = JSON.parse(payload) if payload.class == String
|
286
357
|
payload = payload["data"] if payload.keys.include?("data")
|
358
|
+
payload = Hash[payload.map{|(k,v)| [k.to_s,v]}]
|
287
359
|
end
|
288
360
|
|
289
361
|
@uri = uri
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bimbly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kyle Kennedy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|