protobuf 3.10.8 → 3.10.10

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.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +106 -22
  3. data/.rubocop.yml +30 -11
  4. data/.rubocop_todo.yml +462 -60
  5. data/CHANGES.md +31 -0
  6. data/Gemfile +22 -0
  7. data/lib/protobuf/code_generator.rb +17 -5
  8. data/lib/protobuf/decoder.rb +33 -2
  9. data/lib/protobuf/field/base_field.rb +13 -5
  10. data/lib/protobuf/field/base_field_object_definitions.rb +40 -6
  11. data/lib/protobuf/field/bool_field.rb +2 -1
  12. data/lib/protobuf/field/int32_field.rb +12 -0
  13. data/lib/protobuf/field/sint32_field.rb +10 -0
  14. data/lib/protobuf/field/uint32_field.rb +9 -0
  15. data/lib/protobuf/generators/printable.rb +10 -1
  16. data/lib/protobuf/message/serialization.rb +4 -4
  17. data/lib/protobuf/railtie.rb +48 -0
  18. data/lib/protobuf/rpc/application_service.rb +12 -0
  19. data/lib/protobuf/rpc/buffer.rb +2 -2
  20. data/lib/protobuf/rpc/service.rb +7 -3
  21. data/lib/protobuf/rpc/service_filters.rb +35 -5
  22. data/lib/protobuf/service_loader.rb +21 -0
  23. data/lib/protobuf/version.rb +1 -1
  24. data/lib/protobuf.rb +5 -0
  25. data/protobuf.gemspec +9 -27
  26. data/spec/encoding/packed_decoding_spec.rb +233 -0
  27. data/spec/encoding/wire_compat_decoding_spec.rb +113 -0
  28. data/spec/functional/railtie_boot_spec.rb +84 -0
  29. data/spec/lib/protobuf/field/bool_field_spec.rb +21 -0
  30. data/spec/lib/protobuf/field/string_field_spec.rb +0 -2
  31. data/spec/lib/protobuf/generators/service_generator_spec.rb +23 -0
  32. data/spec/lib/protobuf/message_spec.rb +0 -2
  33. data/spec/lib/protobuf/railtie_spec.rb +86 -0
  34. data/spec/lib/protobuf/rpc/application_service_spec.rb +57 -0
  35. data/spec/lib/protobuf/rpc/service_filters_inheritance_spec.rb +105 -0
  36. data/spec/lib/protobuf/service_loader_spec.rb +88 -0
  37. metadata +49 -77
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0c5dfe944c45e6d2ae26771385b8bfe7719efe4efd6576d0f95866319872342e
4
- data.tar.gz: aa4bb74aadc1e5d2462db9df39b8b931e2382478078f4c84aa4c22d1d2145252
3
+ metadata.gz: 8096ad0d169fe7be73b2cce91ed6b45fc29ce8377f6599468ea4b165f3cba5fc
4
+ data.tar.gz: f562a6ffed606efb06c22f429859d3c6f34a95024e12775b5fe500242f4af760
5
5
  SHA512:
6
- metadata.gz: 4b225ea3a368cec4e619d8b117dc8eb1e11fe913ce1563c254c8530a6b18abb6109a5c4aaace7c1fbd7f774df302fce9d182c5db166e5e013e9e8d18334d0fc6
7
- data.tar.gz: 2450cdba292656144044d49098f9c95cc8e487cf27843ab99abf2d99c1f0478d566b65f181ac87babb05aeab2f62f5cea611d41d717e10eeeaccef59c4cf1f25
6
+ metadata.gz: 759ac6f9f38a1eb1a462cbaa8b7f8c172563fe85963fa51e8557d37464def8dd486b66a4e272593b6a9cb10f6094df3848678b139dd8fe15fd057f3a1d50d512
7
+ data.tar.gz: eacef1704e921e60280621d4cea12396c43a20e597e0485dfb402c18cf2d918d110f33cfb88fec57d729eb1bdf797c15abef77216604c99b3dca845d55ac1e21
data/.circleci/config.yml CHANGED
@@ -1,46 +1,130 @@
1
1
  version: 2.1
2
2
 
3
3
  jobs:
4
- # skipping build step because Gemfile.lock is not included in the source
5
- # this makes the bundler caching step a noop
4
+ rubocop:
5
+ docker:
6
+ # RuboCop 0.81 does not load on Ruby 4.0 (it needs the benchmark gem).
7
+ - image: cimg/ruby:3.4
8
+ steps:
9
+ - checkout
10
+ - run:
11
+ name: Install gems
12
+ command: bundle install --jobs 4 --retry 3
13
+ - run:
14
+ name: RuboCop
15
+ command: bundle exec rubocop
16
+
6
17
  test:
7
18
  parameters:
8
- ruby-image:
19
+ ruby:
20
+ type: string
21
+ rails:
9
22
  type: string
10
23
  docker:
