Sha256: e7b54629fee537f09f8165eb6d7a235d6ab8fddb4993077b0686810b20e26d52

Contents?: true

Size: 1.31 KB

Versions: 38

Compression:

Stored size: 1.31 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.
        #
      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}/*.rb") do |rb_file|
          template rb_file.to_s, "app/services/live_events/#{File.basename(rb_file)}"
        end
      end
      template "base_event.rb", "app/services/live_events/base_event.rb"
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
canvas_sync-0.10.2 lib/canvas_sync/generators/install_live_events_generator.rb
canvas_sync-0.10.0 lib/canvas_sync/generators/install_live_events_generator.rb
canvas_sync-0.9.4 lib/canvas_sync/generators/install_live_events_generator.rb
canvas_sync-0.9.3 lib/canvas_sync/generators/install_live_events_generator.rb
canvas_sync-0.9.2 lib/canvas_sync/generators/install_live_events_generator.rb
canvas_sync-0.9.1 lib/canvas_sync/generators/install_live_events_generator.rb
canvas_sync-0.9.0 lib/canvas_sync/generators/install_live_events_generator.rb
canvas_sync-0.8.4 lib/canvas_sync/generators/install_live_events_generator.rb
canvas_sync-0.8.3 lib/canvas_sync/generators/install_live_events_generator.rb
canvas_sync-0.8.2 lib/canvas_sync/generators/install_live_events_generator.rb
canvas_sync-0.8.1 lib/canvas_sync/generators/install_live_events_generator.rb
canvas_sync-0.8.0 lib/canvas_sync/generators/install_live_events_generator.rb
canvas_sync-0.7.3 lib/canvas_sync/generators/install_live_events_generator.rb
canvas_sync-0.7.2 lib/canvas_sync/generators/install_live_events_generator.rb
canvas_sync-0.7.1 lib/canvas_sync/generators/install_live_events_generator.rb
canvas_sync-0.7.0 lib/canvas_sync/generators/install_live_events_generator.rb
canvas_sync-0.6.4 lib/canvas_sync/generators/install_live_events_generator.rb
canvas_sync-0.6.3 lib/canvas_sync/generators/install_live_events_generator.rb
canvas_sync-0.6.2 lib/canvas_sync/generators/install_live_events_generator.rb
canvas_sync-0.6.1 lib/canvas_sync/generators/install_live_events_generator.rb