pbbuilder 0.15.0 → 0.15.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e89f023f27d95d8d11cdf454148ef955b0234b6d7e59f40e30859e09c02761cb
4
- data.tar.gz: 108693d16d963bc46ad96d3f79ed4b8078f8efc9c3a7f798c32b7bdd5cc98e73
3
+ metadata.gz: dc165db83a23b9c5bf32a6921b3cd959171083d48f7a6887df8c524f9920d574
4
+ data.tar.gz: 7d3631f19dea340592918300b66e6d024889fe2c18776c729d4bebdb9424ad4b
5
5
  SHA512:
6
- metadata.gz: aa478fc7fad5954801385b731b7fc77296d732e8f13a6bc5688417dfdeb247a7135f3ecbce14f88abc441a87cbc6ad669d3f5547b917f80bfddfbac7e0b2c9a8
7
- data.tar.gz: 2fe79ab3cfde6b908907d55eaf37054cb0b530f4e98dbf44d732bef82c46054f0efd4c6ba3a05827915cc855f9cc70a671adc2316c691edd5147ababec573ec6
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "pbbuilder"
5
- spec.version = "0.15.0"
5
+ spec.version = "0.15.1"
6
6
  spec.authors = ["Bouke van der Bijl"]
7
7
  spec.email = ["bouke@cheddar.me"]
8
8
  spec.homepage = "https://github.com/cheddar-me/pbbuilder"
@@ -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.0
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-05-23 00:00:00.000000000 Z
11
+ date: 2023-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-protobuf