Sha256: 6c0231fc7208c9d5f7bde1457a3cb96de4835d3e5ec6c2dd7208f6ecfab3c492

Contents?: true

Size: 944 Bytes

Versions: 2

Compression:

Stored size: 944 Bytes

Contents

class NameGenerator
  def initialize(&cleanup_proc)
    @cleanup_proc = cleanup_proc
    @names = []
  end

  def name
    alpha = ("a".."z").to_a
    name = 10.times.map { alpha[Random.rand(alpha.size)]}.join
    @names << name
    name
  end

  def clean
    @names.reject! do |name|
      @cleanup_proc.call(name)
    end
  end
end

TableNameHelper = NameGenerator.new do |name|
  table = Azure::Tables::Table.new(name)
  Azure::Tables.delete(table)
end

ContainerNameHelper = NameGenerator.new do |name|
  container = Azure::Blobs::Container.new(name)
  container.delete
end

QueueNameHelper = NameGenerator.new do |name|
  queue = Azure::Queues::Queue.new(name)
  queue.delete
end

ServiceBusQueueNameHelper = NameGenerator.new do |name|
  queue = Azure::ServiceBus::Queues::Queue.new(name)
  queue.delete
end

ServiceBusTopicNameHelper = NameGenerator.new do |name|
  topic = Azure::ServiceBus::Topics::Topic.new(name)
  topic.delete
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
azure-0.1.1 test/support/table_names.rb
azure-0.1.0 test/support/table_names.rb