From 3416313ffa7befddfba0ef5fa3b3f199b1e3e238 Mon Sep 17 00:00:00 2001 From: Joshua Sierles Date: Sun, 29 Aug 2021 21:54:20 +0200 Subject: [PATCH 1/3] Rename gem to 'livekit' since the -ruby extension is redundant in the absence of other Rubygems built for Livekit --- Gemfile.lock | 5 ++--- README.md | 14 +++++--------- lib/livekit.rb | 2 +- livekit_ruby.gemspec => livekit.gemspec | 2 +- 4 files changed, 9 insertions(+), 14 deletions(-) rename livekit_ruby.gemspec => livekit.gemspec (97%) diff --git a/Gemfile.lock b/Gemfile.lock index 0c1ba6f..f0a3e3a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - livekit-ruby (0.1.0) + livekit (0.1.0) jwt (~> 2.2.3) twirp (~> 1.7.2) @@ -31,7 +31,6 @@ GEM faraday-patron (1.0.0) faraday-rack (1.0.0) google-protobuf (3.17.3) - google-protobuf (3.17.3-x86_64-linux) jwt (2.2.3) method_source (1.0.0) multipart-post (2.1.1) @@ -90,7 +89,7 @@ PLATFORMS x86_64-linux DEPENDENCIES - livekit-ruby! + livekit! pry pry-doc rake diff --git a/README.md b/README.md index bd3c427..e337f71 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ TODO: Delete this and the text above, and describe your gem Add this line to your application's Gemfile: ```ruby -gem 'livekit-ruby' +gem 'livekit' ``` And then execute: @@ -20,7 +20,7 @@ And then execute: Or install it yourself as: - $ gem install livekit-ruby + $ gem install livekit ## Usage @@ -28,18 +28,14 @@ TODO: Write usage instructions here ## Development -After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. +After checking out the repo, run `bundle install` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org). ## Contributing -Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/livekit-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/livekit-ruby/blob/master/CODE_OF_CONDUCT.md). +Bug reports and pull requests are welcome on GitHub at https://github.com/livekit/livekit. ## License -The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT). - -## Code of Conduct - -Everyone interacting in the Livekit::Ruby project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/livekit-ruby/blob/master/CODE_OF_CONDUCT.md). +The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT). \ No newline at end of file diff --git a/lib/livekit.rb b/lib/livekit.rb index cde26bc..9435acf 100644 --- a/lib/livekit.rb +++ b/lib/livekit.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true require 'livekit/version' -require 'livekit/access_token' module Livekit autoload(:Proto, File.expand_path('livekit/proto.rb', __dir__)) + autoload(:AccessToken, File.expand_path('livekit/access_token.rb', __dir__)) end diff --git a/livekit_ruby.gemspec b/livekit.gemspec similarity index 97% rename from livekit_ruby.gemspec rename to livekit.gemspec index 67d6929..9a18269 100644 --- a/livekit_ruby.gemspec +++ b/livekit.gemspec @@ -3,7 +3,7 @@ require_relative 'lib/livekit/version' Gem::Specification.new do |spec| - spec.name = 'livekit-ruby' + spec.name = 'livekit' spec.version = Livekit::VERSION spec.authors = ['Omri Gabay'] spec.email = ['omri@omrigabay.me'] From add5d859ddae4d4da1019e7471135e583628ce18 Mon Sep 17 00:00:00 2001 From: Joshua Sierles Date: Sun, 29 Aug 2021 23:28:14 +0200 Subject: [PATCH 2/3] remove unused directory --- protocol | 1 - 1 file changed, 1 deletion(-) delete mode 160000 protocol diff --git a/protocol b/protocol deleted file mode 160000 index 031bb23..0000000 --- a/protocol +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 031bb23807408312d718c1426148148d36a3dde0 From f12f43af9d5a869f77e089eb964d448a917d38b4 Mon Sep 17 00:00:00 2001 From: Joshua Sierles Date: Mon, 30 Aug 2021 00:28:59 +0200 Subject: [PATCH 3/3] Initial attempt to encapsulate protocol methods in a single wrapper class --- lib/livekit.rb | 17 +++++++++++++++++ lib/livekit/proto.rb | 6 +++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/lib/livekit.rb b/lib/livekit.rb index 9435acf..af3f649 100644 --- a/lib/livekit.rb +++ b/lib/livekit.rb @@ -5,4 +5,21 @@ module Livekit autoload(:Proto, File.expand_path('livekit/proto.rb', __dir__)) autoload(:AccessToken, File.expand_path('livekit/access_token.rb', __dir__)) + + Proto.initialize_proto! + + class Client + extend Forwardable + + room_methods = (Proto::RoomServiceClient.instance_methods - public_methods) - [:rpc] + delegate room_methods => :@client + + def initialize(url) + conn = Faraday.new(url: url) do |c| + c.request :authorization, 'Bearer', LiveKit::AccessToken.new + end + + @client = Proto::RoomServiceClient.new(conn) + end + end end diff --git a/lib/livekit/proto.rb b/lib/livekit/proto.rb index e164138..7eb8863 100644 --- a/lib/livekit/proto.rb +++ b/lib/livekit/proto.rb @@ -2,11 +2,11 @@ module Livekit module Proto - FOLDER = Pathname.new(File.expand_path('lib/livekit/proto')) + PATH = Pathname.new(File.expand_path(__dir__ + '/proto')) def self.initialize_proto! - $LOAD_PATH.unshift(FOLDER) - FOLDER.children.sort.each { |proto_file| require proto_file } + $LOAD_PATH.unshift(PATH) + PATH.children.sort.each { |proto_file| require proto_file } end end end