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 <<~NEXT

    Next steps:

      1. Authorize document access: implement `authorized?` in
         app/channels/document_channel.rb (it denies everyone until you do).
      2. bin/rails db:migrate
      3. Install the yrby-client npm package and connect an editor:

           import { ActionCableProvider } from "yrby-client"
           const provider = new ActionCableProvider(doc, consumer,
             "DocumentChannel", { id: documentId })
           provider.connect()

    The README's Editors section links working integrations for
    Tiptap, Lexxy, Rhino Editor, and CodeMirror.
  NEXT
end