hadron 0.1.3 → 0.1.6

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5789e8b8a04dc4e123db597eebdc97e4fa0a97d5e1df1747cd8f6b78bed40ada
4
- data.tar.gz: d27140dbc167d46189d967878db79cc429a47c8c4c36cb5fc83617cc48103d76
3
+ metadata.gz: e9c80e4d16226e4f656e36f23f9195db88fe9330070ebf9da6cd062f7386a0a5
4
+ data.tar.gz: 273a6c9d5389325ef878671321c4913a312f81c7d51cfdb30810c7cde18fe6a8
5
5
  SHA512:
6
- metadata.gz: 6d6504fcfee5ebeb1020ad01e55960686fa04399cd39ffb74b5bdb3db3729911257645525a73d7eef68247753c8782739bf838abde8a53c1ff48c03ef38a2092
7
- data.tar.gz: 61edf40b2de032a523f6a61d630cb759ef36f36e1877e27c1ed447a5639f77010d724abf03d6168c505b8deedc2c2221a87bc98968591f60b2e527ab4c2a21f4
6
+ metadata.gz: 95c08fc728f26542cb9719326fd2739447f4cb426cec11fb514d080a01129cb2e4b05cff2893cf90843f40df25a38775fd015ad42aed78dff2f002e67d6b2fe5
7
+ data.tar.gz: 67c42934db699adbebbcdbfc6d01a854f6c6d2c128cba6e697a4d99542690b952e74ebb57a63eed50dc804f43ef7260664e881fa6e78152302bf4b26d9547ca2
data/Gemfile CHANGED
@@ -5,8 +5,10 @@ source "https://rubygems.org"
5
5
  # Specify your gem's dependencies in hadron.gemspec
6
6
  gemspec
7
7
 
8
- gem "proto_dsl", "~> 0.1.1"
8
+ gem "pry", "~> 0.14.1"
9
9
  gem "rake", "~> 13.0"
10
10
  gem "rspec", "~> 3.0"
11
11
  gem "rubocop", "~> 1.21"
12
+
12
13
  gem "thor", "~> 1.2"
14
+ gem "fileutils", "~> 1.7"
data/Gemfile.lock CHANGED
@@ -1,18 +1,23 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hadron (0.1.3)
4
+ hadron (0.1.6)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
9
  ast (2.4.2)
10
+ coderay (1.1.3)
10
11
  diff-lcs (1.5.0)
12
+ fileutils (1.7.0)
11
13
  json (2.6.3)
14
+ method_source (1.0.0)
12
15
  parallel (1.22.1)
13
16
  parser (3.1.3.0)
14
17
  ast (~> 2.4.1)
15
- proto_dsl (0.1.1)
18
+ pry (0.14.1)
19
+ coderay (~> 1.1)
20
+ method_source (~> 1.0)
16
21
  rainbow (3.1.1)
17
22
  rake (13.0.6)
18
23
  regexp_parser (2.6.1)
@@ -51,8 +56,9 @@ PLATFORMS
51
56
  x86_64-linux
52
57
 
53
58
  DEPENDENCIES
59
+ fileutils (~> 1.7)
54
60
  hadron!
55
- proto_dsl (~> 0.1.1)
61
+ pry (~> 0.14.1)
56
62
  rake (~> 13.0)
57
63
  rspec (~> 3.0)
58
64
  rubocop (~> 1.21)
data/bin/cli ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "hadron"
6
+
7
+ Hadron::Cli.start(ARGV)
data/hadron.gemspec CHANGED
@@ -7,6 +7,7 @@ Gem::Specification.new do |spec|
7
7
  spec.version = Hadron::VERSION
8
8
  spec.authors = ["Sylvance"]
9
9
  spec.email = ["kerandisylvance@gmail.com"]
10
+ spec.platform = Gem::Platform::RUBY
10
11
 
11
12
  spec.summary = "Ruby framework called Hadron that allows you to work with gRPC Ruby output easily."
12
13
  spec.description = "Ruby framework called Hadron that allows you to work with gRPC Ruby output easily."
