pbbuilder 0.15.0 → 0.15.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/pbbuilder.rb +5 -0
- data/pbbuilder.gemspec +1 -1
- data/test/pbbuilder_template_test.rb +32 -0
- data/test/test_helper.rb +7 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc165db83a23b9c5bf32a6921b3cd959171083d48f7a6887df8c524f9920d574
|
4
|
+
data.tar.gz: 7d3631f19dea340592918300b66e6d024889fe2c18776c729d4bebdb9424ad4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad453cd1f12f8a71f05b98c5d60e34837848f1c4bdbe403d41a407762b980d5f47c6dc16925b01f2927fef427cb82b5a4b23801102fa7a46d280adf1245afe2f
|
7
|
+
data.tar.gz: 1b0bb8019d473e1a433e3009ece6976d7a42992e00d207290106fef8a7de3fd16de5c49caaf6dc23a39aab5cdd6369caae06f62b34def0f431e6c16361210e03
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file.
|
|
3
3
|
|
4
4
|
This format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
5
5
|
|
6
|
+
## 0.15.1
|
7
|
+
### Fixed
|
8
|
+
- #merge! method to handle repeated unintialized message object
|
9
|
+
|
6
10
|
## 0.15.0
|
7
11
|
### Changed
|
8
12
|
- #merge! method was refactored to accomodate caching for all data types (especially those that are :repeated)
|
data/lib/pbbuilder.rb
CHANGED
@@ -157,6 +157,11 @@ class Pbbuilder
|
|
157
157
|
|
158
158
|
object[key].each do |k, v|
|
159
159
|
if object[key][k].respond_to?(:to_hash)
|
160
|
+
if @message[key.to_s][k.to_s].nil?
|
161
|
+
descriptor = @message[key.to_s].class.descriptor.lookup(k.to_s)
|
162
|
+
@message[key.to_s][k.to_s] = _new_message_from_descriptor(descriptor)
|
163
|
+
end
|
164
|
+
|
160
165
|
_scope(@message[key.to_s][k.to_s]) { self.merge!(object[key][k]) }
|
161
166
|
elsif object[key][k].respond_to?(:to_ary)
|
162
167
|
@message[key.to_s][k.to_s].replace object[key][k]
|
data/pbbuilder.gemspec
CHANGED
@@ -116,6 +116,38 @@ class PbbuilderTemplateTest < ActiveSupport::TestCase
|
|
116
116
|
}
|
117
117
|
end
|
118
118
|
|
119
|
+
test "caching a message object" do
|
120
|
+
template = <<-PBBUILDER
|
121
|
+
pb.cache! "some-random-key-again" do
|
122
|
+
pb.best_friend do
|
123
|
+
pb.name "Max Verstappen"
|
124
|
+
pb.logo do
|
125
|
+
pb.url('https://google.com/image.jpg')
|
126
|
+
pb.url_2x('https://google.com/image.jpg')
|
127
|
+
pb.url_3x('https://google.com/image.jpg')
|
128
|
+
end
|
129
|
+
end
|
130
|
+
pb.logo do
|
131
|
+
pb.url('https://google.com/image.jpg')
|
132
|
+
pb.url_2x('https://google.com/image.jpg')
|
133
|
+
pb.url_3x('https://google.com/image.jpg')
|
134
|
+
end
|
135
|
+
end
|
136
|
+
PBBUILDER
|
137
|
+
|
138
|
+
assert_nothing_raised { render(template) }
|
139
|
+
|
140
|
+
result = render('pb.cache! "some-random-key-again" do; end ')
|
141
|
+
|
142
|
+
assert_equal('https://google.com/image.jpg', result.logo.url)
|
143
|
+
assert_equal('https://google.com/image.jpg', result.logo.url_2x)
|
144
|
+
assert_equal('https://google.com/image.jpg', result.logo.url_3x)
|
145
|
+
|
146
|
+
assert_equal('https://google.com/image.jpg', result.best_friend.logo.url)
|
147
|
+
assert_equal('https://google.com/image.jpg', result.best_friend.logo.url_2x)
|
148
|
+
assert_equal('https://google.com/image.jpg', result.best_friend.logo.url_3x)
|
149
|
+
end
|
150
|
+
|
119
151
|
test "empty fragment caching" do
|
120
152
|
render 'pb.cache! "nothing" do; end'
|
121
153
|
|
data/test/test_helper.rb
CHANGED
@@ -33,6 +33,13 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
|
|
33
33
|
repeated :tags, :string, 7
|
34
34
|
optional :last_name, :string, 8
|
35
35
|
optional :boolean_me, :bool, 9
|
36
|
+
optional :logo, :message, 10, "pbbuildertest.Asset"
|
37
|
+
end
|
38
|
+
|
39
|
+
add_message "pbbuildertest.Asset" do
|
40
|
+
optional :url, :string, 1
|
41
|
+
optional :url_2x, :string, 2
|
42
|
+
optional :url_3x, :string, 3
|
36
43
|
end
|
37
44
|
end
|
38
45
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pbbuilder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.15.
|
4
|
+
version: 0.15.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bouke van der Bijl
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google-protobuf
|