protobuf 2.0.0.rc2 → 2.0.0.rc3
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.
- data/.gitignore +1 -0
- data/ext/ruby_generator/Makefile +10 -0
- data/ext/ruby_generator/RubyGenerator.cpp +85 -70
- data/ext/ruby_generator/RubyGenerator.h +23 -4
- data/lib/protobuf.rb +33 -26
- data/lib/protobuf/cli.rb +18 -13
- data/lib/protobuf/enum.rb +39 -34
- data/lib/protobuf/enum_value.rb +29 -0
- data/lib/protobuf/field/base_field.rb +34 -5
- data/lib/protobuf/field/enum_field.rb +6 -14
- data/lib/protobuf/field/extension_fields.rb +13 -5
- data/lib/protobuf/field/field_array.rb +17 -7
- data/lib/protobuf/field/varint_field.rb +4 -6
- data/lib/protobuf/message.rb +44 -148
- data/lib/protobuf/rpc/server.rb +2 -2
- data/lib/protobuf/version.rb +1 -1
- data/spec/benchmark/tasks.rb +7 -8
- data/spec/functional/evented_server_spec.rb +9 -9
- data/spec/functional/socket_server_spec.rb +8 -8
- data/spec/functional/zmq_server_spec.rb +8 -8
- data/spec/lib/protobuf/cli_spec.rb +30 -11
- data/spec/lib/protobuf/enum_spec.rb +90 -0
- data/spec/lib/protobuf/enum_value_spec.rb +13 -0
- data/spec/lib/protobuf/message/encoder_spec.rb +1 -1
- data/spec/lib/protobuf/message_spec.rb +50 -0
- data/spec/lib/protobuf/rpc/client_spec.rb +23 -23
- data/spec/lib/protobuf/rpc/servers/evented_server_spec.rb +1 -1
- data/spec/lib/protobuf/rpc/servers/socket_server_spec.rb +1 -1
- data/spec/lib/protobuf/rpc/service_spec.rb +18 -18
- data/spec/lib/protobuf_spec.rb +62 -0
- data/spec/spec_helper.rb +12 -1
- data/spec/support/all.rb +0 -1
- data/spec/support/server.rb +1 -1
- data/spec/support/test/enum.pb.rb +32 -0
- data/spec/support/test/enum.proto +12 -0
- data/spec/support/test/resource.pb.rb +52 -0
- data/spec/{proto/test.proto → support/test/resource.proto} +2 -2
- data/spec/support/test/resource_service.rb +14 -0
- metadata +51 -48
- data/ext/Makefile +0 -11
- data/spec/lib/protobuf/message/enum_spec.rb +0 -13
- data/spec/lib/protobuf/message/message_spec.rb +0 -67
- data/spec/proto/test.pb.rb +0 -54
- data/spec/proto/test_service.rb +0 -30
- data/spec/proto/test_service_impl.rb +0 -18
- data/spec/support/silent_constants.rb +0 -44
data/spec/proto/test_service.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'protobuf/rpc/service'
|
2
|
-
require 'spec/proto/test.pb'
|
3
|
-
|
4
|
-
## !! DO NOT EDIT THIS FILE !!
|
5
|
-
##
|
6
|
-
## To implement this service as defined by the protobuf, simply
|
7
|
-
## reopen Spec::Proto::TestService and implement each service method:
|
8
|
-
##
|
9
|
-
## module Spec
|
10
|
-
## module Proto
|
11
|
-
## class TestService
|
12
|
-
##
|
13
|
-
## # request -> Spec::Proto::ResourceFindRequest
|
14
|
-
## # response -> Spec::Proto::Resource
|
15
|
-
## def find
|
16
|
-
## # TODO: implement find
|
17
|
-
## end
|
18
|
-
##
|
19
|
-
## end
|
20
|
-
## end
|
21
|
-
## end
|
22
|
-
##
|
23
|
-
|
24
|
-
module Spec
|
25
|
-
module Proto
|
26
|
-
class TestService < Protobuf::Rpc::Service
|
27
|
-
rpc :find, ResourceFindRequest, Resource
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'protobuf/rpc/service'
|
2
|
-
require File.dirname(__FILE__) + '/test.pb'
|
3
|
-
require File.dirname(__FILE__) + '/test_service'
|
4
|
-
|
5
|
-
module Spec
|
6
|
-
module Proto
|
7
|
-
class TestService
|
8
|
-
|
9
|
-
# request -> Spec::Proto::ResourceFindRequest
|
10
|
-
# response -> Spec::Proto::Resource
|
11
|
-
def find
|
12
|
-
response.name = request.name
|
13
|
-
response.status = request.active ? 1 : 0
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
# Just a way to keep warnings from being flagged in rename of constants during tests
|
2
|
-
=begin
|
3
|
-
module Kernel
|
4
|
-
def silence_warnings
|
5
|
-
orig_verbosity = $VERBOSE
|
6
|
-
$VERBOSE = nil
|
7
|
-
yield
|
8
|
-
$VERBOSE = orig_verbosity
|
9
|
-
end
|
10
|
-
end
|
11
|
-
=end
|
12
|
-
|
13
|
-
module SilentConstants
|
14
|
-
=begin
|
15
|
-
def parse(constant)
|
16
|
-
source, _, constant_name = constant.to_s.rpartition('::')
|
17
|
-
[Object.const_get(source.to_sym), constant_name.to_sym]
|
18
|
-
end
|
19
|
-
|
20
|
-
# Examples
|
21
|
-
# with_constants "Something" => "nothing" do
|
22
|
-
# end
|
23
|
-
#
|
24
|
-
# with_constants "Something::Foo" => "something else" do
|
25
|
-
# end
|
26
|
-
#
|
27
|
-
def with_constants(constants, &block)
|
28
|
-
saved_constants = {}
|
29
|
-
constants.each do |constant, val|
|
30
|
-
source_object, const_name = parse(constant)
|
31
|
-
saved_constants[constant] = source_object.const_get(const_name)
|
32
|
-
Kernel::silence_warnings { source_object.const_set(const_name, val) }
|
33
|
-
end
|
34
|
-
|
35
|
-
block.call
|
36
|
-
ensure
|
37
|
-
constants.each do |constant, val|
|
38
|
-
source_object, const_name = parse(constant)
|
39
|
-
Kernel::silence_warnings { source_object.const_set(const_name, saved_constants[constant]) }
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
=end
|
44
|
-
end
|