paper_trail-binary_serializer 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3389db267c9c91eb5fbef18772e7f29ff98faa4e3deeb2c4ee338f419a1d1374
4
+ data.tar.gz: f1f1c50c5610eca3aa41cef66a913c10e7742cc2e302fef063ebc31c6830e988
5
+ SHA512:
6
+ metadata.gz: ddbd6f694e0025424f004873a2f73e8c945251ae7e2fd688f4b8c4567d8d7e4cd6379d7fdab292ab01b6171682a30f72b163cb5624db24ce684971d575a5cf66
7
+ data.tar.gz: 7665c96ee7de79a131fa99e1131aa0ee8cfe58d32ffdbd2eb9cdd7895e815eb19e9d110deeadd7616e0344bc29b8d39bc1ed038d8de98c4ded36e7c6ed239886
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2016 ankit1910
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,4 @@
1
+ # PaperTrailBinarySerializer
2
+
3
+ This gem is an extension to paper_trail gem https://github.com/paper-trail-gem/paper_trail. That means you need to install `paper_trail` gem. This gem will add one serializer used on columns with type `:binary`, encoding the content with base64 to prevent errors when generating JSON.
4
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,15 @@
1
+ require 'paper_trail/attribute_serializers/attribute_serializer_factory'
2
+ require 'paper_trail_binary_serializer/base64'
3
+ require 'paper_trail_binary_serializer/version'
4
+
5
+ PaperTrail::AttributeSerializers::AttributeSerializerFactory.module_eval do
6
+ orig_for = method(:for)
7
+ define_singleton_method :for do |klass, attr|
8
+ serializer = orig_for.call(klass, attr)
9
+ if serializer.is_a?(ActiveModel::Type::Binary)
10
+ PaperTrailBinarySerializer::Base64.new(**serializer.instance_values.symbolize_keys)
11
+ else
12
+ serializer
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,10 @@
1
+ module PaperTrailBinarySerializer
2
+ class Base64 < ActiveModel::Type::Binary
3
+ def serialize(val)
4
+ ::Base64.encode64(val) if val
5
+ end
6
+ def deserialize(val)
7
+ ::Base64.decode64(val) if val
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,3 @@
1
+ module PaperTrailBinarySerializer
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'paper_trail_binary_serializer/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "paper_trail-binary_serializer"
8
+ spec.version = PaperTrailBinarySerializer::VERSION
9
+ spec.authors = ["Sergio Cambra"]
10
+ spec.email = ["sergio@enpijama.es"]
11
+ spec.summary = "A PaperTrail serializer for binary columns using base64 encoding"
12
+ spec.description = "A PaperTrail serializer for binary columns using base64 encoding"
13
+ spec.homepage = "https://github.com/scambra/paper_trail-binary_serializer"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency 'paper_trail', '~> 15.0'
22
+
23
+ spec.add_development_dependency "bundler", "~> 2.0"
24
+ spec.add_development_dependency "rake"
25
+ end
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: paper_trail-binary_serializer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Sergio Cambra
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2025-04-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: paper_trail
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '15.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '15.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: A PaperTrail serializer for binary columns using base64 encoding
56
+ email:
57
+ - sergio@enpijama.es
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - LICENSE.txt
63
+ - README.md
64
+ - Rakefile
65
+ - lib/paper_trail-binary_serializer.rb
66
+ - lib/paper_trail_binary_serializer/base64.rb
67
+ - lib/paper_trail_binary_serializer/version.rb
68
+ - paper_trail-binary_serializer.gemspec
69
+ homepage: https://github.com/scambra/paper_trail-binary_serializer
70
+ licenses:
71
+ - MIT
72
+ metadata: {}
73
+ post_install_message:
74
+ rdoc_options: []
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ requirements: []
88
+ rubygems_version: 3.5.11
89
+ signing_key:
90
+ specification_version: 4
91
+ summary: A PaperTrail serializer for binary columns using base64 encoding
92
+ test_files: []