Class: Roadworker::Client

Inherits:
Object
  • Object
show all
Includes:
Log
Defined in:
lib/roadworker/client.rb

Instance Method Summary collapse

Methods included from Log

#log

Constructor Details

#initialize(options) ⇒ Client

Returns a new instance of Client.



13
14
15
16
17
18
19
# File 'lib/roadworker/client.rb', line 13

def initialize(options)
  @options = OpenStruct.new(options)
  @options.logger ||= Logger.new($stdout)
  String.colorize = @options.color
  @options.route53 = AWS::Route53.new
  @route53 = Route53Wrapper.new(@options)
end

Instance Method Details

#apply(file) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/roadworker/client.rb', line 21

def apply(file)
  dsl = nil

  if file.kind_of?(String)
    open(file) do |f|
      dsl = DSL.define(f.read, file).result
    end
  else
    dsl = DSL.define(file.read, file.path).result
  end

  updated = false

  if dsl.hosted_zones.empty? and not @options.force
    log(:warn, "Nothing is defined (pass `--force` if you want to remove)", :yellow)
  else
    AWS.memoize {
      walk_hosted_zones(dsl)
      updated = @options.updated
    }
  end

  return updated
end

#exportObject



46
47
48
49
# File 'lib/roadworker/client.rb', line 46

def export
  exported = AWS.memoize { @route53.export }
  DSL.convert(exported)
end