Class: Yrby::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/yrby/install/install_generator.rb

Overview

bin/rails generate yrby:install — a DocumentChannel speaking the y-websocket protocol over the gem's document storage, plus the storage migration (via yrby:tables). The models ship in the gem; only the migration lands in the app.

Instance Method Summary collapse

Instance Method Details

#create_channelObject



15
16
17
# File 'lib/generators/yrby/install/install_generator.rb', line 15

def create_channel
  template "document_channel.rb", "app/channels/document_channel.rb"
end

#create_tablesObject



19
20
21
# File 'lib/generators/yrby/install/install_generator.rb', line 19

def create_tables
  invoke "yrby:tables"
end

#show_next_stepsObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/generators/yrby/install/install_generator.rb', line 23

def show_next_steps
  say "\n    Next steps:\n\n      1. Authorize document access: implement `authorized?` in\n         app/channels/document_channel.rb (it denies everyone until you do).\n      2. bin/rails db:migrate\n      3. Install the yrby-client npm package and connect an editor:\n\n           import { ActionCableProvider } from \"yrby-client\"\n           const provider = new ActionCableProvider(doc, consumer,\n             \"DocumentChannel\", { id: documentId })\n           provider.connect()\n\n    The README's Editors section links working integrations for\n    Tiptap, Lexxy, Rhino Editor, and CodeMirror.\n  NEXT\nend\n"