Class: Fum::StageAnalyzer

Inherits:
Object
  • Object
show all
Includes:
DNS, Util
Defined in:
lib/fum/stage_analyzer.rb

Overview

Analyzes environments and DNS zone info to determine which environments belong to a particular stage and the status of each environment.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Util

#die

Methods included from DNS

#dns, #dns_names_equal, #ensure_trailing_dot, #find_records, #update_zone, #update_zones

Constructor Details

#initialize(stage_decl) ⇒ StageAnalyzer

Returns a new instance of StageAnalyzer.



13
14
15
16
17
# File 'lib/fum/stage_analyzer.rb', line 13

def initialize(stage_decl)
  @stage_decl = stage_decl
  @zones_map = {}
  @env_map = {}
end

Instance Attribute Details

#env_mapObject

Returns the value of attribute env_map.



11
12
13
# File 'lib/fum/stage_analyzer.rb', line 11

def env_map
  @env_map
end

#zones_mapObject

Returns the value of attribute zones_map.



11
12
13
# File 'lib/fum/stage_analyzer.rb', line 11

def zones_map
  @zones_map
end

Instance Method Details

#activeObject

Return the Active environment or nil



27
28
29
# File 'lib/fum/stage_analyzer.rb', line 27

def active
  @env_map.values.select { |e| e[:state] == :active }.map { |e| e[:env] }.shift
end

#analyze(options) ⇒ Object



19
20
21
22
23
24
# File 'lib/fum/stage_analyzer.rb', line 19

def analyze(options)
  beanstalk = Fog::AWS[:beanstalk]
  build_zone_map(@stage_decl.zones, options)
  analyze_zone_map(beanstalk.environments.select { |env| @stage_decl.matches?(env) }, options)
  @env_map
end

#inactiveObject

Return the inactive environments or empty array



32
33
34
# File 'lib/fum/stage_analyzer.rb', line 32

def inactive
  @env_map.values.select { |e| e[:state] == :inactive }.map { |e| e[:env] }
end