Class: Fum::StageAnalyzer
- Inherits:
-
Object
- Object
- Fum::StageAnalyzer
- 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
-
#env_map ⇒ Object
Returns the value of attribute env_map.
-
#zones_map ⇒ Object
Returns the value of attribute zones_map.
Instance Method Summary collapse
-
#active ⇒ Object
Return the Active environment or nil.
- #analyze(options) ⇒ Object
-
#inactive ⇒ Object
Return the inactive environments or empty array.
-
#initialize(stage_decl) ⇒ StageAnalyzer
constructor
A new instance of StageAnalyzer.
Methods included from Util
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_map ⇒ Object
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_map ⇒ Object
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
#active ⇒ Object
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() beanstalk = Fog::AWS[:beanstalk] build_zone_map(@stage_decl.zones, ) analyze_zone_map(beanstalk.environments.select { |env| @stage_decl.matches?(env) }, ) @env_map end |
#inactive ⇒ Object
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 |