pbbuilder 0.19.0 → 0.20.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: 1ea3598ad1ed31172d0b3154c6968649f63073f23de0d94abf191a07dbdbf4e0
4
- data.tar.gz: 7285883ae069eeff4f1860eb9b4c4a727585e6762b3bfd974ce1fb9e51928086
3
+ metadata.gz: 9f241a460f2ab7e8383c37db199821f8cb5e8d2f69c262f38c7c462a4d7827e0
4
+ data.tar.gz: 3e8c43a8d0c0362049a9cb8a709c86eac64d86e12366812f2b996b1e81d73c23
5
5
  SHA512:
6
- metadata.gz: e051d79882379fb30f3f0b4bab503e6591034d1cc16639918d685a0ef19e6f7cc42ea224954bf755db739f6a2b2c2c86a8c7666e23065ce337aafb862486b4f6
7
- data.tar.gz: 90f2266161a9a101fd4b67afb71130a009b17ec9a5139dc583db18d02a1a32a2bd7730f1ea872c3d4b77a4d64f953b1a34e72cb35f845dc6a879f117f7c3c5ec
6
+ metadata.gz: '03691d015507cb98d862c4f1c352a08c20e0968f0fae3a23795bec6e6ffdbef6b3e54dca9057364c32e353bfc561e8f117cf02219ad2c73725ae004b7fd1590b'
7
+ data.tar.gz: b52b5324090887effbaba0ae6ff79ebe9cc7c08ffae945037883d42375bca4ec53bd5a37dc4a9d144c488a6ba5e7ffce88d05f3e9f7ba1a260af5f0ed55107ed
@@ -13,15 +13,12 @@ jobs:
13
13
  strategy:
14
14
  fail-fast: false
15
15
  matrix:
16
- ruby: ["3.0", "3.1", "3.2", "3.3"]
17
- gemfile: [ "rails_6_1", "rails_7_0", "rails_7_2"]
18
- exclude:
19
- - ruby: "3.0"
20
- gemfile: "rails_7_2"
16
+ ruby: ["3.2.2"]
17
+ gemfile: ["rails_7_2", "rails_8_0"]
21
18
  experimental: [false]
22
19
 
23
20
  steps:
24
- - uses: actions/checkout@v3
21
+ - uses: actions/checkout@v4
25
22
 
26
23
  - uses: ruby/setup-ruby@v1
27
24
  with:
