Sha256: 441a83ffca9e889b67ccddf9a2c2cd2fc37ba7d6217781a989da410a1db87cd3

Contents?: true

Size: 831 Bytes

Versions: 1

Compression:

Stored size: 831 Bytes

Contents

module RabbitMQ::Definition
  class Create < Command
    def initialize(client, verbose, vhosts)
      super(client, verbose)
      @vhosts = (vhosts || []).compact
      if @vhosts.empty?
        @vhosts = ask("-> What vhosts do you want to create? (comma separated list)".yellow, lambda { |str| str.split(/,\s*/) })
      end
    end

    def execute
      if FileDefinition.exists?
        Logger.error "Definition file already exists in #{FileDefinition.file_path}"
      else
        @vhosts.each do |vhost|
          Logger.progress "Creating vhost '#{vhost}'" if verbose
          client.create_vhost(vhost)
          Logger.progress "Adding permissions for '#{user}' to vhost '#{vhost}'" if verbose
          add_permissions_for_vhost(vhost)
        end
        Dump.run(client, false, @vhosts)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rabbitmq-definition-0.1.3 lib/rabbitmq_definition/create.rb