hermes_messenger_of_the_gods 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.drone.yml +9 -0
- data/.gitignore +12 -0
- data/.rspec +3 -0
- data/.ruby-version +1 -0
- data/.travis.yml +5 -0
- data/Gemfile +13 -0
- data/README.md +464 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/fly_hermes +57 -0
- data/hermes_messenger_of_the_gods.gemspec +38 -0
- data/lib/hermes_messenger_of_the_gods.rb +57 -0
- data/lib/hermes_messenger_of_the_gods/concerns/base.rb +42 -0
- data/lib/hermes_messenger_of_the_gods/concerns/grpc_protobuf.rb +62 -0
- data/lib/hermes_messenger_of_the_gods/concerns/message.rb +194 -0
- data/lib/hermes_messenger_of_the_gods/concerns/mono_message.rb +52 -0
- data/lib/hermes_messenger_of_the_gods/concerns/worker.rb +173 -0
- data/lib/hermes_messenger_of_the_gods/configuration.rb +29 -0
- data/lib/hermes_messenger_of_the_gods/endpoint_builder.rb +41 -0
- data/lib/hermes_messenger_of_the_gods/endpoints.rb +3 -0
- data/lib/hermes_messenger_of_the_gods/endpoints/base.rb +113 -0
- data/lib/hermes_messenger_of_the_gods/endpoints/sns.rb +21 -0
- data/lib/hermes_messenger_of_the_gods/endpoints/sqs.rb +114 -0
- data/lib/hermes_messenger_of_the_gods/exceptions.rb +27 -0
- data/lib/hermes_messenger_of_the_gods/logging_helpers.rb +30 -0
- data/lib/hermes_messenger_of_the_gods/output/basic.rb +63 -0
- data/lib/hermes_messenger_of_the_gods/status_server.rb +48 -0
- data/lib/hermes_messenger_of_the_gods/testing/array_endpoint.rb +46 -0
- data/lib/hermes_messenger_of_the_gods/testing/dispatch_matcher.rb +52 -0
- data/lib/hermes_messenger_of_the_gods/testing/rspec_helpers.rb +64 -0
- data/lib/hermes_messenger_of_the_gods/version.rb +3 -0
- data/packageGems.sh +13 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/.bundlecache +0 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/.circleci/config.yml +32 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/.gitignore +11 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/.rspec +3 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/.rubocop.yml +42 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/.ruby-version +1 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/.travis.yml +5 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/Gemfile +6 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/Gemfile.lock +75 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/Makefile +1 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/README.md +78 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/Rakefile +6 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/bin/bundle +105 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/bin/coderay +29 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/bin/console +14 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/bin/grpc_tools_ruby_protoc +29 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/bin/grpc_tools_ruby_protoc_plugin +29 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/bin/htmldiff +29 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/bin/ldiff +29 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/bin/pry +29 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/bin/rake +29 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/bin/rspec +29 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/bin/rubocop +29 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/bin/ruby-parse +29 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/bin/ruby-rewrite +29 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/bin/setup +8 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/lib/protobuf3_fixer.rb +123 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/lib/protobuf3_fixer/encoder.rb +63 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/lib/protobuf3_fixer/generation_helpers.rb +23 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/lib/protobuf3_fixer/reflector.rb +66 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/lib/protobuf3_fixer/version.rb +3 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/protobuf3_fixer.gemspec +54 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/rubocop/bundle +105 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/rubocop/coderay +29 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/rubocop/grpc_tools_ruby_protoc +29 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/rubocop/grpc_tools_ruby_protoc_plugin +29 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/rubocop/htmldiff +29 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/rubocop/ldiff +29 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/rubocop/pry +29 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/rubocop/rake +29 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/rubocop/rspec +29 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/rubocop/rubocop +29 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/rubocop/ruby-parse +29 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/rubocop/ruby-rewrite +29 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/spec/build_from_hash_spec.rb +20 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/spec/encoding/encoding_options_spec.rb +23 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/spec/extra_fields/json_decode_of_superset_spec.rb +54 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/spec/generation_helpers_spec.rb +37 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/spec/protobuf3_fixer_spec.rb +5 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/spec/spec_helper.rb +17 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/spec/support/compiled_protobuffs/source/superset_pb.rb +44 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/spec/support/compiled_protobuffs/source/timestamp_pb.rb +27 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/spec/support/protobuffs/source/superset.proto +40 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/spec/support/protobuffs/source/timestamp.proto +18 -0
- data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/spec/well_known_type_fixes/timestamp_spec.rb +79 -0
- data/vendor/cache/activemodel-6.0.3.1.gem +0 -0
- data/vendor/cache/activesupport-6.0.3.1.gem +0 -0
- data/vendor/cache/addressable-2.6.0.gem +0 -0
- data/vendor/cache/aws-eventstream-1.1.0.gem +0 -0
- data/vendor/cache/aws-partitions-1.329.0.gem +0 -0
- data/vendor/cache/aws-sdk-core-3.99.2.gem +0 -0
- data/vendor/cache/aws-sdk-sns-1.25.1.gem +0 -0
- data/vendor/cache/aws-sdk-sqs-1.27.1.gem +0 -0
- data/vendor/cache/aws-sigv4-1.1.4.gem +0 -0
- data/vendor/cache/codeclimate-test-reporter-1.0.9.gem +0 -0
- data/vendor/cache/coderay-1.1.2.gem +0 -0
- data/vendor/cache/concurrent-ruby-1.1.6.gem +0 -0
- data/vendor/cache/crack-0.4.3.gem +0 -0
- data/vendor/cache/diff-lcs-1.3.gem +0 -0
- data/vendor/cache/docile-1.1.5.gem +0 -0
- data/vendor/cache/google-protobuf-3.12.2-universal-darwin.gem +0 -0
- data/vendor/cache/google-protobuf-3.12.2-x86_64-linux.gem +0 -0
- data/vendor/cache/google-protobuf-3.12.2.gem +0 -0
- data/vendor/cache/googleapis-common-protos-types-1.0.2.gem +0 -0
- data/vendor/cache/grpc-1.18.0-universal-darwin.gem +0 -0
- data/vendor/cache/grpc-1.18.0-x86_64-linux.gem +0 -0
- data/vendor/cache/grpc-1.18.0.gem +0 -0
- data/vendor/cache/hashdiff-0.3.8.gem +0 -0
- data/vendor/cache/i18n-1.8.3.gem +0 -0
- data/vendor/cache/jmespath-1.4.0.gem +0 -0
- data/vendor/cache/json-2.1.0.gem +0 -0
- data/vendor/cache/memory_profiler-0.9.12.gem +0 -0
- data/vendor/cache/method_source-0.9.2.gem +0 -0
- data/vendor/cache/minitest-5.14.1.gem +0 -0
- data/vendor/cache/pry-0.12.2.gem +0 -0
- data/vendor/cache/public_suffix-3.0.3.gem +0 -0
- data/vendor/cache/rake-10.5.0.gem +0 -0
- data/vendor/cache/rspec-3.8.0.gem +0 -0
- data/vendor/cache/rspec-core-3.8.0.gem +0 -0
- data/vendor/cache/rspec-expectations-3.8.2.gem +0 -0
- data/vendor/cache/rspec-mocks-3.8.0.gem +0 -0
- data/vendor/cache/rspec-support-3.8.0.gem +0 -0
- data/vendor/cache/safe_yaml-1.0.4.gem +0 -0
- data/vendor/cache/simplecov-0.13.0.gem +0 -0
- data/vendor/cache/simplecov-html-0.10.2.gem +0 -0
- data/vendor/cache/thor-1.0.1.gem +0 -0
- data/vendor/cache/thread_safe-0.3.6.gem +0 -0
- data/vendor/cache/timecop-0.9.1.gem +0 -0
- data/vendor/cache/tzinfo-1.2.7.gem +0 -0
- data/vendor/cache/webmock-3.5.1.gem +0 -0
- data/vendor/cache/zeitwerk-2.3.0.gem +0 -0
- metadata +362 -0
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'ruby-rewrite' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 150) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("parser", "ruby-rewrite")
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe 'creating a PB from a hash' do
|
6
|
+
let(:ts_subobject) do
|
7
|
+
Testing::Examples::Timestamp::SubTs.new(
|
8
|
+
ts: Google::Protobuf::Timestamp.new(seconds: 10)
|
9
|
+
)
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'raises an error on unknown fields' do
|
13
|
+
expect do
|
14
|
+
Protobuf3Fixer.build_from_hash(
|
15
|
+
Testing::Examples::Timestamp::SubTs,
|
16
|
+
ts: { seconds: 10 }
|
17
|
+
)
|
18
|
+
end.to raise_error Google::Protobuf::ParseError
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe 'options passed to encode_json' do
|
6
|
+
describe 'persisting defaults' do
|
7
|
+
let(:pb_object_with_defaults) do
|
8
|
+
Testing::Examples::ExtraFields::SubField1.new
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'excludes defaults' do
|
12
|
+
expect(
|
13
|
+
Protobuf3Fixer.encode_json(pb_object_with_defaults)
|
14
|
+
).to eq('{}')
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'allows the inclusion of defaults' do
|
18
|
+
expect(
|
19
|
+
Protobuf3Fixer.encode_json(pb_object_with_defaults, emit_defaults: true)
|
20
|
+
).to eq('{"fielda":""}')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/spec/extra_fields/json_decode_of_superset_spec.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe 'decoding a superset of fields via json' do
|
6
|
+
let(:subset_subobject) do
|
7
|
+
Testing::Examples::ExtraFields::SubField1.new(fielda: 'abc')
|
8
|
+
end
|
9
|
+
|
10
|
+
let(:superset_subobject) do
|
11
|
+
Testing::Examples::ExtraFields::SuperSubField1.new(
|
12
|
+
fielda: 'abc',
|
13
|
+
fieldb: 'def'
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
let(:superset_json) do
|
18
|
+
Testing::Examples::ExtraFields::Superset.encode_json(
|
19
|
+
Testing::Examples::ExtraFields::Superset.new(
|
20
|
+
field1: 'abc',
|
21
|
+
field2: 'def',
|
22
|
+
arr_field: [superset_subobject],
|
23
|
+
mapField: { 'abc' => superset_subobject },
|
24
|
+
subMsg: superset_subobject,
|
25
|
+
foo: %w[1 2 3],
|
26
|
+
bar: { 'a' => 'b' },
|
27
|
+
foo_extra: %w[a b],
|
28
|
+
bar_extra: { 'd' => 'e' }
|
29
|
+
)
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'errors using the provided decoders' do
|
34
|
+
expect do
|
35
|
+
Testing::Examples::ExtraFields::Subset.decode_json(superset_json)
|
36
|
+
end.to raise_error Google::Protobuf::ParseError
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'properly parses a superset of top level fields' do
|
40
|
+
expect(
|
41
|
+
Protobuf3Fixer.decode_json(
|
42
|
+
Testing::Examples::ExtraFields::Subset,
|
43
|
+
superset_json
|
44
|
+
)
|
45
|
+
).to eq Testing::Examples::ExtraFields::Subset.new(
|
46
|
+
field1: 'abc',
|
47
|
+
arr_field: [subset_subobject],
|
48
|
+
mapField: { 'abc' => subset_subobject },
|
49
|
+
subMsg: subset_subobject,
|
50
|
+
foo: %w[1 2 3],
|
51
|
+
bar: { 'a' => 'b' },
|
52
|
+
)
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe Protobuf3Fixer::GenerationHelpers do
|
6
|
+
it 'creates a timestamp proto' do
|
7
|
+
test_time = Time.now
|
8
|
+
expect(
|
9
|
+
Protobuf3Fixer::GenerationHelpers.create_timestamp(test_time)
|
10
|
+
).to have_attributes(
|
11
|
+
seconds: test_time.to_i,
|
12
|
+
nanos: test_time.nsec
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'creates a date proto from a date' do
|
17
|
+
test_date = Date.today
|
18
|
+
expect(
|
19
|
+
Protobuf3Fixer::GenerationHelpers.create_date(test_date)
|
20
|
+
).to have_attributes(
|
21
|
+
year: test_date.year,
|
22
|
+
month: test_date.month,
|
23
|
+
day: test_date.day
|
24
|
+
)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'creates a date proto from a string' do
|
28
|
+
test_date = '2019-10-12'
|
29
|
+
expect(
|
30
|
+
Protobuf3Fixer::GenerationHelpers.create_date(test_date)
|
31
|
+
).to have_attributes(
|
32
|
+
year: 2019,
|
33
|
+
month: 10,
|
34
|
+
day: 12
|
35
|
+
)
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "bundler/setup"
|
2
|
+
require "protobuf3_fixer"
|
3
|
+
require 'pry'
|
4
|
+
|
5
|
+
RSpec.configure do |config|
|
6
|
+
Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }
|
7
|
+
|
8
|
+
# Enable flags like --only-failures and --next-failure
|
9
|
+
config.example_status_persistence_file_path = ".rspec_status"
|
10
|
+
|
11
|
+
# Disable RSpec exposing methods globally on `Module` and `main`
|
12
|
+
config.disable_monkey_patching!
|
13
|
+
|
14
|
+
config.expect_with :rspec do |c|
|
15
|
+
c.syntax = :expect
|
16
|
+
end
|
17
|
+
end
|
data/vendor/cache/Protobuf3Fixer-5f9f1a2d2da9/spec/support/compiled_protobuffs/source/superset_pb.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
|
+
# source: source/superset.proto
|
3
|
+
|
4
|
+
require 'google/protobuf'
|
5
|
+
|
6
|
+
Google::Protobuf::DescriptorPool.generated_pool.build do
|
7
|
+
add_message "testing.examples.extra_fields.SubField1" do
|
8
|
+
optional :fielda, :string, 1
|
9
|
+
end
|
10
|
+
add_message "testing.examples.extra_fields.SuperSubField1" do
|
11
|
+
optional :fielda, :string, 1
|
12
|
+
optional :fieldb, :string, 2
|
13
|
+
end
|
14
|
+
add_message "testing.examples.extra_fields.Subset" do
|
15
|
+
optional :field1, :string, 1
|
16
|
+
repeated :arr_field, :message, 2, "testing.examples.extra_fields.SubField1"
|
17
|
+
map :mapField, :string, :message, 3, "testing.examples.extra_fields.SubField1"
|
18
|
+
optional :subMsg, :message, 4, "testing.examples.extra_fields.SubField1"
|
19
|
+
repeated :foo, :string, 5
|
20
|
+
map :bar, :string, :string, 6
|
21
|
+
end
|
22
|
+
add_message "testing.examples.extra_fields.Superset" do
|
23
|
+
optional :field1, :string, 1
|
24
|
+
repeated :arr_field, :message, 2, "testing.examples.extra_fields.SuperSubField1"
|
25
|
+
map :mapField, :string, :message, 3, "testing.examples.extra_fields.SuperSubField1"
|
26
|
+
optional :subMsg, :message, 4, "testing.examples.extra_fields.SuperSubField1"
|
27
|
+
repeated :foo, :string, 5
|
28
|
+
map :bar, :string, :string, 6
|
29
|
+
repeated :foo_extra, :string, 7
|
30
|
+
map :bar_extra, :string, :string, 8
|
31
|
+
optional :field2, :string, 9
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
module Testing
|
36
|
+
module Examples
|
37
|
+
module ExtraFields
|
38
|
+
SubField1 = Google::Protobuf::DescriptorPool.generated_pool.lookup("testing.examples.extra_fields.SubField1").msgclass
|
39
|
+
SuperSubField1 = Google::Protobuf::DescriptorPool.generated_pool.lookup("testing.examples.extra_fields.SuperSubField1").msgclass
|
40
|
+
Subset = Google::Protobuf::DescriptorPool.generated_pool.lookup("testing.examples.extra_fields.Subset").msgclass
|
41
|
+
Superset = Google::Protobuf::DescriptorPool.generated_pool.lookup("testing.examples.extra_fields.Superset").msgclass
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
|
+
# source: source/timestamp.proto
|
3
|
+
|
4
|
+
require 'google/protobuf'
|
5
|
+
|
6
|
+
require 'google/protobuf/timestamp_pb'
|
7
|
+
Google::Protobuf::DescriptorPool.generated_pool.build do
|
8
|
+
add_message "testing.examples.timestamp.SubTs" do
|
9
|
+
optional :ts, :message, 2, "google.protobuf.Timestamp"
|
10
|
+
optional :ts_one, :message, 3, "google.protobuf.Timestamp"
|
11
|
+
optional :tsTwo, :message, 4, "google.protobuf.Timestamp"
|
12
|
+
repeated :foo, :message, 5, "google.protobuf.Timestamp"
|
13
|
+
map :bar, :string, :message, 6, "google.protobuf.Timestamp"
|
14
|
+
end
|
15
|
+
add_message "testing.examples.timestamp.ParentTs" do
|
16
|
+
optional :abc, :message, 1, "testing.examples.timestamp.SubTs"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
module Testing
|
21
|
+
module Examples
|
22
|
+
module Timestamp
|
23
|
+
SubTs = Google::Protobuf::DescriptorPool.generated_pool.lookup("testing.examples.timestamp.SubTs").msgclass
|
24
|
+
ParentTs = Google::Protobuf::DescriptorPool.generated_pool.lookup("testing.examples.timestamp.ParentTs").msgclass
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
syntax = "proto3";
|
2
|
+
|
3
|
+
package testing.examples.extra_fields;
|
4
|
+
|
5
|
+
message SubField1 {
|
6
|
+
string fielda = 1;
|
7
|
+
}
|
8
|
+
|
9
|
+
message SuperSubField1 {
|
10
|
+
string fielda = 1;
|
11
|
+
string fieldb = 2;
|
12
|
+
}
|
13
|
+
|
14
|
+
message Subset {
|
15
|
+
string field1 = 1;
|
16
|
+
repeated SubField1 arr_field = 2;
|
17
|
+
map<string, SubField1> mapField = 3;
|
18
|
+
SubField1 subMsg = 4;
|
19
|
+
|
20
|
+
// Things it shouldn't touch
|
21
|
+
repeated string foo = 5;
|
22
|
+
map<string, string> bar = 6;
|
23
|
+
}
|
24
|
+
|
25
|
+
message Superset {
|
26
|
+
string field1 = 1;
|
27
|
+
repeated SuperSubField1 arr_field = 2;
|
28
|
+
map<string, SuperSubField1> mapField = 3;
|
29
|
+
SuperSubField1 subMsg = 4;
|
30
|
+
|
31
|
+
// Things it shouldn't touch
|
32
|
+
repeated string foo = 5;
|
33
|
+
map<string, string> bar = 6;
|
34
|
+
|
35
|
+
repeated string foo_extra = 7;
|
36
|
+
map<string, string> bar_extra = 8;
|
37
|
+
|
38
|
+
string field2 = 9;
|
39
|
+
}
|
40
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
syntax = "proto3";
|
2
|
+
|
3
|
+
import "google/protobuf/timestamp.proto";
|
4
|
+
|
5
|
+
package testing.examples.timestamp;
|
6
|
+
|
7
|
+
message SubTs {
|
8
|
+
google.protobuf.Timestamp ts = 2;
|
9
|
+
google.protobuf.Timestamp ts_one = 3;
|
10
|
+
google.protobuf.Timestamp tsTwo = 4;
|
11
|
+
repeated google.protobuf.Timestamp foo = 5;
|
12
|
+
map<string, google.protobuf.Timestamp> bar = 6;
|
13
|
+
}
|
14
|
+
|
15
|
+
message ParentTs {
|
16
|
+
SubTs abc = 1;
|
17
|
+
}
|
18
|
+
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe 'decoding a superset of fields via json' do
|
6
|
+
let(:ts_subobject) do
|
7
|
+
Testing::Examples::Timestamp::SubTs.new(
|
8
|
+
ts: Google::Protobuf::Timestamp.new(seconds: 10),
|
9
|
+
ts_one: Google::Protobuf::Timestamp.new(seconds: 10),
|
10
|
+
tsTwo: Google::Protobuf::Timestamp.new(seconds: 10),
|
11
|
+
foo: [Google::Protobuf::Timestamp.new(seconds: 10)],
|
12
|
+
bar: { 'a' => Google::Protobuf::Timestamp.new(seconds: 10) }
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
let(:ts_parentobj) do
|
17
|
+
Testing::Examples::Timestamp::ParentTs.new(
|
18
|
+
abc: ts_subobject
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
let(:ts_subobject_json) do
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'works on a strait up timestamp' do
|
26
|
+
expect(
|
27
|
+
Protobuf3Fixer.encode_json(
|
28
|
+
Google::Protobuf::Timestamp.new(seconds: 10)
|
29
|
+
)
|
30
|
+
).to eq('1970-01-01T00:00:10Z'.to_json)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'generates timestamps encoded as RFC3339' do
|
34
|
+
expect(
|
35
|
+
Protobuf3Fixer.encode_json(ts_subobject)
|
36
|
+
.yield_self(&JSON.method(:parse))
|
37
|
+
).to eq(
|
38
|
+
'ts' => '1970-01-01T00:00:10Z',
|
39
|
+
'tsOne' => '1970-01-01T00:00:10Z',
|
40
|
+
'tsTwo' => '1970-01-01T00:00:10Z',
|
41
|
+
'foo' => ['1970-01-01T00:00:10Z'],
|
42
|
+
'bar' => { 'a' => '1970-01-01T00:00:10Z' }
|
43
|
+
)
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'decodes the json it generates' do
|
47
|
+
expect(
|
48
|
+
Protobuf3Fixer.decode_json(
|
49
|
+
Testing::Examples::Timestamp::SubTs,
|
50
|
+
Protobuf3Fixer.encode_json(ts_subobject)
|
51
|
+
)
|
52
|
+
).to eq ts_subobject
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'subobjects' do
|
56
|
+
it 'handles subobjects' do
|
57
|
+
expect(
|
58
|
+
Protobuf3Fixer.encode_json(ts_parentobj).yield_self(&JSON.method(:parse))
|
59
|
+
).to eq(
|
60
|
+
'abc' => {
|
61
|
+
'ts' => '1970-01-01T00:00:10Z',
|
62
|
+
'tsOne' => '1970-01-01T00:00:10Z',
|
63
|
+
'tsTwo' => '1970-01-01T00:00:10Z',
|
64
|
+
'foo' => ['1970-01-01T00:00:10Z'],
|
65
|
+
'bar' => { 'a' => '1970-01-01T00:00:10Z' },
|
66
|
+
}
|
67
|
+
)
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'handles encode -> decode' do
|
71
|
+
expect(
|
72
|
+
Protobuf3Fixer.decode_json(
|
73
|
+
Testing::Examples::Timestamp::ParentTs,
|
74
|
+
Protobuf3Fixer.encode_json(ts_parentobj)
|
75
|
+
)
|
76
|
+
).to eq ts_parentobj
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|