Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,8 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: ["3.0", "3.1", "3.2", "3.3"]
gemfile: ["rails_7_0", "rails_7_2"]
exclude:
- ruby: "3.0"
gemfile: "rails_7_2"
ruby: ["3.2.2"]
gemfile: ["rails_7_2", "rails_8_0"]
experimental: [false]

steps:
Expand Down
10 changes: 6 additions & 4 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
appraise "rails-7-0" do
gem "rails", "~> 7.0.0"
end

appraise "rails-7-2" do
gem "rails", "~> 7.2.0"
gem "google-protobuf", "~> 3.25", "< 4.0"
end

appraise "rails-8-0" do
gem "rails", "~> 8.0.2"
gem "google-protobuf", "~> 4.0", "< 5.0"
end
48 changes: 14 additions & 34 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,83 +1,63 @@
# Pbbuilder Changelog
All notable changes to this project will be documented in this file.

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).

## Unreleased
- Remove official support for Rails 6 versions. It still works, but we don't test against it anymore.

- Remove official support for Rails 7.0 and Rails 6.x, add Appraisal config for Rails 8.x
- Bump actions/checkout from 3 to 4 (#40)
- Drop support for rails v6.* versions (#60)
- Regenerate Appraisals, drop Rails 7.0
- Allow usage of google-protobuf 4.x
- Use an actual .proto for testing
- Test with both google-protobuf 3.25 and 4.x
- Remove --verbose when running rake test

## 0.19.0
### Added
- 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
- 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.

## 0.18.0
### Added
- Allow literal assignment of protos to fields

## 0.17.0
### Changed
- Instead of appending to repeated enum message, we're replacing it to avoid issues in case output will be rendered twice
- If one field was defined twice, only last definition will end up in output

## Fixed
- Fixed CI by locking 3 version or lower of google-protobuf dependency.

## 0.16.2
### Added
- Add support for partial as a first argument , e.g.`pb.friends "racers/racer", as: :racer, collection: @racers`
- Add tests to verify that fragment caching is operational

## 0.16.1
### Changed
- Deal properly with recursive protobuf messages while using ActiveView::CollectionRenderer

## 0.16.0
### Added
- Added support for new collection rendering, that is backed by ActiveView::CollectionRenderer.

### Changed
- Refactoring and simplification of #merge! method without a change in functionality.

## 0.15.1
### Fixed
- #merge! method to handle repeated unintialized message object

## 0.15.0
### Changed
- #merge! method was refactored to accomodate caching for all data types (especially those that are :repeated)

## 0.14.0
### Added
- Adding `frozen_string_literal: true` to all files.

## 0.13.2 2023.02.3
### Fixed
## 0.13.2
- 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.

## 0.13.1 2023.01.24
### Added
## 0.13.1
- #merge! to support boolean values

## 0.13.0 2023.01.18
### Added
## 0.13.0
- #merge! method added for PbbuilderTemplate class
- ActiveSupport added as a dependency for gem
- Fragment Caching support added, with #cache! and #cache_if! methods in PbbuilderTemplate class.


### Changed
- Appraisal is properly configured to run against all rubies and rails combinations.
- Supported ruby version's are 2.7, 3.0, 3.1
- Superclass for pbbuilder is now active_support/proxy_object, with a fallback to active_support/basic_object.
- Library upgrade: All gems are updated to the latest possible version. Most notable upgrades:
- `rails` from version 6.1.4.4 to 6.1.7, and from version 7.0.1 to 7.0.4
- `google-protobuf` is let loose
- `bundler` from version 2.3.4 to 2.3.22

### Removed
- TestUnit dependency

- TestUnit dependency removed

## 0.12.0 Prior to 2022-10-14

Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ else
file_name = ARGV[1]
test_name = ARGV[2]&.tr(" ", "_")

ENV["TESTOPTS"] = "--verbose"
ENV["TESTOPTS"] = ""

t.test_files = if file_name
if test_name
Expand Down
1 change: 1 addition & 0 deletions gemfiles/rails_7_2.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ source "https://rubygems.org"
gem "rake"
gem "appraisal"
gem "rails", "~> 7.2.0"
gem "google-protobuf", "~> 3.25", "< 4.0"

gemspec path: "../"
3 changes: 2 additions & 1 deletion gemfiles/rails_7_0.gemfile → gemfiles/rails_8_0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ source "https://rubygems.org"

gem "rake"
gem "appraisal"
gem "rails", "~> 7.0.0"
gem "rails", "~> 8.0.2"
gem "google-protobuf", "~> 4.0", "< 5.0"

gemspec path: "../"
9 changes: 0 additions & 9 deletions gemfiles/rails_head.gemfile

This file was deleted.

14 changes: 7 additions & 7 deletions pbbuilder.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@

Gem::Specification.new do |spec|
spec.name = "pbbuilder"
spec.version = "0.19.0"
spec.authors = ["Bouke van der Bijl"]
spec.email = ["bouke@cheddar.me"]
spec.version = "0.20.0"
spec.authors = ["Bouke van der Bijl", "Julik Tarkhanov", "Stas Katkov", "Sebastian van Hesteren"]
spec.email = ["julik@cheddar.me"]
spec.homepage = "https://github.com/cheddar-me/pbbuilder"
spec.summary = "Generate Protobuf Messages with a simple DSL similar to JBuilder"
spec.summary = "Generate Protobuf messages with a simple DSL similar to JBuilder"
spec.license = "MIT"

spec.required_ruby_version = '>= 2.7'
spec.required_ruby_version = '>= 3.2'

spec.files = `git ls-files`.split("\n")
spec.test_files = `git ls-files -- test/*`.split("\n")

spec.add_dependency "google-protobuf", "~> 3.25"
spec.add_dependency "google-protobuf", ">= 3.25", "< 5.0"
spec.add_dependency "activesupport"
spec.add_development_dependency 'm'
spec.add_development_dependency "m"
spec.add_development_dependency "pry"
end
28 changes: 7 additions & 21 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,14 @@

ActiveSupport.test_order = :random

Google::Protobuf::DescriptorPool.generated_pool.build do
add_file("pbbuilder.proto", syntax: :proto3) do
add_message "pbbuildertest.Person" do
optional :name, :string, 1
repeated :friends, :message, 2, "pbbuildertest.Person"
optional :best_friend, :message, 3, "pbbuildertest.Person"
repeated :nicknames, :string, 4
optional :field_mask, :message, 5, "google.protobuf.FieldMask"
map :favourite_foods, :string, :string, 6
repeated :tags, :string, 7
optional :last_name, :string, 8
optional :boolean_me, :bool, 9
optional :logo, :message, 10, "pbbuildertest.Asset"
end

add_message "pbbuildertest.Asset" do
optional :url, :string, 1
optional :url_2x, :string, 2
optional :url_3x, :string, 3
end
end
# Regenerate Ruby descriptors from proto if needed, and require them.
# This does require protoc to be installed
proto_file = File.expand_path("test_proto.proto", __dir__)
ruby_out = File.expand_path("test_proto_pb.rb", __dir__)
if !File.exist?(ruby_out) || File.mtime(ruby_out) < File.mtime(proto_file)
system("protoc --proto_path=#{File.dirname(proto_file)} --ruby_out=#{File.dirname(ruby_out)} #{proto_file}")
end
require_relative "test_proto_pb"

module API
Person = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("pbbuildertest.Person").msgclass
Expand Down
27 changes: 27 additions & 0 deletions test/test_proto.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// This is the source proto file from which Ruby proto descriptors are generated.
// See test/test_helper.rb for the generation process.

syntax = "proto3";

package pbbuildertest;

import "google/protobuf/field_mask.proto";

message Person {
string name = 1;
repeated Person friends = 2;
Person best_friend = 3;
repeated string nicknames = 4;
google.protobuf.FieldMask field_mask = 5;
map<string, string> favourite_foods = 6;
repeated string tags = 7;
string last_name = 8;
bool boolean_me = 9;
Asset logo = 10;
}

message Asset {
string url = 1;
string url_2x = 2;
string url_3x = 3;
}
18 changes: 18 additions & 0 deletions test/test_proto_pb.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.