ruby_protobuf 0.4.5 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +9 -2
- data/VERSION +1 -1
- data/lib/protobuf/common/wire_type.rb +2 -0
- data/lib/protobuf/compiler/nodes.rb +6 -0
- data/lib/protobuf/compiler/proto.y +5 -2
- data/lib/protobuf/compiler/proto_parser.rb +385 -366
- data/lib/protobuf/message/decoder.rb +31 -16
- data/lib/protobuf/message/encoder.rb +1 -0
- data/lib/protobuf/message/field.rb +12 -37
- data/lib/protobuf/message/message.rb +37 -97
- data/test/proto/merge.pb.rb +6 -6
- data/test/proto/merge.proto +3 -3
- data/test/test_enum_value.rb +3 -2
- data/test/test_extension.rb +1 -1
- data/test/test_message.rb +30 -24
- data/test/test_packed_field.rb +5 -0
- metadata +24 -29
- data/test/proto/address_book_service.rb +0 -31
- data/test/proto/client_add.rb +0 -18
- data/test/proto/client_search.rb +0 -18
- data/test/proto/float_default.pb.rb +0 -28
- data/test/proto/rpc.pb.rb +0 -16
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'protobuf/rpc/server'
|
2
|
-
require 'protobuf/rpc/handler'
|
3
|
-
require 'test/proto/rpc.pb'
|
4
|
-
|
5
|
-
class Tutorial::SearchHandler < Protobuf::Rpc::Handler
|
6
|
-
request Tutorial::Person
|
7
|
-
response Tutorial::AddressBook
|
8
|
-
|
9
|
-
def self.process_request(request, response)
|
10
|
-
# TODO: edit this method
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
class Tutorial::AddHandler < Protobuf::Rpc::Handler
|
15
|
-
request Tutorial::Person
|
16
|
-
response Tutorial::Person
|
17
|
-
|
18
|
-
def self.process_request(request, response)
|
19
|
-
# TODO: edit this method
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
class Tutorial::AddressBookService < Protobuf::Rpc::Server
|
24
|
-
def setup_handlers
|
25
|
-
@handlers = {
|
26
|
-
:search => Tutorial::SearchHandler,
|
27
|
-
:add => Tutorial::AddHandler,
|
28
|
-
}
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
data/test/proto/client_add.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
require 'protobuf/rpc/client'
|
3
|
-
require 'test/proto/rpc.pb'
|
4
|
-
|
5
|
-
# build request
|
6
|
-
request = Tutorial::Person.new
|
7
|
-
# TODO: setup a request
|
8
|
-
raise StandardError, 'setup a request'
|
9
|
-
|
10
|
-
# create blunk response
|
11
|
-
response = Tutorial::Person.new
|
12
|
-
|
13
|
-
# execute rpc
|
14
|
-
Protobuf::Rpc::Client.new('localhost', 9999).call :add, request, response
|
15
|
-
|
16
|
-
# show response
|
17
|
-
puts response
|
18
|
-
|
data/test/proto/client_search.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
require 'protobuf/rpc/client'
|
3
|
-
require 'test/proto/rpc.pb'
|
4
|
-
|
5
|
-
# build request
|
6
|
-
request = Tutorial::Person.new
|
7
|
-
# TODO: setup a request
|
8
|
-
raise StandardError, 'setup a request'
|
9
|
-
|
10
|
-
# create blunk response
|
11
|
-
response = Tutorial::AddressBook.new
|
12
|
-
|
13
|
-
# execute rpc
|
14
|
-
Protobuf::Rpc::Client.new('localhost', 9999).call :search, request, response
|
15
|
-
|
16
|
-
# show response
|
17
|
-
puts response
|
18
|
-
|
@@ -1,28 +0,0 @@
|
|
1
|
-
### Generated by rprotoc. DO NOT EDIT!
|
2
|
-
### <proto file: test/proto/float_default.proto>
|
3
|
-
# message M {
|
4
|
-
# optional float f = 1 [default = 4.2];
|
5
|
-
# optional float g = 2 [default = -4.2];
|
6
|
-
# optional float h = 3 [default = 4352];
|
7
|
-
# optional float i = 4 [default = 23145.2 ];
|
8
|
-
# optional float j = 5 [default = -5 ];
|
9
|
-
# optional float k = 6 [default = +23 ];
|
10
|
-
# optional float l = 7 [default = +23.42 ];
|
11
|
-
# }
|
12
|
-
#
|
13
|
-
|
14
|
-
require 'protobuf/message/message'
|
15
|
-
require 'protobuf/message/enum'
|
16
|
-
require 'protobuf/message/service'
|
17
|
-
require 'protobuf/message/extend'
|
18
|
-
|
19
|
-
class M < ::Protobuf::Message
|
20
|
-
defined_in __FILE__
|
21
|
-
optional :float, :f, 1, :default => 4.2
|
22
|
-
optional :float, :g, 2, :default => -4.2
|
23
|
-
optional :float, :h, 3, :default => 4352
|
24
|
-
optional :float, :i, 4, :default => 23145.2
|
25
|
-
optional :float, :j, 5, :default => -5
|
26
|
-
optional :float, :k, 6, :default => 23
|
27
|
-
optional :float, :l, 7, :default => 23.42
|
28
|
-
end
|
data/test/proto/rpc.pb.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
### Generated by rprotoc. DO NOT EDIT!
|
2
|
-
### <proto file: test/proto/rpc.proto>
|
3
|
-
# package tutorial;
|
4
|
-
#
|
5
|
-
# service AddressBookService {
|
6
|
-
# rpc Search (Person) returns (AddressBook);
|
7
|
-
# rpc Add (Person) returns (Person);
|
8
|
-
# }
|
9
|
-
|
10
|
-
require 'protobuf/message/message'
|
11
|
-
require 'protobuf/message/enum'
|
12
|
-
require 'protobuf/message/service'
|
13
|
-
require 'protobuf/message/extend'
|
14
|
-
|
15
|
-
module Tutorial
|
16
|
-
end
|