rbkubemq 0.1.2 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8620b009b9e3e3fd5341369d20ba57dab654713ede62a56b6f3f3c9f3a1054cb
4
- data.tar.gz: 75d00093b03fabfeb67140dde1fa0f4d42dbe1b839568bbb8c38cb0d0d5d876c
3
+ metadata.gz: 90339a3e09009ba583221fa436e0401338c3988c683da4b68d546e8ace288834
4
+ data.tar.gz: 26d4c093349193535391b731dc6133432abfa4954b1be34dbc0cca0fac142742
5
5
  SHA512:
6
- metadata.gz: 734baf78fb2f696ab7590054658e48752296d60c44fd7335c21cbbfd5db3659724b46046f0ac589f290ff891b45e64978a2be464b9b5e8773a148d2e0e620458
7
- data.tar.gz: ae4e559ab3e015e056388f88c24e64cb6368aa3bfd0f5f7b67f29da8586004d4606969e4f2ad9bb6061adc69b6c15a4a982f93f331ddf7be8b5a361639751c4b
6
+ metadata.gz: 70103d6212b3b1fb8548003335531d848813028474be3b50c23de126872c3bd0a4cabcf9146be3a76c6c983552815cb1fb95e3266e0ec57f5327101fafdf6a61
7
+ data.tar.gz: 6d54190afa3a96958dd6202d0ebf1e7f5c62943c59ad0f7e3bb7730f6d7589d558a366edf7464d27a6beae4a6d327b769fd4a6caa3d7d0e1c254be3df7f89d78
@@ -4,7 +4,7 @@ require "rake"
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = 'rbkubemq'
7
- s.version = '0.1.2'
7
+ s.version = '0.1.3'
8
8
  s.authors = ['Stefano Martin']
9
9
  s.email = ['stefano@seluxit.com']
10
10
  s.homepage = 'https://github.com/Seluxit/RBKubeMQ'
@@ -2,19 +2,32 @@ module RBKubeMQ
2
2
  class Utility
3
3
  def self.dump(hash)
4
4
  hash.compact!
5
- hash["Body"] = Base64.encode64(hash["Body"].to_s)
5
+ hash["Body"] = Base64.encode64(Oj.dump(hash["Body"], mode: :json))
6
6
  Oj.dump(hash, mode: :json)
7
7
  end
8
8
 
9
- def self.load(hash)
10
- hash = Oj.load(hash) if hash.is_a?(String)
9
+ def self.load(hash, parse_body: true)
10
+ hash = Oj.load(hash, mode: :json, symbol_keys: false) if hash.is_a?(String)
11
11
  unless hash["Body"].nil?
12
- hash["Body"] = Base64.decode64(hash["Body"].to_s)
12
+ hash["Body"] = parsing_body(hash["Body"], parse_body: parse_body)
13
13
  end
14
14
  if hash["data"].is_a?(Hash) && !hash["data"]["Body"].nil?
15
- hash["data"]["Body"] = Base64.decode64(hash["data"]["Body"].to_s)
15
+ hash["data"]["Body"] = parsing_body(hash["data"]["Body"],
16
+ parse_body: parse_body)
16
17
  end
17
18
  hash
18
19
  end
20
+
21
+ private
22
+
23
+ def self.parsing_body(body, parse_body: true)
24
+ decoded = Base64.decode64(body.to_s)
25
+ return decoded unless parse_body
26
+ begin
27
+ return Oj.load(decoded, mode: :json, symbol_keys: false)
28
+ rescue
29
+ return decoded
30
+ end
31
+ end
19
32
  end
20
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbkubemq
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefano Martin
@@ -108,7 +108,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
108
  - !ruby/object:Gem::Version
109
109
  version: '0'
110
110
  requirements: []
111
- rubygems_version: 3.0.1
111
+ rubyforge_project:
112
+ rubygems_version: 2.7.7
112
113
  signing_key:
113
114
  specification_version: 4
114
115
  summary: A simple gem for KubeMQ