Skip to content

Commit

Permalink
Merge pull request #13 from code0-tech/9-rename-protocols-to-their-se…
Browse files Browse the repository at this point in the history
…rver-components

Rename protocols to their server components
  • Loading branch information
Taucher2003 authored Oct 30, 2024
2 parents 12689f2 + fdef9a7 commit 22cf133
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 45 deletions.
4 changes: 2 additions & 2 deletions build/ruby/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
22 changes: 9 additions & 13 deletions build/ruby/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions build/ruby/lib/tucana.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down
10 changes: 4 additions & 6 deletions build/ruby/spec/tucana_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions build/rust/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ fn main() -> Result<()> {

let inclusions = &[
"../../proto/shared",
"../../proto/internal",
"../../proto/actions",
"../../proto/sagittarius",
"../../proto/aquila",
];

let out_path = "src/generated";
Expand Down
8 changes: 4 additions & 4 deletions build/rust/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions proto/actions/transfer.proto → proto/aquila/transfer.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 0 additions & 8 deletions proto/internal/flow_definition.proto

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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;
Expand Down
4 changes: 2 additions & 2 deletions proto/internal/flow.proto → proto/sagittarius/flow.proto
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
8 changes: 8 additions & 0 deletions proto/sagittarius/flow_definition.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
syntax = "proto3";

option ruby_package = "Tucana::Sagittarius";

package sagittarius;

message FlowDefinition {
}
4 changes: 2 additions & 2 deletions proto/internal/node.proto → proto/sagittarius/node.proto
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
syntax = "proto3";

option ruby_package = "Tucana::Internal";
option ruby_package = "Tucana::Sagittarius";

package internal;
package sagittarius;

import "definitions.proto";

Expand Down
4 changes: 2 additions & 2 deletions proto/internal/ping.proto → proto/sagittarius/ping.proto
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit 22cf133

Please sign in to comment.