From 26ad50bc33524c1d46165b8ef7a88909207b803f Mon Sep 17 00:00:00 2001 From: Ismail Akram Date: Thu, 30 May 2024 16:52:30 +0500 Subject: [PATCH] publish version 0.1.0 --- Gemfile | 2 -- bin/xconn | 37 +++++++++++++++++++++++++++++-------- wamp.gemspec | 3 ++- 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/Gemfile b/Gemfile index ec34c33..95595c6 100644 --- a/Gemfile +++ b/Gemfile @@ -12,6 +12,4 @@ gem "rubocop", "~> 1.21" gem "async", "~> 2.9" -gem "wampproto", "~> 0.1.1", require: true - gem "debug", "~> 1.9", groups: %i[development test] diff --git a/bin/xconn b/bin/xconn index d65e997..590cff5 100755 --- a/bin/xconn +++ b/bin/xconn @@ -6,7 +6,7 @@ require "wamp" require "optparse" -options = { host: "127.0.0.1", port: 8080, realm: "realm1", directory: "." } +options = { host: "127.0.0.1", port: 8080, realm: "realm1", directory: ".", app: "App" } OptionParser.new do |opts| opts.banner = "Usage: xconn [options]" @@ -22,15 +22,24 @@ OptionParser.new do |opts| options[:port] = port end - opts.on("-dDIRECTORY", "--directory Directory", 'Directory (default: ".")') do |directory| + opts.on("-dDIRECTORY", "--directory DIRECTORY", 'Directory (default: ".")') do |directory| options[:directory] = directory end - opts.on("-aAPP", "--app App", 'App (default: "App")') do |app| + opts.on("-aAPP", "--app APP", 'App (default: "App")') do |app| options[:app] = app end + + opts.on("-v", "--version", "Gem Version") do |version| + options[:version] = version + end end.parse! +if options.include?(:version) + puts "Xconn v#{Wamp::VERSION}" + exit 0 +end + def create_client_session(router) session = Wamp::Connection::Session.new @@ -46,12 +55,24 @@ router = Wamp::Router::Base.new router.add_realm(options.fetch(:realm)) client = create_client_session(router).tap(&:on_open) -Pathname.new(options[:directory]).glob("**/*.rb").each { |file| require file.to_s } -app = Object.const_get(options[:app]) -app.new.procedures.each do |procedure, func| - client.api.register(procedure, func) do - puts "Registered procedure: #{procedure}" + +begin + Pathname.new(options[:directory]).glob("**/*.rb").each { |file| require file.to_s } +rescue LoadError => e + puts e.message + exit 1 +end + +begin + app = Object.const_get(options[:app]) + app.new.procedures.each do |procedure, func| + client.api.register(procedure, func) do + puts "Registered procedure: #{procedure}" + end end +rescue StandardError => e + puts e.message + exit 1 end server = Wamp::Router::Server.new(router, options) diff --git a/wamp.gemspec b/wamp.gemspec index b37a800..88d120d 100644 --- a/wamp.gemspec +++ b/wamp.gemspec @@ -3,7 +3,7 @@ require_relative "lib/wamp/version" Gem::Specification.new do |spec| - spec.name = "wamp" + spec.name = "xconn" spec.version = Wamp::VERSION spec.authors = ["Ismail Akram"] spec.email = ["rubyonrails3@gmail.com"] @@ -34,6 +34,7 @@ Gem::Specification.new do |spec| spec.add_dependency "ed25519", "~> 1.3" spec.add_dependency "msgpack", "~> 1.7.2" spec.add_dependency "nio4r", "~> 2.7" + spec.add_dependency "wampproto", "~> 0.1.1" spec.add_dependency "websocket-driver", "~> 0.7" spec.metadata["rubygems_mfa_required"] = "true" end