diff --git a/build/ruby/.gitignore b/build/ruby/.gitignore index 5decf0a..0ae12ff 100644 --- a/build/ruby/.gitignore +++ b/build/ruby/.gitignore @@ -11,6 +11,6 @@ .rspec_status # generated ruby files -lib/tucana/actions/*.rb -lib/tucana/internal/*.rb +lib/tucana/aquila/*.rb +lib/tucana/sagittarius/*.rb lib/tucana/shared/*.rb diff --git a/build/ruby/Rakefile b/build/ruby/Rakefile index 459c594..546f73e 100644 --- a/build/ruby/Rakefile +++ b/build/ruby/Rakefile @@ -9,13 +9,10 @@ RSpec::Core::RakeTask.new(:spec) PROJECT_ROOT = File.expand_path("../..", __dir__) RUBY_ROOT = "#{PROJECT_ROOT}/build/ruby".freeze +RUBY_LIB_ROOT = "#{RUBY_ROOT}/lib/tucana".freeze PROTO_ROOT = "#{PROJECT_ROOT}/proto".freeze -INPUT_ACTIONS_DIR = "#{PROTO_ROOT}/actions".freeze -INPUT_INTERNAL_DIR = "#{PROTO_ROOT}/internal".freeze INPUT_SHARED_DIR = "#{PROTO_ROOT}/shared".freeze -OUTPUT_ACTIONS_DIR = "#{RUBY_ROOT}/lib/tucana/actions".freeze -OUTPUT_INTERNAL_DIR = "#{RUBY_ROOT}/lib/tucana/internal".freeze -OUTPUT_SHARED_DIR = "#{RUBY_ROOT}/lib/tucana/shared".freeze +OUTPUT_SHARED_DIR = "#{RUBY_LIB_ROOT}/shared".freeze def system!(*args) system(*args, exception: true) @@ -54,18 +51,17 @@ namespace :generate_ruby do compile_protos!(INPUT_SHARED_DIR, OUTPUT_SHARED_DIR) end - desc "Generate ruby files for the internal protocol" - task internal: "generate_ruby:shared" do - compile_protos!(INPUT_INTERNAL_DIR, OUTPUT_INTERNAL_DIR) - end + require_relative 'lib/tucana' - desc "Generate ruby files for the actions protocol" - task actions: "generate_ruby:shared" do - compile_protos!(INPUT_ACTIONS_DIR, OUTPUT_ACTIONS_DIR) + Tucana::AVAILABLE_PROTOCOLS.each do |protocol| + desc "Generate ruby files for the #{protocol} protocol" + task protocol => :shared do + compile_protos!("#{PROTO_ROOT}/#{protocol}", "#{RUBY_LIB_ROOT}/#{protocol}") + end end desc "Generate ruby files for all protocols" - task all: %w[generate_ruby:internal generate_ruby:actions] + task all: Tucana::AVAILABLE_PROTOCOLS end namespace :release do diff --git a/build/ruby/lib/tucana.rb b/build/ruby/lib/tucana.rb index 47998d7..db49a6f 100644 --- a/build/ruby/lib/tucana.rb +++ b/build/ruby/lib/tucana.rb @@ -5,6 +5,8 @@ module Tucana class Error < StandardError; end + AVAILABLE_PROTOCOLS = %i[aquila sagittarius] + def self.load_protocol(protocol) this_dir = File.expand_path(File.dirname(__FILE__)) protocol_dir = File.join(this_dir, "tucana/#{protocol}") diff --git a/build/ruby/spec/tucana_spec.rb b/build/ruby/spec/tucana_spec.rb index 7b8941b..af171fe 100644 --- a/build/ruby/spec/tucana_spec.rb +++ b/build/ruby/spec/tucana_spec.rb @@ -5,11 +5,9 @@ expect(Tucana::VERSION).not_to be_nil end - it "can load internal protocol" do - expect { Tucana.load_protocol(:internal) }.not_to raise_error - end - - it "can load actions protocol" do - expect { Tucana.load_protocol(:actions) }.not_to raise_error + Tucana::AVAILABLE_PROTOCOLS.each do |protocol| + it "can load #{protocol} protocol" do + expect { Tucana.load_protocol(protocol) }.not_to raise_error + end end end diff --git a/build/rust/build.rs b/build/rust/build.rs index c0eac72..d2ca984 100644 --- a/build/rust/build.rs +++ b/build/rust/build.rs @@ -15,8 +15,8 @@ fn main() -> Result<()> { let inclusions = &[ "../../proto/shared", - "../../proto/internal", - "../../proto/actions", + "../../proto/sagittarius", + "../../proto/aquila", ]; let out_path = "src/generated"; diff --git a/build/rust/src/lib.rs b/build/rust/src/lib.rs index 1a02dce..11bb7d5 100644 --- a/build/rust/src/lib.rs +++ b/build/rust/src/lib.rs @@ -1,9 +1,9 @@ -pub mod internal { - include!("generated/internal.rs"); +pub mod sagittarius { + include!("generated/sagittarius.rs"); } -pub mod actions { - include!("generated/actions.rs"); +pub mod aquila { + include!("generated/aquila.rs"); } pub mod shared { diff --git a/proto/actions/transfer.proto b/proto/aquila/transfer.proto similarity index 87% rename from proto/actions/transfer.proto rename to proto/aquila/transfer.proto index 5021338..0c8a899 100644 --- a/proto/actions/transfer.proto +++ b/proto/aquila/transfer.proto @@ -2,9 +2,9 @@ syntax = "proto3"; import "definitions.proto"; -option ruby_package = "Tucana::Actions"; +option ruby_package = "Tucana::Aquila"; -package actions; +package aquila; message InformationRequest { string identifier = 1; diff --git a/proto/internal/flow_definition.proto b/proto/internal/flow_definition.proto deleted file mode 100644 index a1af7fe..0000000 --- a/proto/internal/flow_definition.proto +++ /dev/null @@ -1,8 +0,0 @@ -syntax = "proto3"; - -option ruby_package = "Tucana::Internal"; - -package internal; - -message FlowDefinition { -} \ No newline at end of file diff --git a/proto/internal/action.proto b/proto/sagittarius/action.proto similarity index 88% rename from proto/internal/action.proto rename to proto/sagittarius/action.proto index 989b6a4..81b801a 100644 --- a/proto/internal/action.proto +++ b/proto/sagittarius/action.proto @@ -1,9 +1,9 @@ syntax = "proto3"; import "definitions.proto"; -option ruby_package = "Tucana::Internal"; +option ruby_package = "Tucana::Sagittarius"; -package internal; +package sagittarius; message ActionLogonRequest { string identifier = 1; diff --git a/proto/internal/flow.proto b/proto/sagittarius/flow.proto similarity index 93% rename from proto/internal/flow.proto rename to proto/sagittarius/flow.proto index 708d906..fe8ed9c 100644 --- a/proto/internal/flow.proto +++ b/proto/sagittarius/flow.proto @@ -1,8 +1,8 @@ syntax = "proto3"; -option ruby_package = "Tucana::Internal"; +option ruby_package = "Tucana::Sagittarius"; -package internal; +package sagittarius; import "node.proto"; import "flow_definition.proto"; diff --git a/proto/sagittarius/flow_definition.proto b/proto/sagittarius/flow_definition.proto new file mode 100644 index 0000000..f393ba2 --- /dev/null +++ b/proto/sagittarius/flow_definition.proto @@ -0,0 +1,8 @@ +syntax = "proto3"; + +option ruby_package = "Tucana::Sagittarius"; + +package sagittarius; + +message FlowDefinition { +} \ No newline at end of file diff --git a/proto/internal/node.proto b/proto/sagittarius/node.proto similarity index 82% rename from proto/internal/node.proto rename to proto/sagittarius/node.proto index 13d8af9..a3024f9 100644 --- a/proto/internal/node.proto +++ b/proto/sagittarius/node.proto @@ -1,8 +1,8 @@ syntax = "proto3"; -option ruby_package = "Tucana::Internal"; +option ruby_package = "Tucana::Sagittarius"; -package internal; +package sagittarius; import "definitions.proto"; diff --git a/proto/internal/ping.proto b/proto/sagittarius/ping.proto similarity index 68% rename from proto/internal/ping.proto rename to proto/sagittarius/ping.proto index c8559ad..88b82a3 100644 --- a/proto/internal/ping.proto +++ b/proto/sagittarius/ping.proto @@ -1,8 +1,8 @@ syntax = "proto3"; -option ruby_package = "Tucana::Internal"; +option ruby_package = "Tucana::Sagittarius"; -package internal; +package sagittarius; message PingMessage { int64 ping_id = 1;