Class: Heirloom::Verifier

Inherits:
Object
  • Object
show all
Defined in:
lib/heirloom/archive/verifier.rb

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Verifier

Returns a new instance of Verifier.



5
6
7
8
9
# File 'lib/heirloom/archive/verifier.rb', line 5

def initialize(args)
  @config = args[:config]
  @name = args[:name]
  @logger = @config.logger
end

Instance Method Details

#bucket_exists?(args) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/heirloom/archive/verifier.rb', line 26

def bucket_exists?(args)
  bucket_prefix = args[:bucket_prefix]
  region = args[:region]

  bucket = "#{bucket_prefix}-#{region}"
  
  s3 ||= AWS::S3.new :config => @config,
                     :region => region

  if s3.get_bucket bucket
    @logger.debug "Bucket '#{bucket}' exists in '#{region}'."
    true
  else
    @logger.debug "Bucket '#{bucket}' does not exist in '#{region}'."
    false
  end
end

#buckets_exist?(args) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/heirloom/archive/verifier.rb', line 11

def buckets_exist?(args)
  bucket_prefix = args[:bucket_prefix]
  regions = args[:regions]
  result = true

  regions.each do |region|
    unless bucket_exists? :region        => region,
                          :bucket_prefix => bucket_prefix
      result = false
    end
  end

  result
end

#domain_exists?Boolean

Returns:

  • (Boolean)


44
45
46
47
48
49
50
51
52
53
54
# File 'lib/heirloom/archive/verifier.rb', line 44

def domain_exists?
  domain = "heirloom_#{@name}"
  region = @config.
  if sdb.domain_exists? domain
    @logger.debug "Domain '#{@name}' exists in '#{region}'."
    true
  else
    @logger.debug "Domain '#{@name}' does not exist in '#{region}'."
    false
  end
end