Sha256: ec6707f2c8734af0369ad7bc70b93aaf8e1768d41ac10a7bef1a843421081765

Contents?: true

Size: 1.61 KB

Versions: 25

Compression:

Stored size: 1.61 KB

Contents

require "rails/generators"

module CanvasSync
  class InstallLiveEventsGenerator < Rails::Generators::Base
    source_root File.expand_path("../templates/services/live_events", __FILE__)
    class_option :events, type: :string, required: true

    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

    # 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
    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
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
canvas_sync-0.22.9 lib/canvas_sync/generators/install_live_events_generator.rb
canvas_sync-0.22.8 lib/canvas_sync/generators/install_live_events_generator.rb
canvas_sync-0.22.6 lib/canvas_sync/generators/install_live_events_generator.rb
canvas_sync-0.22.5 lib/canvas_sync/generators/install_live_events_generator.rb
canvas_sync-0.22.4 lib/canvas_sync/generators/install_live_events_generator.rb
canvas_sync-0.22.3 lib/canvas_sync/generators/install_live_events_generator.rb
canvas_sync-0.22.2 lib/canvas_sync/generators/install_live_events_generator.rb
canvas_sync-0.22.1 lib/canvas_sync/generators/install_live_events_generator.rb
canvas_sync-0.22.0 lib/canvas_sync/generators/install_live_events_generator.rb
canvas_sync-0.22.0.beta8 lib/canvas_sync/generators/install_live_events_generator.rb
canvas_sync-0.22.0.beta7 lib/canvas_sync/generators/install_live_events_generator.rb
canvas_sync-0.22.0.beta6 lib/canvas_sync/generators/install_live_events_generator.rb
canvas_sync-0.22.0.beta5 lib/canvas_sync/generators/install_live_events_generator.rb
canvas_sync-0.22.0.beta4 lib/canvas_sync/generators/install_live_events_generator.rb
canvas_sync-0.22.0.beta3 lib/canvas_sync/generators/install_live_events_generator.rb
canvas_sync-0.22.0.beta2 lib/canvas_sync/generators/install_live_events_generator.rb
canvas_sync-0.22.0.beta1 lib/canvas_sync/generators/install_live_events_generator.rb
canvas_sync-0.21.1 lib/canvas_sync/generators/install_live_events_generator.rb
canvas_sync-0.21.1.beta1 lib/canvas_sync/generators/install_live_events_generator.rb
canvas_sync-0.21.0 lib/canvas_sync/generators/install_live_events_generator.rb