11
- - image: << parameters.ruby-image >>
24
+ - image: cimg/ruby:<< parameters.ruby >>
25
+ environment:
26
+ # Newer protoc versions reject the explicit `map_entry` option in the spec protos.
27
+ PROTOC_VERSION: "3.16.0"
28
+ RAILS_VERSION: "~> << parameters.rails >>.0"
12
29
  steps:
30
+ - checkout
31
+ - run:
32
+ name: Install ZeroMQ
33
+ command: sudo apt-get update && sudo apt-get install -y libzmq3-dev
13
34
  - run:
14
- name: Install protobuf compiler
35
+ name: Install protoc
15
36
  command: |
16
- archive=protoc-3.16.0-linux-x86_64
17
- curl -O -L https://github.com/protocolbuffers/protobuf/releases/download/v3.16.0/$archive.zip
18
- sudo unzip -d '/usr/local' $archive.zip 'bin/*' 'include/*'
19
- sudo chown -R $(whoami) /usr/local/bin/protoc /usr/local/include/google
20
- rm -rf $archive.zip
37
+ archive="protoc-${PROTOC_VERSION}-linux-x86_64"
38
+ curl -sSL -o "/tmp/${archive}.zip" \
39
+ "https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/${archive}.zip"
40
+ sudo unzip -q -o -d /usr/local "/tmp/${archive}.zip" 'bin/*' 'include/*'
41
+ sudo chmod -R a+rX /usr/local/bin/protoc /usr/local/include/google
42
+ protoc --version
43
+ # Gemfile.lock is not committed, so each job resolves gems for its own
44
+ # Ruby and RAILS_VERSION.
45
+ - run:
46
+ name: Install gems
47
+ command: bundle install --jobs 4 --retry 3
48
+ - run:
49
+ name: Compile protos
50
+ command: bundle exec rake compile:spec compile:rpc
21
51
  - run:
22
- command: protoc --version
52
+ name: Check compiled protos are committed
53
+ command: git diff --exit-code
23
54
  - run:
24
- command: sudo apt-get update
55
+ name: Run specs
56
+ command: bundle exec rspec
57
+
58
+ test-jruby:
59
+ parameters:
60
+ jruby:
61
+ type: string
62
+ rails:
63
+ type: string
64
+ docker:
65
+ - image: jruby:<< parameters.jruby >>
66
+ environment:
67
+ PROTOC_VERSION: "3.16.0"
68
+ RAILS_VERSION: "~> << parameters.rails >>.0"
69
+ JRUBY_OPTS: "--dev"
70
+ steps:
71
+ # The jruby image has no git, so install it before checkout.
25
72
  - run:
26
- message: Install ZeroMQ
27
- command: sudo apt-get -y install libzmq3-dev
73
+ name: Install system packages
74
+ command: apt-get update && apt-get install -y git unzip build-essential libzmq3-dev
28
75
  - checkout
29
76
  - run:
30
- command: gem install bundler
77
+ name: Install protoc
78
+ command: |
79
+ archive="protoc-${PROTOC_VERSION}-linux-x86_64"
80
+ curl -sSL -o "/tmp/${archive}.zip" \
81
+ "https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/${archive}.zip"
82
+ unzip -q -o -d /usr/local "/tmp/${archive}.zip" 'bin/*' 'include/*'
83
+ protoc --version
84
+ - run:
85
+ name: Install gems
86
+ command: bundle install --jobs 4 --retry 3
87
+ - run:
88
+ name: Compile protos
89
+ command: bundle exec rake compile:spec compile:rpc
31
90
  - run:
32
- command: bundle install
91
+ name: Check compiled protos are committed
92
+ command: git diff --exit-code
33
93
  - run:
34
- command: bundle exec rake
94
+ name: Run specs
95
+ command: bundle exec rspec
35
96
 
36
97
  workflows:
37
98
  build_and_test:
38
99
  jobs:
100
+ - rubocop
39
101
  - test:
102
+ name: test-ruby-<< matrix.ruby >>-rails-<< matrix.rails >>
103
+ matrix:
104
+ parameters:
105
+ ruby: ["3.1", "3.2", "3.3", "3.4", "4.0"]
106
+ rails: ["6.0", "6.1", "7.0", "7.1", "7.2", "8.0", "8.1"]
107
+ exclude:
108
+ # Rails 8.0+ requires Ruby 3.2+.
109
+ - { ruby: "3.1", rails: "8.0" }
110
+ - { ruby: "3.1", rails: "8.1" }
111
+ # Rails 6.x does not load on Ruby 3.4+: it needs bigdecimal and
112
+ # logger, which are no longer default gems, and does not declare them.
113
+ - { ruby: "3.4", rails: "6.0" }
114
+ - { ruby: "3.4", rails: "6.1" }
115
+ - { ruby: "4.0", rails: "6.0" }
116
+ - { ruby: "4.0", rails: "6.1" }
117
+ - test-jruby:
118
+ name: test-jruby-<< matrix.jruby >>-rails-<< matrix.rails >>
40
119
  matrix:
