migrating_serializer 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/lib/migrating_serializer.rb +14 -0
- data/lib/migrating_serializer/flexible_loader.rb +21 -0
- data/lib/migrating_serializer/version.rb +4 -0
- metadata +48 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4bac6dc0e1c270e286e80974ad741912b19883de
|
4
|
+
data.tar.gz: 96996055a42fcb77dd084f3cf10fdfa6bf8db2a6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 22333b591877ea29b7f1c03eacacfd4bb5a9e7a2a59a634356720fa51d97441e2ba4d3944a7e7e8e563e70707f0b544e63a20e2788f780f35aab37beba0da686
|
7
|
+
data.tar.gz: 2651d9f2040fcdce276c861c9a45e145e0e2f2f5a229489a443699a554e6b148b3918022fa205c9d0fdfa9f8cffa06ffd4731ae65adbc56cafd3c4a328f80da0
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (C) 2013 Craig Day <craigday3@gmail.com>
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'migrating_serializer/flexible_loader'
|
3
|
+
|
4
|
+
# An ActiveRecord compatible serializer module. This will support deserializing
|
5
|
+
# data that is either YAML or JSON. It will always reserialize the data as JSON.
|
6
|
+
module MigratingSerializer
|
7
|
+
def self.load(data)
|
8
|
+
FlexibleLoader.load(data)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.dump(data)
|
12
|
+
JSON.dump(data)
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# rubocop:disable Security/YAMLLoad, Security/JSONLoad
|
3
|
+
require 'yaml'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
module MigratingSerializer
|
7
|
+
# This module provides our flexible load method. It will check the data to see
|
8
|
+
# if it is YAML and then call `YAML.load` on it. If the data does not appear
|
9
|
+
# to be YAML then it will assume JSON and load it.
|
10
|
+
module FlexibleLoader
|
11
|
+
def self.load(data)
|
12
|
+
if data.start_with?('---')
|
13
|
+
# we know its YAML
|
14
|
+
YAML.load(data)
|
15
|
+
else
|
16
|
+
# we should be able to read as JSON
|
17
|
+
JSON.load(data)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: migrating_serializer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Craig Day
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-03-24 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email: craigday3@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- MIT-LICENSE
|
20
|
+
- lib/migrating_serializer.rb
|
21
|
+
- lib/migrating_serializer/flexible_loader.rb
|
22
|
+
- lib/migrating_serializer/version.rb
|
23
|
+
homepage: https://github.com/craig-day/migrating_serializer
|
24
|
+
licenses:
|
25
|
+
- MIT
|
26
|
+
metadata: {}
|
27
|
+
post_install_message:
|
28
|
+
rdoc_options: []
|
29
|
+
require_paths:
|
30
|
+
- lib
|
31
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: 2.1.0
|
36
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
requirements: []
|
42
|
+
rubyforge_project:
|
43
|
+
rubygems_version: 2.5.1
|
44
|
+
signing_key:
|
45
|
+
specification_version: 4
|
46
|
+
summary: Convert YAML serialized columns to JSON by providing support for deserializing
|
47
|
+
both JSON and YAML
|
48
|
+
test_files: []
|