@@ -27,7 +28,7 @@ Gem::Specification.new do |spec|
27
28
  end
28
29
  end
29
30
 
30
- spec.executables = ["hadron"]
31
+ spec.executables << "cli"
31
32
  spec.require_paths = ["lib"]
32
33
 
33
34
  # Uncomment to register a new dependency of your gem
data/lib/hadron/cli.rb ADDED
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "thor"
4
+ require "fileutils"
5
+
6
+ module Hadron
7
+ class Cli < Thor
8
+ desc "create PROJECT_NAME", "Creates a new gRPC Ruby server project with the given name"
9
+ def create(project_name)
10
+ # Create the project directory
11
+ FileUtils.mkdir_p(project_name)
12
+
13
+ # Copy the templates to the project directory
14
+ FileUtils.cp_r("templates/.", project_name)
15
+
16
+ # Replace placeholders in the templates with the project name
17
+ Dir["#{project_name}/**/*.erb"].each do |template_path|
18
+ template = File.read(template_path)
19
+ result = ERB.new(template).result(binding)
20
+ File.write(template_path.sub(/\.erb\z/, ""), result)
21
+ File.delete(template_path)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Hadron
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.6"
5
5
  end
data/lib/hadron.rb CHANGED
@@ -4,20 +4,4 @@ Dir[File.join(__dir__, "hadron", "*.rb")].sort.each { |file| require file }
4
4
 
5
5
  module Hadron
6
6
  class Error < StandardError; end