41
120
  parameters:
42
- ruby-image:
43
- - circleci/jruby:9.2.6.0-jdk
44
- - circleci/jruby:9.1.17.0-jdk
45
- - circleci/ruby:2.5
46
- - circleci/ruby:2.7
121
+ # JRuby 9.4 is Ruby 3.1; JRuby 10.0 is Ruby 3.4.
122
+ jruby: ["9.4", "10.0"]
123
+ rails: ["6.1", "7.1", "7.2", "8.0", "8.1"]
124
+ exclude:
125
+ # Rails 8.0+ requires Ruby 3.2+.
126
+ - { jruby: "9.4", rails: "8.0" }
127
+ - { jruby: "9.4", rails: "8.1" }
128
+ # Rails 6.x does not load on Ruby 3.4 (base64 and bigdecimal are
129
+ # no longer default gems).
130
+ - { jruby: "10.0", rails: "6.1" }
data/.rubocop.yml CHANGED
@@ -2,12 +2,18 @@ inherit_from: .rubocop_todo.yml
2
2
 
3
3
  AllCops:
4
4
  DisplayCopNames: true
5
+ # The newest version RuboCop 0.81 knows. Without it, RuboCop reads the Ruby
6
+ # version from .ruby-version or Gemfile.lock and fails on Ruby 3.x.
7
+ TargetRubyVersion: 2.7
5
8
  Exclude:
6
9
  - 'spec/support/protos/*.pb.rb'
7
10
  - 'varint_prof.rb'
8
11
 
9
- Lint/EndAlignment:
10
- AlignWith: keyword
12
+ Bundler/DuplicatedGem:
13
+ Enabled: false
14
+
15
+ Layout/EndAlignment:
16
+ EnforcedStyleAlignWith: keyword
11
17
 
12
18
  Lint/Loop:
13
19
  Enabled: false
@@ -18,25 +24,26 @@ Metrics/ClassLength:
18
24
  Metrics/ModuleLength:
19
25
  Enabled: false
20
26
 
21
- Style/CaseIndentation:
22
- IndentWhenRelativeTo: end
27
+ Layout/CaseIndentation:
28
+ EnforcedStyle: end
23
29
 
24
30
  Style/ClassAndModuleChildren:
25
31
  Exclude:
26
32
  - '**/*.pb.rb'
33
+ - 'spec/**/*.rb'
27
34
 
28
- Style/ClassAndModuleCamelCase:
35
+ Naming/ClassAndModuleCamelCase:
29
36
  Exclude:
30
37
  - '**/*.pb.rb'
31
38
 
32
- Style/EmptyLineBetweenDefs:
39
+ Layout/EmptyLineBetweenDefs:
33
40
  AllowAdjacentOneLineDefs: true
34
41
 
35
- Style/EmptyLines:
42
+ Layout/EmptyLines:
36
43
  Exclude:
37
44
  - '**/*.pb.rb'
38
45
 
39
- Style/FileName:
46
+ Naming/FileName:
40
47
  Exclude:
41
48
  - '**/protoc-gen-ruby*'
42
49
 
@@ -46,7 +53,7 @@ Style/GuardClause:
46
53
  Style/HashSyntax:
47
54
  EnforcedStyle: hash_rockets
48
55
 
49
- Style/IndentHash:
56
+ Layout/FirstHashElementIndentation:
50
57
  EnforcedStyle: consistent
51
58
 
52
59
  Style/Semicolon:
@@ -55,16 +62,28 @@ Style/Semicolon:
55
62
  Style/SingleLineBlockParams:
56
63
  Enabled: false
57
64
 
58
- Style/TrailingBlankLines:
65
+ Layout/TrailingEmptyLines:
59
66
  Exclude:
60
67
  - '**/*.pb.rb'
61
68
 
62
69
  Style/TrailingCommaInArguments:
63
70
  EnforcedStyleForMultiline: comma
64
71
 
65
- Style/TrailingCommaInLiteral:
72
+ Style/TrailingCommaInArrayLiteral:
73
+ EnforcedStyleForMultiline: comma
74
+
75
+ Style/TrailingCommaInHashLiteral:
66
76
  EnforcedStyleForMultiline: comma
67
77
 
68
78
  Style/TrivialAccessors:
69
79
  AllowDSLWriters: true
70
80
  AllowPredicates: true
81
+
82
+ Style/Encoding:
83
+ Exclude:
84
+ - '**/*.pb.rb'
85
+
86
+ # TargetRubyVersion (2.7) cannot match required_ruby_version (>= 3.1), because
87
+ # RuboCop 0.81 does not know Ruby 3.x.
88
+ Gemspec/RequiredRubyVersion:
89
+ Enabled: false