Class: Fum::Lang::Stage

Inherits:
Object
  • Object
show all
Defined in:
lib/fum/lang/stage.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, &block) ⇒ Stage

Returns a new instance of Stage.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/fum/lang/stage.rb', line 10

def initialize(id, &block)
  @zones = []
  @environment_name = id.to_s
  @id = id.to_s
  @swap_cnames = false

  if block_given?
    if block.arity == 1
      yield self
    else
      instance_eval &block
    end
  end
end

Instance Attribute Details

#env_descriptionObject

Returns the value of attribute env_description.



8
9
10
# File 'lib/fum/lang/stage.rb', line 8

def env_description
  @env_description
end

#environment_nameObject

Returns the value of attribute environment_name.



7
8
9
# File 'lib/fum/lang/stage.rb', line 7

def environment_name
  @environment_name
end

#idObject

Returns the value of attribute id.



7
8
9
# File 'lib/fum/lang/stage.rb', line 7

def id
  @id
end

#solution_stack_nameObject

Returns the value of attribute solution_stack_name.



7
8
9
# File 'lib/fum/lang/stage.rb', line 7

def solution_stack_name
  @solution_stack_name
end

#swap_cnamesObject

Returns the value of attribute swap_cnames.



7
8
9
# File 'lib/fum/lang/stage.rb', line 7

def swap_cnames
  @swap_cnames
end

#template_nameObject

Returns the value of attribute template_name.



7
8
9
# File 'lib/fum/lang/stage.rb', line 7

def template_name
  @template_name
end

#version_labelObject

Returns the value of attribute version_label.



7
8
9
# File 'lib/fum/lang/stage.rb', line 7

def version_label
  @version_label
end

#zonesObject

Returns the value of attribute zones.



7
8
9
# File 'lib/fum/lang/stage.rb', line 7

def zones
  @zones
end

Instance Method Details

#cname_prefix(name, opts = {}) ⇒ Object



63
64
65
66
67
68
# File 'lib/fum/lang/stage.rb', line 63

def cname_prefix(name, opts = {})
  @cname_prefix = name
  if opts[:swap]
    @swap_cnames = true
  end
end

#description(value) ⇒ Object



55
56
57
# File 'lib/fum/lang/stage.rb', line 55

def description(value)
  @env_description = value
end

#matcher(arg) ⇒ Object



47
48
49
# File 'lib/fum/lang/stage.rb', line 47

def matcher(arg)
  @matcher = arg
end

#matches?(env) ⇒ Boolean

Returns true if environment matches the matcher for this stage

Returns:

  • (Boolean)


71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/fum/lang/stage.rb', line 71

def matches?(env)
  if @matcher
    if @matcher.is_a?(Regexp)
      return env.name =~ @matcher
    else
      return env.name == @matcher
    end
  else
    return env.name == @environment_name
  end
  false
end

#name(arg) ⇒ Object



43
44
45
# File 'lib/fum/lang/stage.rb', line 43

def name(arg)
  @environment_name = arg
end

#solution_stack(name, &block) ⇒ Object



59
60
61
# File 'lib/fum/lang/stage.rb', line 59

def solution_stack(name, &block)
  @solution_stack_name = name
end

#template(arg, &block) ⇒ Object



39
40
41
# File 'lib/fum/lang/stage.rb', line 39

def template(arg, &block)
  @template_name = arg
end

#timestamp_name(prefix) ⇒ Object

Raises:

  • (ArgumentError)


25
26
27
28
# File 'lib/fum/lang/stage.rb', line 25

def timestamp_name(prefix)
  raise ArgumentError, "Prefix must be less than 15" unless prefix.length < 15 && prefix.length > 1
  return "#{prefix}-#{Time.now.to_i.to_s(16)}"
end

#timestamp_name_matcher(prefix) ⇒ Object

Raises:

  • (ArgumentError)


30
31
32
33
# File 'lib/fum/lang/stage.rb', line 30

def timestamp_name_matcher(prefix)
  raise ArgumentError, "Prefix must be less than 15" unless prefix.length < 15 && prefix.length > 1
  /#{prefix}-[a-z0-9]{8}/
end

#version(arg) ⇒ Object



51
52
53
# File 'lib/fum/lang/stage.rb', line 51

def version(arg)
  @version_label = arg
end

#zone(*args, &block) ⇒ Object



35
36
37
# File 'lib/fum/lang/stage.rb', line 35

def zone(*args, &block)
  @zones << Zone.new(*args, &block)
end