Class: Humidifier::Directory

Inherits:
Object
  • Object
show all
Defined in:
lib/humidifier/directory.rb

Overview

Represents a directory on the filesystem containing YAML files that correspond to resources belonging to a stack. Contains all of the logic for interfacing with humidifier to deploy stacks, validate them, display them.

Defined Under Namespace

Classes: Export

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, pattern: nil, prefix: nil) ⇒ Directory

Returns a new instance of Directory.



23
24
25
26
27
28
29
# File 'lib/humidifier/directory.rb', line 23

def initialize(name, pattern: nil, prefix: nil)
  @name       = name
  @pattern    = pattern
  @prefix     = prefix
  @exports    = []
  @stack_name = "#{prefix || Humidifier.config.stack_prefix}#{name}"
end

Instance Attribute Details

#exportsObject (readonly)

Returns the value of attribute exports.



21
22
23
# File 'lib/humidifier/directory.rb', line 21

def exports
  @exports
end

#nameObject (readonly)

Returns the value of attribute name.



21
22
23
# File 'lib/humidifier/directory.rb', line 21

def name
  @name
end

#patternObject (readonly)

Returns the value of attribute pattern.



21
22
23
# File 'lib/humidifier/directory.rb', line 21

def pattern
  @pattern
end

#prefixObject (readonly)

Returns the value of attribute prefix.



21
22
23
# File 'lib/humidifier/directory.rb', line 21

def prefix
  @prefix
end

#stack_nameObject (readonly)

Returns the value of attribute stack_name.



21
22
23
# File 'lib/humidifier/directory.rb', line 21

def stack_name
  @stack_name
end

Instance Method Details

#create_change_setObject



31
32
33
34
35
36
37
# File 'lib/humidifier/directory.rb', line 31

def create_change_set
  return unless valid?

  stack.create_change_set(
    capabilities: %w[CAPABILITY_IAM CAPABILITY_NAMED_IAM]
  )
end

#deploy(wait = false, parameter_values = {}) ⇒ Object



39
40
41
42
43
44
45
46
47
# File 'lib/humidifier/directory.rb', line 39

def deploy(wait = false, parameter_values = {})
  return unless valid?

  stack.public_send(
    wait ? :deploy_and_wait : :deploy,
    capabilities: %w[CAPABILITY_IAM CAPABILITY_NAMED_IAM],
    parameters: parameter_values
  )
end

#to_cfObject



49
50
51
# File 'lib/humidifier/directory.rb', line 49

def to_cf
  stack.to_cf
end

#uploadObject



53
54
55
# File 'lib/humidifier/directory.rb', line 53

def upload
  stack.upload if valid?
end

#valid?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/humidifier/directory.rb', line 57

def valid?
  stack.valid?
end