Skip to content

Commit 68dbe87

Browse files
committed
Implement datatypes into sagittarius protocol
1 parent d23f291 commit 68dbe87

File tree

3 files changed

+72
-1
lines changed

3 files changed

+72
-1
lines changed

build/ruby/Rakefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,15 @@ namespace :generate_ruby do
4040

4141
Dir["#{output_dir}/*_pb.rb"].each do |file|
4242
code = File.read(file)
43-
code = code.gsub(/require '(\S+)_pb'/, "require_relative '\\1_pb'")
43+
code = code.gsub(/require '(\S+)_pb'/) do |str|
44+
match = Regexp.last_match[1]
45+
46+
if File.exist?("#{output_dir}/#{match}_pb.rb")
47+
"require_relative '#{match}_pb'"
48+
else
49+
str
50+
end
51+
end
4452
File.write(file, code)
4553
end
4654
end

proto/sagittarius/datatype.proto

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
syntax = "proto3";
2+
import "translations.proto";
3+
import "google/protobuf/any.proto";
4+
5+
option ruby_package = "Tucana::Sagittarius";
6+
7+
package sagittarius;
8+
9+
message DataType {
10+
enum Variant {
11+
UNKNOWN = 0;
12+
PRIMITIVE = 1;
13+
TYPE = 2;
14+
OBJECT = 3;
15+
DATATYPE = 4;
16+
ARRAY = 5;
17+
GENERIC = 6;
18+
FUNCTION = 7;
19+
}
20+
21+
shared.Translation name = 1;
22+
Variant variant = 2;
23+
repeated DataTypeRule rules = 3;
24+
repeated DataType input_types = 4;
25+
optional DataType return_type = 5;
26+
optional DataType parent_type = 6;
27+
}
28+
29+
message DataTypeRule {
30+
enum Variant {
31+
UNKNOWN = 0;
32+
REGEX = 1;
33+
NUMBER_RANGE = 2;
34+
ITEM_OF_COLLECTION = 3;
35+
CONTAINS_TYPE = 4;
36+
CONTAINS_KEY = 5;
37+
}
38+
39+
Variant variant = 1;
40+
map<string, google.protobuf.Any> config = 2;
41+
}
42+
43+
message DataTypeUpdateRequest {
44+
repeated DataType data_types = 1;
45+
}
46+
47+
message DataTypeUpdateResponse {
48+
bool success = 1;
49+
}
50+
51+
service DataTypeService {
52+
rpc Update(DataTypeUpdateRequest) returns (DataTypeUpdateResponse) {}
53+
}

proto/shared/translations.proto

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
syntax = "proto3";
2+
3+
option ruby_package = "Tucana::Shared";
4+
5+
package shared;
6+
7+
message Translation {
8+
string code = 1;
9+
string text = 2;
10+
}

0 commit comments

Comments
 (0)