Class: CanvasSync::InstallLiveEventsGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/canvas_sync/generators/install_live_events_generator.rb

Instance Method Summary collapse

Instance Method Details

#autogenerated_event_warningObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/canvas_sync/generators/install_live_events_generator.rb', line 8

def autogenerated_event_warning
  <<-HERE.strip_heredoc
    #
    # AUTO GENERATED LIVE EVENT
    # This was auto generated by the CanvasSync Gem.
    # You can customize it as needed, but make sure you test
    # any changes you make to the auto generated methods.
    #
    # LiveEvent message formats can be found at https://canvas.instructure.com/doc/api/file.live_events.html
    # In the general case, LiveEvent message content should not be trusted - it is highly possible that events may
    # arrive out of order. Most of the CanvasSync LiveEvent templates solve this by always fetching the object from the API.
    #
  HERE
end

#generate_live_eventsObject

Generates the specified live events. Invoke with:

bin/rails generate canvas_sync:install_live_events –events users,courses

Install all live events with:

bin/rails generate canvas_sync:install_live_events –events all



30
31
32
33
34
35
36
37
38
39
# File 'lib/canvas_sync/generators/install_live_events_generator.rb', line 30

def generate_live_events
  events = options["events"] == "all" ? CanvasSync::SUPPORTED_LIVE_EVENTS : options["events"].split(",")
  CanvasSync.validate_live_events!(events)

  events.each do |event|
    Dir.glob("#{File.dirname(__FILE__)}/templates/services/live_events/#{event}_event.rb") do |rb_file|
      template rb_file.to_s, "app/services/live_events/#{File.basename(rb_file)}"
    end
  end
end