data/.gitignore CHANGED
@@ -18,5 +18,5 @@ gemfiles/*.lock
18
18
  Gemfile.lock
19
19
  .ruby-version
20
20
  pkg
21
-
21
+ .vscode/
22
22
 
data/Appraisals CHANGED
@@ -1,11 +1,9 @@
1
- appraise "rails-6-1" do
2
- gem "rails", "~> 6.1.0"
3
- end
4
-
5
- appraise "rails-7-0" do
6
- gem "rails", "~> 7.0.0"
7
- end
8
-
9
1
  appraise "rails-7-2" do
10
2
  gem "rails", "~> 7.2.0"
3
+ gem "google-protobuf", "~> 3.25", "< 4.0"
11
4
  end
5
+
6
+ appraise "rails-8-0" do
7
+ gem "rails", "~> 8.0.2"
8
+ gem "google-protobuf", "~> 4.0", "< 5.0"
9
+ end
data/CHANGELOG.md CHANGED
@@ -1,69 +1,55 @@
1
- # Pbbuilder Changelog
2
- All notable changes to this project will be documented in this file.
1
+ ## Unreleased
3
2
 
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).
3
+ - Remove official support for Rails 7.0 and Rails 6.x, add Appraisal config for Rails 8.x
4
+ - Bump actions/checkout from 3 to 4 (#40)
5
+ - Drop support for rails v6.* versions (#60)
6
+ - Regenerate Appraisals, drop Rails 7.0
7
+ - Allow usage of google-protobuf 4.x
8
+ - Use an actual .proto for testing
9
+ - Test with both google-protobuf 3.25 and 4.x
10
+ - Remove --verbose when running rake test
5
11
 
6
12
  ## 0.19.0
7
- ### Added
8
- - Add support for rails 7.2, but leave out rails 7.1 support. This is because ActionView has a breaking bug in 7.1 that renders the template back as a string
9
- instead of an object, like we need for Pbbuilder https://github.com/rails/rails/pull/51023
13
+ - Add support for rails 7.2, but leave out rails 7.1 support. This is because ActionView has a breaking bug in 7.1 that renders the template back as a string instead of an object, like we need for Pbbuilder https://github.com/rails/rails/pull/51023 This also removes the uses of the Rails variant of BasicObject in favor of the Ruby built-in.
10
14
 
11
15
  ## 0.18.0
12
- ### Added
13
16
  - Allow literal assignment of protos to fields
14
17
 
15
18
  ## 0.17.0
16
- ### Changed
17
19
  - Instead of appending to repeated enum message, we're replacing it to avoid issues in case output will be rendered twice
18
20
  - If one field was defined twice, only last definition will end up in output
19
-
20
- ## Fixed
21
21
  - Fixed CI by locking 3 version or lower of google-protobuf dependency.
22
22
 
23
23
  ## 0.16.2
24
- ### Added
25
24
  - Add support for partial as a first argument , e.g.`pb.friends "racers/racer", as: :racer, collection: @racers`
26
25
  - Add tests to verify that fragment caching is operational
27
26
 
28
27
  ## 0.16.1
29
- ### Changed
30
28
  - Deal properly with recursive protobuf messages while using ActiveView::CollectionRenderer
31
29
 
32
30
  ## 0.16.0
33
- ### Added
34
31
  - Added support for new collection rendering, that is backed by ActiveView::CollectionRenderer.
35
-
36
- ### Changed
37
32
  - Refactoring and simplification of #merge! method without a change in functionality.
38
33
 
39
34
  ## 0.15.1
40
- ### Fixed
41
35
  - #merge! method to handle repeated unintialized message object
42
36
 
43
37
  ## 0.15.0
44
- ### Changed
45
38
  - #merge! method was refactored to accomodate caching for all data types (especially those that are :repeated)
46
39
 
47
40
  ## 0.14.0
48
- ### Added
49
41
  - Adding `frozen_string_literal: true` to all files.
50
42
 
51
- ## 0.13.2 2023.02.3
52
- ### Fixed
43
+ ## 0.13.2
53
44
  - In case ActiveSupport::Cache::FileStore in Rails is used as a cache, File.atomic_write can have a race condition and fail to rename temporary file. We're attempting to recover from that, by catching this specific error and returning a value.
54
45
 
55
- ## 0.13.1 2023.01.24
56
- ### Added
46
+ ## 0.13.1
57
47
  - #merge! to support boolean values
58
48
 
59
- ## 0.13.0 2023.01.18
60
- ### Added
49
+ ## 0.13.0
61
50
  - #merge! method added for PbbuilderTemplate class
62
51
  - ActiveSupport added as a dependency for gem
63
52
  - Fragment Caching support added, with #cache! and #cache_if! methods in PbbuilderTemplate class.
64
-
65
-
66
- ### Changed
67
53
  - Appraisal is properly configured to run against all rubies and rails combinations.
68
54
  - Supported ruby version's are 2.7, 3.0, 3.1
69
55
  - Superclass for pbbuilder is now active_support/proxy_object, with a fallback to active_support/basic_object.
@@ -71,10 +57,7 @@ instead of an object, like we need for Pbbuilder https://github.com/rails/rails/
71
57
  - `rails` from version 6.1.4.4 to 6.1.7, and from version 7.0.1 to 7.0.4
72
58
  - `google-protobuf` is let loose
73
59
  - `bundler` from version 2.3.4 to 2.3.22
74
-
75
- ### Removed
76
- - TestUnit dependency
77
-
60
+ - TestUnit dependency removed
78
61
 
79
62
  ## 0.12.0 Prior to 2022-10-14
80
63
 
data/README.md CHANGED
@@ -1,11 +1,14 @@
1
1
  # Pbbuilder
2
2
  PBBuilder generates [Protobuf](https://developers.google.com/protocol-buffers) Messages with a simple DSL similar to the [JBuilder](https://rubygems.org/gems/jbuilder) gem.
3
3
 
4
+ ## Requirements
5
+ This gem only supports Rails 7.0 and Rails 7.2, **7.1 is not supported**.
4
6
 
5
- At least Rails 6.1 is required and rails 7.1 is currently not supported.
6
7
  There currently is a regression in ActionView (the part of Rails which renders) that forces rendered objects into strings, but for Pbbuilder we need the raw objects.
7
8
  This is only present in Rails 7.1, and a fix is released in Rails 7.2. https://github.com/rails/rails/pull/51023
8
9
 
10
+ It might work on rails v6 (it worked previously), but we don't guarantee that and don't test against these versions anymore.
11
+
9
12
  ## Compatibility with jBuilder
10
13
  We don't aim to have 100% compitability and coverage with jbuilder gem, but we closely follow jbuilder's API design to maintain familiarity.
11
14
 
@@ -154,14 +157,26 @@ Seen in:
154
157
  [Errors](lib/pbbuilder/errors.rb)
155
158
 
156
159
  ## Testing
157
- Running `bundle exec appraisal rake test` locally will run the entire testsuit with all versions of rails.
158
- To run tests only for a certain rails version do the following `bundle exec appraisal rails-7-0 rake test`
159
160
 
160
- To run only one tests from file - use `m` utility. Like this:
161
- `bundle exec appraisal rails-7-0 m test/pbbuilder_template_test.rb:182`
161
+ `pbbuilder` is set up with Appraisal so that we can test a couple Rails and google-protobuf versions against our changes. To run the tests for all setups:
162
+
163
+ ```bash
164
+ $ bundle exec appraisal install
165
+ $ bundle exec appraisal rake test
166
+
167
+ To run tests only for a certain pre-set Gemfile (check the `Appraisals` file to see what's defined):
168
+
169
+ ```bash
170
+ $ bundle exec appraisal rails-7-2 rake test`
171
+ ```
172
+
173
+ To run only one test use `m` utility. Like this:
174
+ `bundle exec appraisal rails-7-2 m test/pbbuilder_template_test.rb:182`
162
175
 
163
176
  ## Contributing
177
+
164
178
  Everyone is welcome to contribute.
165
179
 
166
180
  ## License
181
+
167
182
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile CHANGED
@@ -21,7 +21,7 @@ else
21
21
  file_name = ARGV[1]
22
22
  test_name = ARGV[2]&.tr(" ", "_")
23
23
 
24
- ENV["TESTOPTS"] = "--verbose"
24
+ ENV["TESTOPTS"] = ""
25
25
 
26
26
  t.test_files = if file_name
27
27
  if test_name
@@ -5,5 +5,6 @@ source "https://rubygems.org"
5
5
  gem "rake"
6
6
  gem "appraisal"
7
7
  gem "rails", "~> 7.2.0"
8
+ gem "google-protobuf", "~> 3.25", "< 4.0"
8
9
 
9
10
  gemspec path: "../"
@@ -4,6 +4,7 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "rake"
6
6
  gem "appraisal"
7
- gem "rails", "~> 6.0"
7
+ gem "rails", "~> 8.0.2"
8
+ gem "google-protobuf", "~> 4.0", "< 5.0"
8
9
 
9
10
  gemspec path: "../"
data/pbbuilder.gemspec CHANGED
@@ -2,20 +2,21 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "pbbuilder"
5
- spec.version = "0.19.0"
6
- spec.authors = ["Bouke van der Bijl"]
7
- spec.email = ["bouke@cheddar.me"]
5
+ spec.version = "0.20.0"
6
+ spec.authors = ["Bouke van der Bijl", "Julik Tarkhanov", "Stas Katkov", "Sebastian van Hesteren"]
7
+ spec.email = ["julik@cheddar.me"]
8
8
  spec.homepage = "https://github.com/cheddar-me/pbbuilder"
9
- spec.summary = "Generate Protobuf Messages with a simple DSL similar to JBuilder"
9
+ spec.summary = "Generate Protobuf messages with a simple DSL similar to JBuilder"
10
10
  spec.license = "MIT"
11
11
 
12
- spec.required_ruby_version = '>= 2.7'
12
+ spec.required_ruby_version = '>= 3.2'
13
13
 
14
14
  spec.files = `git ls-files`.split("\n")
15
15
  spec.test_files = `git ls-files -- test/*`.split("\n")
16
16
 
17
- spec.add_dependency "google-protobuf", "~> 3.25"
17
+ spec.add_dependency "google-protobuf", ">= 3.25", "< 5.0"
18
18
  spec.add_dependency "activesupport"
19
- spec.add_development_dependency 'm'
19
+ spec.add_development_dependency "m"
20
20
  spec.add_development_dependency "pry"
21
+ spec.add_development_dependency "rake"
21
22
  end
data/test/test_helper.rb CHANGED
@@ -21,28 +21,14 @@ require "pry"
21
21
 
22
22
  ActiveSupport.test_order = :random
23
23
 
24
- Google::Protobuf::DescriptorPool.generated_pool.build do
25
- add_file("pbbuilder.proto", syntax: :proto3) do
26
- add_message "pbbuildertest.Person" do
27
- optional :name, :string, 1
28
- repeated :friends, :message, 2, "pbbuildertest.Person"
29
- optional :best_friend, :message, 3, "pbbuildertest.Person"
30
- repeated :nicknames, :string, 4
31
- optional :field_mask, :message, 5, "google.protobuf.FieldMask"
32
- map :favourite_foods, :string, :string, 6
33
- repeated :tags, :string, 7
34
- optional :last_name, :string, 8
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
43
- end
44
- end
24
+ # Regenerate Ruby descriptors from proto if needed, and require them.
25
+ # This does require protoc to be installed
26
+ proto_file = File.expand_path("test_proto.proto", __dir__)
27
+ ruby_out = File.expand_path("test_proto_pb.rb", __dir__)
28
+ if !File.exist?(ruby_out) || File.mtime(ruby_out) < File.mtime(proto_file)
29
+ system("protoc --proto_path=#{File.dirname(proto_file)} --ruby_out=#{File.dirname(ruby_out)} #{proto_file}")
45
30
  end
31
+ require_relative "test_proto_pb"
46
32
 
47
33
  module API
48
34
  Person = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("pbbuildertest.Person").msgclass
@@ -0,0 +1,27 @@
1
+ // This is the source proto file from which Ruby proto descriptors are generated.
2
+ // See test/test_helper.rb for the generation process.
3
+
4
+ syntax = "proto3";
5
+
6
+ package pbbuildertest;
7
+
8
+ import "google/protobuf/field_mask.proto";
9
+
10
+ message Person {
11
+ string name = 1;
12
+ repeated Person friends = 2;
13
+ Person best_friend = 3;
14
+ repeated string nicknames = 4;
15
+ google.protobuf.FieldMask field_mask = 5;
16
+ map<string, string> favourite_foods = 6;
17
+ repeated string tags = 7;
18
+ string last_name = 8;
19
+ bool boolean_me = 9;
20
+ Asset logo = 10;
21
+ }
22
+
23
+ message Asset {
24
+ string url = 1;
25
+ string url_2x = 2;
26
+ string url_3x = 3;
27
+ }
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
3
+ # source: test_proto.proto
4
+
5
+ require 'google/protobuf'
6
+
7
+ require 'google/protobuf/field_mask_pb'
8
+
9
+
10
+ descriptor_data = "\n\x10test_proto.proto\x12\rpbbuildertest\x1a google/protobuf/field_mask.proto\"\x81\x03\n\x06Person\x12\x0c\n\x04name\x18\x01 \x01(\t\x12&\n\x07\x66riends\x18\x02 \x03(\x0b\x32\x15.pbbuildertest.Person\x12*\n\x0b\x62\x65st_friend\x18\x03 \x01(\x0b\x32\x15.pbbuildertest.Person\x12\x11\n\tnicknames\x18\x04 \x03(\t\x12.\n\nfield_mask\x18\x05 \x01(\x0b\x32\x1a.google.protobuf.FieldMask\x12\x42\n\x0f\x66\x61vourite_foods\x18\x06 \x03(\x0b\x32).pbbuildertest.Person.FavouriteFoodsEntry\x12\x0c\n\x04tags\x18\x07 \x03(\t\x12\x11\n\tlast_name\x18\x08 \x01(\t\x12\x12\n\nboolean_me\x18\t \x01(\x08\x12\"\n\x04logo\x18\n \x01(\x0b\x32\x14.pbbuildertest.Asset\x1a\x35\n\x13\x46\x61vouriteFoodsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"4\n\x05\x41sset\x12\x0b\n\x03url\x18\x01 \x01(\t\x12\x0e\n\x06url_2x\x18\x02 \x01(\t\x12\x0e\n\x06url_3x\x18\x03 \x01(\tb\x06proto3"
11
+
12
+ pool = Google::Protobuf::DescriptorPool.generated_pool
13
+ pool.add_serialized_file(descriptor_data)
14
+
15
+ module Pbbuildertest
16
+ Person = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("pbbuildertest.Person").msgclass
17
+ Asset = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("pbbuildertest.Asset").msgclass
18
+ end
metadata CHANGED
@@ -1,29 +1,38 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pbbuilder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.19.0
4
+ version: 0.20.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bouke van der Bijl
8
+ - Julik Tarkhanov
9
+ - Stas Katkov
10
+ - Sebastian van Hesteren
8
11
  autorequire:
9
12
  bindir: bin
10
13
  cert_chain: []
11
- date: 2024-09-12 00:00:00.000000000 Z
14
+ date: 2025-06-19 00:00:00.000000000 Z
12
15
  dependencies:
13
16
  - !ruby/object:Gem::Dependency
14
17
  name: google-protobuf
15
18
  requirement: !ruby/object:Gem::Requirement
16
19
  requirements:
17
- - - "~>"
20
+ - - ">="
18
21
  - !ruby/object:Gem::Version
19
22
  version: '3.25'
23
+ - - "<"
24
+ - !ruby/object:Gem::Version
25
+ version: '5.0'
20
26
  type: :runtime
21
27
  prerelease: false
22
28
  version_requirements: !ruby/object:Gem::Requirement
23
29
  requirements:
24
- - - "~>"
30
+ - - ">="
25
31
  - !ruby/object:Gem::Version
26
32
  version: '3.25'
33
+ - - "<"
34
+ - !ruby/object:Gem::Version
35
+ version: '5.0'
27
36
  - !ruby/object:Gem::Dependency
28
37
  name: activesupport
29
38
  requirement: !ruby/object:Gem::Requirement
@@ -66,9 +75,23 @@ dependencies:
66
75
  - - ">="
67
76
  - !ruby/object:Gem::Version
68
77
  version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rake
80
+ requirement: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ type: :development
86
+ prerelease: false
87
+ version_requirements: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
69
92
  description:
70
93
  email:
71
- - bouke@cheddar.me
94
+ - julik@cheddar.me
72
95
  executables: []
73
96
  extensions: []
74
97
  extra_rdoc_files: []
@@ -85,12 +108,8 @@ files:
85
108
  - bin/appraisal
86
109
  - bin/test
87
110
  - gemfiles/.bundle/config
88
- - gemfiles/rails_6.gemfile
89
- - gemfiles/rails_6_1.gemfile
90
- - gemfiles/rails_7.gemfile
91
- - gemfiles/rails_7_0.gemfile
92
111
  - gemfiles/rails_7_2.gemfile
93
- - gemfiles/rails_head.gemfile
112
+ - gemfiles/rails_8_0.gemfile
94
113
  - lib/pbbuilder.rb
95
114
  - lib/pbbuilder/collection_renderer.rb
96
115
  - lib/pbbuilder/errors.rb
@@ -103,6 +122,8 @@ files:
103
122
  - test/pbbuilder_test.rb
104
123
  - test/protobuf_extension_test.rb
105
124
  - test/test_helper.rb
125
+ - test/test_proto.proto
126
+ - test/test_proto_pb.rb
106
127
  homepage: https://github.com/cheddar-me/pbbuilder
107
128
  licenses:
108
129
  - MIT
@@ -115,19 +136,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
115
136
  requirements:
116
137
  - - ">="
117
138
  - !ruby/object:Gem::Version
118
- version: '2.7'
139
+ version: '3.2'
119
140
  required_rubygems_version: !ruby/object:Gem::Requirement
120
141
  requirements:
121
142
  - - ">="
122
143
  - !ruby/object:Gem::Version
123
144
  version: '0'
124
145
  requirements: []
125
- rubygems_version: 3.5.18
146
+ rubygems_version: 3.5.9
126
147
  signing_key:
127
148
  specification_version: 4
128
- summary: Generate Protobuf Messages with a simple DSL similar to JBuilder
149
+ summary: Generate Protobuf messages with a simple DSL similar to JBuilder
129
150
  test_files:
130
151
  - test/pbbuilder_template_test.rb
131
152
  - test/pbbuilder_test.rb
132
153
  - test/protobuf_extension_test.rb
133
154
  - test/test_helper.rb
155
+ - test/test_proto.proto
156
+ - test/test_proto_pb.rb
@@ -1,9 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rake"
6
- gem "appraisal"
7
- gem "rails", "~> 6.1.0"
8
-
9
- gemspec path: "../"
@@ -1,9 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rake"
6
- gem "appraisal"
7
- gem "rails", "~> 7.0"
8
-
9
- gemspec path: "../"
@@ -1,9 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rake"
6
- gem "appraisal"
7
- gem "rails", "~> 7.0.0"
8
-
9
- gemspec path: "../"
@@ -1,9 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rake"
6
- gem "appraisal"
7
- gem "rails", github: "rails/rails", branch: "main"
8
-
9
- gemspec path: "../"