7
-
8
- def self.create_project(name)
9
- puts "Creates project #{name}"
10
- end
11
-
12
- def self.create_database
13
- puts "Creates database"
14
- end
15
-
16
- def self.migrates_database
17
- puts "Migrates database"
18
- end
19
-
20
- def self.generate_scaffold(name)
21
- puts "Generates scaffold #{name}"
22
- end
23
7
  end
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "grpc"
4
+ gem "grpc-tools"
@@ -0,0 +1,13 @@
1
+ syntax = "proto3";
2
+
3
+ service Greeter {
4
+ rpc SayHello (HelloRequest) returns (HelloResponse) {}
5
+ }
6
+
7
+ message HelloRequest {
8
+ string name = 1;
9
+ }
10
+
11
+ message HelloResponse {
12
+ string message = 1;
13
+ }
@@ -0,0 +1,53 @@
1
+ # Welcome to the gRPC Ruby Server Project
2
+
3
+ This project is a template for creating a gRPC Ruby server using the [gRPC gem](https://github.com/grpc/grpc). It includes the necessary dependencies and files to get started with building a gRPC server in Ruby.
4
+
5
+ ## Prerequisites
6
+
7
+ Before getting started, make sure you have the following installed on your machine:
8
+
9
+ - [Ruby](https://www.ruby-lang.org/) (version 2.6 or higher)
10
+ - [Bundler](https://bundler.io/) (for installing dependencies)
11
+
12
+ ## Installation
13
+
14
+ To install the dependencies for this project, run the following command in the root directory of the project:
15
+
16
+ ```bash
17
+ bundle install
18
+ ```
19
+
20
+ ## Running the Server
21
+ To start the gRPC server, run the following command in the root directory of the project:
22
+
23
+ ```bash
24
+ ruby server.rb
25
+ ```
26
+
27
+ This will start the server and listen for incoming gRPC requests on port 50051.
28
+
29
+ ## Customizing the Server
30
+
31
+ To customize the gRPC server, you can modify the helloworld.proto file in the lib/proto directory to define your own gRPC service and messages. You can then regenerate the Ruby code for the service using the grpc_tools_ruby_protoc command:
32
+
33
+ ```bash
34
+ bundle exec grpc_tools_ruby_protoc -I lib/proto --ruby_out=lib --grpc_out=lib lib/proto/helloworld.proto
35
+ ```
36
+
37
+ You can also modify the helloworld_services.rb file in the lib directory to define the logic for handling gRPC requests and responses.
38
+
39
+ ## Testing the Server
40
+
41
+ To test the gRPC server, you can use a gRPC client to send requests to the server and verify the responses. You can find more information about creating gRPC clients in Ruby in the gRPC documentation.
42
+
43
+ ## Deployment
44
+
45
+ To deploy the gRPC server, you can follow the steps for deploying a gRPC server in your preferred environment. You can find more information about deploying gRPC servers in the gRPC documentation.
46
+
47
+ ## Contributing
48
+
49
+ We welcome contributions to this project! If you have an idea for how to improve the gRPC Ruby server template, please feel free to open an issue or pull request.
50
+
51
+ ## License
52
+
53
+ This project is licensed under the MIT License. See the LICENSE file for more information.
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "helloworld_services"
5
+
6
+ def main
7
+ s = GRPC::RpcServer.new
8
+ s.add_http2_port("0.0.0.0:50051", :this_port_is_insecure)
9
+ s.handle(Helloworld::GreeterServer)
10
+ s.run_till_terminated_or_interrupted([1, "int", "SIGQUIT"])
11
+ end
12
+
13
+ main
@@ -0,0 +1,9 @@
1
+ require "grpc"
2
+
3
+ module Helloworld
4
+ class GreeterServer < Helloworld::Greeter::Service
5
+ def say_hello(hello_req, _unused_call)
6
+ Helloworld::HelloResponse.new(message: "Hello \#{hello_req.name}")
7
+ end
8
+ end
9
+ end
metadata CHANGED
@@ -1,21 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hadron
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sylvance
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-08 00:00:00.000000000 Z
11
+ date: 2022-12-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ruby framework called Hadron that allows you to work with gRPC Ruby output
14
14
  easily.
15
15
  email:
16
16
  - kerandisylvance@gmail.com
17
17
  executables:
18
- - hadron
18
+ - cli
19
19
  extensions: []
20
20
  extra_rdoc_files: []
21
21
  files:
@@ -27,10 +27,16 @@ files:
27
27
  - Gemfile.lock
28
28
  - README.md
29
29
  - Rakefile
30
- - bin/hadron
30
+ - bin/cli
31
31
  - hadron.gemspec
32
32
  - lib/hadron.rb
33
+ - lib/hadron/cli.rb
33
34
  - lib/hadron/version.rb
35
+ - templates/gemfile.erb
36
+ - templates/protobuf.erb
37
+ - templates/readme.md
38
+ - templates/server.erb
39
+ - templates/services.erb
34
40
  homepage: https://github.com/Sylvance/hadron
35
41
  licenses: []
36
42
  metadata:
data/bin/hadron DELETED
@@ -1,50 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'thor'
4
- require 'hadron'
5
-
6
- # Define the `create` subcommand
7
- command :create do |c|
8
- c.desc "Create a new project"
9
- c.arg_name "project_name"
10
-
11
- c.action do |args, options|
12
- project_name = args.first
13
- Hadron.create_project(project_name)
14
- end
15
- end
16
-
17
- # Define the `db` subcommand
18
- command :db do |c|
19
- # Define the `create` subcommand for `db`
20
- c.command :create do |create|
21
- create.desc "Create a database"
22
- create.action do |args, options|
23
- Hadron.create_database
24
- end
25
- end
26
-
27
- # Define the `migrate` subcommand for `db`
28
- c.command :migrate do |migrate|
29
- migrate.desc "Migrate a database"
30
- migrate.action do |args, options|
31
- Hadron.migrate_database
32
- end
33
- end
34
- end
35
-
36
- # Define the `generate` subcommand
37
- command :generate do |c|
38
- c.desc "Generate boilerplate code"
39
-
40
- # Define the `scaffold` subcommand for `generate`
41
- c.command :scaffold do |scaffold|
42
- scaffold.desc "Generate scaffold code"
43
- scaffold.arg_name "scaffold_name"
44
-
45
- scaffold.action do |args, options|
46
- scaffold_name = args.first
47
- Hadron.generate_scaffold(scaffold_name)
48
- end
49
- end
50
- end