midnight-utilities 0.0.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 59875a82d7fa3e2f52a881b15ea797d3835818f42f57712d6d3324efee0d56ff
4
+ data.tar.gz: f2e31c4a233429fa6e9d2f729fb47895b47eca4438a3ff42bc9732ec4c92bffa
5
+ SHA512:
6
+ metadata.gz: '00105286211a13d5e55d5550a38ca3069d4940242ed69b76d1514f2c100809496e062ec9e1d5256c55ccd63dcfc0fe20dc8b51367afc779c2f89b4347dc45f43'
7
+ data.tar.gz: aa7f4f7f6212f096f6fa014df9d6b1731860e59dd80133ca8b547e8df4786e2ee3645ad06d058eb4a78405c03c909b208316e8af0d138fa008d7e00eb0331755
@@ -0,0 +1,9 @@
1
+ require_relative 'utilities/version'
2
+ require 'active_support/dependencies/autoload'
3
+
4
+ module Midnight
5
+ module Utilities
6
+ extend ::ActiveSupport::Autoload
7
+ autoload :JsonSerializer
8
+ end
9
+ end
@@ -0,0 +1,22 @@
1
+ require 'active_support/core_ext/hash'
2
+ require 'json'
3
+
4
+ module Midnight
5
+ module Utilities
6
+ module JsonSerializer
7
+ module_function def dump(hash)
8
+ hash = hash.try(:to_hash) || hash
9
+ ::JSON.dump(hash)
10
+ rescue ::TypeError
11
+ hash
12
+ end
13
+
14
+ module_function def load(string)
15
+ hash = ::JSON.load(string)
16
+ hash.try(:to_hash).try(:deep_symbolize_keys) || hash
17
+ rescue ::TypeError
18
+ string
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,5 @@
1
+ module Midnight
2
+ module Utilities
3
+ VERSION = '0.0.1'
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: midnight-utilities
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Sarun Rattanasiri
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-08-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: A collection of potentially reusable elements extracted from midnight-rails
28
+ gem.
29
+ email: midnight_w@gmx.tw
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - lib/midnight/utilities.rb
35
+ - lib/midnight/utilities/json_serializer.rb
36
+ - lib/midnight/utilities/version.rb
37
+ homepage: https://gitlab.com/slime-systems/midnight-enterprise-toolkit/tree/master/midnight-utilities
38
+ licenses: []
39
+ metadata: {}
40
+ post_install_message:
41
+ rdoc_options: []
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ requirements: []
55
+ rubygems_version: 3.0.3
56
+ signing_key:
57
+ specification_version: 4
58
+ summary: A reusable utilities pool supporting Midnight::Rails
59
+ test_files: []