paquito 0.6.0 → 0.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7827d51263d503a0798dda51d14f0233f7a310e37f247b14a5ea13454403b3a5
4
- data.tar.gz: 63381b29bd17cbc2473036ef0f6ca8eee60f099e7d2f70202a6922ba6721313a
3
+ metadata.gz: ae7b47980ce61a6b1c3d650217d29a5c196df0c69470a36b74f643d0ded5334c
4
+ data.tar.gz: 06a85f164bcf5a0e472b4ebf41ce1a9680f71557663ed3176cb7e0df368e460b
5
5
  SHA512:
6
- metadata.gz: 75dba9ef5f38a56e765736b63549168e049d695615e6bc6bc545bb05deb7104b452094556cc3899d8fa0bf677ae7deef944f92f71c816af5f390a0e03c0f111b
7
- data.tar.gz: 56d37636f06418d32263a803b84fb1bf15cd4fe07b6b7fd7bf28252e162aabfdedc8cfb9d2ac5e2c03231cd0b4b2bb7cd3b879f43ced04b0af753923cbca5bff
6
+ metadata.gz: 7fcc3454d84b6cfac7ffe5f3b33780fc23aa609cad375db0e35b43a28582fc3b5dbb6913fc1b3e991b1f034418abe9dbd8c0d673f28e591fc8dee001eefd7c1c
7
+ data.tar.gz: 2baa0d2518993e2e140f5e989ede70a0d9aa19edb2361414bb6375a6161db0424fcbf7ab03f8f8e531ff0cef9160ea2fa0708afb345b6d3f2d2b3dcdeec332fa
@@ -9,7 +9,7 @@ jobs:
9
9
  fail-fast: false
10
10
  steps:
11
11
  - name: Checkout
12
- uses: actions/checkout@v2
12
+ uses: actions/checkout@v3
13
13
  - name: Set up Ruby
14
14
  uses: ruby/setup-ruby@v1
15
15
  with:
@@ -26,7 +26,7 @@ jobs:
26
26
  ruby: [ ruby-head, '3.0', '2.7', '2.6' ]
27
27
  steps:
28
28
  - name: Checkout
29
- uses: actions/checkout@v2
29
+ uses: actions/checkout@v3
30
30
  - name: Set up Ruby
31
31
  uses: ruby/setup-ruby@v1
32
32
  with:
data/CHANGELOG.md ADDED
@@ -0,0 +1,47 @@
1
+ # Unreleased
2
+
3
+ # 0.7.0
4
+
5
+ * Make ActiveRecordCoder now encode wether records were persisted or not (#12).
6
+ This change is backward compatible with Paquito 0.6.2 but NOT OLDER VERSIONS.
7
+
8
+ # 0.6.2
9
+
10
+ * Make ActiveRecordCoder able to read payloads that will be generated by Paquito 0.7.0 (#12).
11
+ DO NOT upgrade to Paquito 0.7.0+ without first fully rolling out Paquito 0.6.2.
12
+
13
+ # 0.6.1
14
+
15
+ * No data
16
+
17
+ # 0.6.0
18
+
19
+ * No data
20
+
21
+ # 0.5.0
22
+
23
+ * No data
24
+
25
+ # 0.4.0
26
+
27
+ * No data
28
+
29
+ # 0.3.1
30
+
31
+ * No data
32
+
33
+ # 0.3.0
34
+
35
+ * No data
36
+
37
+ # 0.2.1
38
+
39
+ * No data
40
+
41
+ # 0.2.0
42
+
43
+ * No data
44
+
45
+ # 0.1.0
46
+
47
+ * No data
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- paquito (0.6.0)
5
- msgpack (>= 1.5.1)
4
+ paquito (0.7.0)
5
+ msgpack (>= 1.5.2)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
@@ -25,7 +25,7 @@ GEM
25
25
  i18n (1.10.0)
26
26
  concurrent-ruby (~> 1.0)
27
27
  minitest (5.15.0)
28
- msgpack (1.5.1)
28
+ msgpack (1.5.4)
29
29
  parallel (1.21.0)
30
30
  parser (3.1.1.0)
31
31
  ast (~> 2.4.1)
@@ -73,4 +73,4 @@ DEPENDENCIES
73
73
  sqlite3
74
74
 
75
75
  BUNDLED WITH
76
- 2.3.11
76
+ 2.3.8
@@ -4,6 +4,8 @@ require "paquito/errors"
4
4
 
5
5
  module Paquito
6
6
  class ActiveRecordCoder
7
+ EMPTY_HASH = {}.freeze
8
+
7
9
  class << self
8
10
  def dump(record)
9
11
  instances = InstanceTracker.new
@@ -85,7 +87,9 @@ module Paquito
85
87
  end
86
88
 
87
89
  def serialize_record(record)
88
- [record.class.name, attributes_for_database(record)]
90
+ arguments = [record.class.name, attributes_for_database(record)]
91
+ arguments << true if record.new_record?
92
+ arguments
89
93
  end
90
94
 
91
95
  def attributes_for_database(record)
@@ -94,13 +98,17 @@ module Paquito
94
98
  attributes
95
99
  end
96
100
 
97
- def deserialize_record(class_name, attributes_from_database)
101
+ def deserialize_record(class_name, attributes_from_database, new_record = false)
98
102
  begin
99
103
  klass = Object.const_get(class_name)
100
104
  rescue NameError
101
105
  raise ClassMissingError, "undefined class: #{class_name}"
102
106
  end
103
- klass.instantiate(attributes_from_database)
107
+
108
+ # Ideally we'd like to call `klass.instantiate`, however it doesn't allow to pass
109
+ # wether the record was persisted or not.
110
+ attributes = klass.attributes_builder.build_from_database(attributes_from_database, EMPTY_HASH)
111
+ klass.allocate.init_with_attributes(attributes, new_record)
104
112
  end
105
113
  end
106
114
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Paquito
4
- VERSION = "0.6.0"
4
+ VERSION = "0.7.0"
5
5
  end
data/paquito.gemspec CHANGED
@@ -28,5 +28,5 @@ Gem::Specification.new do |spec|
28
28
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
29
29
  spec.require_paths = ["lib"]
30
30
 
31
- spec.add_dependency("msgpack", ">= 1.5.1")
31
+ spec.add_dependency("msgpack", ">= 1.5.2")
32
32
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paquito
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean Boussier
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-04-07 00:00:00.000000000 Z
11
+ date: 2022-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.5.1
19
+ version: 1.5.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 1.5.1
26
+ version: 1.5.2
27
27
  description: Framework for defining efficient and extendable serializers
28
28
  email:
29
29
  - jean.boussier@gmail.com
@@ -34,6 +34,7 @@ files:
34
34
  - ".github/workflows/ci.yml"
35
35
  - ".gitignore"
36
36
  - ".rubocop.yml"
37
+ - CHANGELOG.md
37
38
  - Gemfile
38
39
  - Gemfile.lock
39
40
  - LICENSE.txt
@@ -85,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
86
  - !ruby/object:Gem::Version
86
87
  version: '0'
87
88
  requirements: []
88
- rubygems_version: 3.2.20
89
+ rubygems_version: 3.3.3
89
90
  signing_key:
90
91
  specification_version: 4
91
92
  summary: Framework for defining efficient and extendable serializers