pbbuilder 0.5.0 → 0.6.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: 1ef756425a57d8ea7b70338e5d15f4de645a0fe43c6429a7bc83e601c3ae7730
4
- data.tar.gz: 5c7579092048ee2b38f4aca3fa02c0c1490bb2f87a0ae58e9120672ca78b2de7
3
+ metadata.gz: d3f417c956ceb3a2123489021f4cc401b7bf56399355fb6bb0d4ebaa437d1cb2
4
+ data.tar.gz: '0408c3174481e7aa7e22f129829a973f822a7245d57c3e93bad2ef564d3ee05f'
5
5
  SHA512:
6
- metadata.gz: 6f963451d5430510700378384d0a996ad6eb15e311dc3669d8246122c2db7e65a0bb9b50b63855b18da1cf5f1484a57f85ad3eda95b3647f09438d04fc78d0e9
7
- data.tar.gz: 52d88436c2f78dbe307f2ce87935a03c293a6ee68d2c471c993ef753166f7450380bf600f759b2d4d5467c5167a50d93dcb63d145085f8bf50acbcdc43531bd1
6
+ metadata.gz: e7476c24846d78dd0dc011372998bb54301a673510ccc8cffe540714db1a991ba6b36c14ec0eb45572aef1880e9cb638870be38a7a510c4edb501eb0da670278
7
+ data.tar.gz: 3027ae2509d083bd9da6a02bf9732c43038534992790017a3bdb00ba1bb80179d650d1a12d6f136af036854a5944125cad64d7b17268b084609f3642e8f7dbfc
@@ -0,0 +1,22 @@
1
+ name: ruby
2
+ on: push
3
+
4
+ jobs:
5
+ test:
6
+ runs-on: ubuntu-latest
7
+ strategy:
8
+ matrix:
9
+ ruby: ["2.7", "3.0.1"]
10
+ name: tests for ruby-${{ matrix.ruby }}
11
+ steps:
12
+ - name: Checkout code
13
+ uses: actions/checkout@v2
14
+
15
+ - name: Setup Ruby
16
+ uses: ruby/setup-ruby@v1
17
+ with:
18
+ bundler-cache: true
19
+ ruby-version: ${{ matrix.ruby }}
20
+
21
+ - name: Run tests
22
+ run: bin/test
data/README.md CHANGED
@@ -22,7 +22,8 @@ $ gem install pbbuilder
22
22
  ```
23
23
 
24
24
  ## Contributing
25
- Contribution directions go here.
25
+
26
+ When debugging, make sure you're prepending `::Kernel` to any calls such as `puts` as otherwise the code will think you're trying to add another attribute onto the protobuf.
26
27
 
27
28
  ## License
28
29
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/lib/pbbuilder.rb CHANGED
@@ -58,7 +58,12 @@ class Pbbuilder < BasicObject
58
58
  elsif args.length == 1
59
59
  arg = args.first
60
60
  if descriptor.label == :repeated
61
- if arg.respond_to?(:to_ary)
61
+ if arg.respond_to?(:to_hash)
62
+ # pb.fields {"one" => "two"}
63
+ arg.to_hash.each do |k, v|
64
+ @message[name][k] = v
65
+ end
66
+ elsif arg.respond_to?(:to_ary)
62
67
  # pb.fields ["one", "two"]
63
68
  # Using concat so it behaves the same as _append_repeated
64
69
  @message[name].concat arg.to_ary
data/pbbuilder.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "pbbuilder"
3
- spec.version = "0.5.0"
3
+ spec.version = "0.6.0"
4
4
  spec.authors = ["Bouke van der Bijl"]
5
5
  spec.email = ["bouke@cheddar.me"]
6
6
  spec.homepage = "https://github.com/cheddar-me/pbbuilder"
@@ -14,11 +14,18 @@ class PbbuilderTest < ActiveSupport::TestCase
14
14
  pb.paths ["ok", "that's"]
15
15
  pb.paths "cool"
16
16
  end
17
+ pb.favourite_foods({
18
+ "Breakfast" => "Eggs",
19
+ "Lunch" => "Shawarma",
20
+ "Dinner" => "Pizza"
21
+ })
17
22
  end.target!
23
+
18
24
  assert_equal "Hello world", person.name
19
25
  assert_equal "Friend #1", person.friends.first.name
20
26
  assert_equal ["ok", "that's", "cool"], person.field_mask.paths
21
27
  assert_equal "Manuelo", person.best_friend.name
28
+ assert_equal "Eggs", person.favourite_foods["Breakfast"]
22
29
  end
23
30
 
24
31
  test "it can extract fields in a nice way" do
data/test/test_helper.rb CHANGED
@@ -19,6 +19,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do
19
19
  optional :best_friend, :message, 3, "pbbuildertest.Person"
20
20
  repeated :nicknames, :string, 4
21
21
  optional :field_mask, :message, 5, "google.protobuf.FieldMask"
22
+ map :favourite_foods, :string, :string, 6
22
23
  end
23
24
  end
24
25
  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.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bouke van der Bijl
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-15 00:00:00.000000000 Z
11
+ date: 2021-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-protobuf
@@ -24,13 +24,14 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 3.15.5
27
- description:
27
+ description:
28
28
  email:
29
29
  - bouke@cheddar.me
30
30
  executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
+ - ".github/workflows/test.yml"
34
35
  - ".gitignore"
35
36
  - Gemfile
36
37
  - MIT-LICENSE
@@ -50,7 +51,7 @@ homepage: https://github.com/cheddar-me/pbbuilder
50
51
  licenses:
51
52
  - MIT
52
53
  metadata: {}
53
- post_install_message:
54
+ post_install_message:
54
55
  rdoc_options: []
55
56
  require_paths:
56
57
  - lib
@@ -65,8 +66,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
65
66
  - !ruby/object:Gem::Version
66
67
  version: '0'
67
68
  requirements: []
68
- rubygems_version: 3.2.3
69
- signing_key:
69
+ rubygems_version: 3.1.4
70
+ signing_key:
70
71
  specification_version: 4
71
72
  summary: Generate Protobuf messages via a Builder-style DSL
72
73
  test_files: