pbbuilder 0.16.2 → 0.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/pbbuilder.rb +5 -3
- data/pbbuilder.gemspec +2 -2
- data/test/pbbuilder_test.rb +28 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe95820bf0015825b24715abe48a568f865affb04ec6c3db6261f33cd3e19829
|
4
|
+
data.tar.gz: 0de697e6e0970a49cf599cb764e1941e019b1b6e0dddcc86c862c070a34ec904
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa06d08bee0e966095491d7b1d0956ff5c0f9a5d305fe66308c98883ddbe3c424d60b62ebf846fe25d2e7ec86181baf0666ec0d638648117188d1b17e3185784
|
7
|
+
data.tar.gz: dac52c94458493380247cba47db06e61ad29590ff8b09b51abbe870aca8381f553870c16604b8079653488c0acc76fa87bfa54cb6a652e3c9fd0538e09ed85d8
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,14 @@ 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.17.0
|
7
|
+
### Changed
|
8
|
+
- Instead of appending to repeated enum message, we're replacing it to avoid issues in case output will be rendered twice
|
9
|
+
- If one field was defined twice, only last definition will end up in output
|
10
|
+
|
11
|
+
## Fixed
|
12
|
+
- Fixed CI by locking 3 version or lower of google-protobuf dependency.
|
13
|
+
|
6
14
|
## 0.16.2
|
7
15
|
### Added
|
8
16
|
- Add support for partial as a first argument , e.g.`pb.friends "racers/racer", as: :racer, collection: @racers`
|
data/lib/pbbuilder.rb
CHANGED
@@ -75,12 +75,12 @@ class Pbbuilder
|
|
75
75
|
if arg.respond_to?(:to_hash)
|
76
76
|
# example syntax that should end up here:
|
77
77
|
# pb.fields {"one" => "two"}
|
78
|
+
|
78
79
|
arg.to_hash.each { |k, v| @message[name][k] = v }
|
79
80
|
elsif arg.respond_to?(:to_ary) && !descriptor.type.eql?(:message)
|
80
81
|
# pb.fields ["one", "two"]
|
81
|
-
# Using concat so it behaves the same as _append_repeated
|
82
82
|
|
83
|
-
@message[name].
|
83
|
+
@message[name].replace arg.to_ary
|
84
84
|
elsif arg.respond_to?(:to_ary) && descriptor.type.eql?(:message)
|
85
85
|
# example syntax that should end up here:
|
86
86
|
# pb.friends [Person.new(name: "Johnny Test"), Person.new(name: "Max Verstappen")]
|
@@ -89,11 +89,13 @@ class Pbbuilder
|
|
89
89
|
else
|
90
90
|
# example syntax that should end up here:
|
91
91
|
# pb.fields "one"
|
92
|
-
|
92
|
+
|
93
|
+
@message[name].replace [arg]
|
93
94
|
end
|
94
95
|
else
|
95
96
|
# example syntax that should end up here:
|
96
97
|
# pb.field "value"
|
98
|
+
|
97
99
|
@message[name] = arg
|
98
100
|
end
|
99
101
|
else
|
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.
|
5
|
+
spec.version = "0.17.0"
|
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"
|
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
|
|
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"
|
17
|
+
spec.add_dependency "google-protobuf", "~> 3.25"
|
18
18
|
spec.add_dependency "activesupport"
|
19
19
|
spec.add_development_dependency 'm'
|
20
20
|
spec.add_development_dependency "pry"
|
data/test/pbbuilder_test.rb
CHANGED
@@ -25,11 +25,38 @@ class PbbuilderTest < ActiveSupport::TestCase
|
|
25
25
|
|
26
26
|
assert_equal "Hello world", person.name
|
27
27
|
assert_equal "Friend #1", person.friends.first.name
|
28
|
-
assert_equal ["
|
28
|
+
assert_equal ["cool"], person.field_mask.paths
|
29
29
|
assert_equal "Manuelo", person.best_friend.name
|
30
30
|
assert_equal "Eggs", person.favourite_foods["Breakfast"]
|
31
31
|
end
|
32
32
|
|
33
|
+
test "replaces the repeated field's value with the last one set" do
|
34
|
+
person = Pbbuilder.new(API::Person.new) do |pb|
|
35
|
+
pb.field_mask do
|
36
|
+
pb.paths ["ok", "that's"]
|
37
|
+
end
|
38
|
+
end.target!
|
39
|
+
|
40
|
+
p = Pbbuilder.new(person) do |pb|
|
41
|
+
pb.field_mask do
|
42
|
+
pb.paths ["ok", "that's"]
|
43
|
+
end
|
44
|
+
end.target!
|
45
|
+
|
46
|
+
assert_equal(["ok", "that's"], p.field_mask.paths)
|
47
|
+
end
|
48
|
+
|
49
|
+
test "sets the last value of the repeated field to be the only value" do
|
50
|
+
person = Pbbuilder.new(API::Person.new) do |pb|
|
51
|
+
pb.field_mask do
|
52
|
+
pb.paths ["ok", "that's"]
|
53
|
+
pb.paths ["cool"]
|
54
|
+
end
|
55
|
+
end.target!
|
56
|
+
|
57
|
+
assert_equal ["cool"], person.field_mask.paths
|
58
|
+
end
|
59
|
+
|
33
60
|
test "it can extract fields in a nice way" do
|
34
61
|
klass = Struct.new(:name)
|
35
62
|
friends = [klass.new("Friend 1"), klass.new("Friend 2")]
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pbbuilder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.17.0
|
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: 2024-03-
|
11
|
+
date: 2024-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google-protobuf
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '3.25'
|
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: '
|
26
|
+
version: '3.25'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activesupport
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
requirements: []
|
126
|
-
rubygems_version: 3.
|
126
|
+
rubygems_version: 3.3.7
|
127
127
|
signing_key:
|
128
128
|
specification_version: 4
|
129
129
|
summary: Generate Protobuf Messages with a simple DSL similar to JBuilder
|