Sha256: 0257accee4a4ddb33b0df229c6fbb12bef16e2aef1e61a82419af0fc9a1b39af

Contents?: true

Size: 1.36 KB

Versions: 5

Compression:

Stored size: 1.36 KB

Contents

# frozen_string_literal: true

require 'cloudenvoy'

ENV['GOOGLE_AUTH_SUPPRESS_CREDENTIALS_WARNINGS'] ||= 'true'

namespace :cloudenvoy do
  desc 'Setup publishers and subscribers.'
  task setup: :environment do
    Rake::Task['cloudenvoy:setup_publishers'].invoke
    Rake::Task['cloudenvoy:setup_subscribers'].invoke
  end

  desc 'Create required subscriptions for all subcribers.'
  task setup_subscribers: :environment do
    # Force registration of subscribers
    Rails.application.eager_load!

    # Setup subscriptions
    list = Cloudenvoy.setup_subscribers.sort_by(&:name)

    puts "\n"

    # Notify user when no suscribers
    if list.empty?
      puts 'There are no subscribers defined in your application'
      return
    end

    puts 'The following subscribers are configured:'
    list.each do |e|
      puts "- #{e.name}"
    end

    puts "\n"
  end

  desc 'Create required topics for all publishers.'
  task setup_publishers: :environment do
    # Force registration of publishers
    Rails.application.eager_load!

    # Setup topics
    list = Cloudenvoy.setup_publishers.sort_by(&:name)

    puts "\n"

    # Notify user when no topics
    if list.empty?
      puts 'There are no publishers defined in your application'
      return
    end

    puts 'The following topics are configured:'
    list.each do |e|
      puts "- #{e.name}"
    end

    puts "\n"
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
cloudenvoy-0.4.0 lib/tasks/cloudenvoy.rake
cloudenvoy-0.3.1 lib/tasks/cloudenvoy.rake
cloudenvoy-0.3.0 lib/tasks/cloudenvoy.rake
cloudenvoy-0.2.0 lib/tasks/cloudenvoy.rake
cloudenvoy-0.1.0 lib/tasks/cloudenvoy.rake