Class: Bcome::Stack::Platform

Inherits:
Base show all
Includes:
BecomeObject
Defined in:
lib/stack/platform.rb

Constant Summary

Constants included from BecomeObject

BecomeObject::CONFIGS_PATH

Constants included from Orchestrator::Registry

Orchestrator::Registry::CONFIGS_PATH

Constants included from ContextFunctions

ContextFunctions::CONFIGS_PATH

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from BecomeObject

#all_items, #become_identifier, #context_breadcrumb, #do_load_resources, #has_main_context?, #has_potential_resources?, #identifier_for, #is_stack_level_resource?, #list, #local_download_path, #main_context, #main_context=, #mini_list, #namespace, #previous_workspace_object, #previous_workspace_object=, #resource_for_identifier, #resource_identifiers, #resources, #responds_to_list?

Methods inherited from Base

#available_resources_options_string, #become, #become_identifier, const_missing, #construct_node, #describe, #has_sub_nodes?, #highlight?, #init, #interactive, #machines, #menu, #method_missing, #node, #recipes, #respond_to_bcome_context_method?, #workon

Methods included from Orchestrator::Registry

#config_for_registry, #do_load_recipes, #has_registry_config?, #load_recipe_registry, #recipe_registry, #registry_configs_path

Methods included from CommandHelper

#run_local

Methods included from ContextFunctions

#command_for_context, #context_cmd_config_path, #context_cmd_functions, #context_commands, #execute_command_for_context, #has_context_cmd_functions?, #has_context_functions_config?, #load_context_cmd_functions

Constructor Details

#initialize(identifier, meta_data) ⇒ Platform

Returns a new instance of Platform.



19
20
21
22
23
# File 'lib/stack/platform.rb', line 19

def initialize(identifier, )
  @identifier = identifier
  @meta_data = 
  @quick_contexts = @meta_data[:quick_contexts]
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Bcome::Stack::Base

Instance Attribute Details

#identifierObject (readonly)

Returns the value of attribute identifier.



17
18
19
# File 'lib/stack/platform.rb', line 17

def identifier
  @identifier
end

#meta_dataObject (readonly)

Returns the value of attribute meta_data.



17
18
19
# File 'lib/stack/platform.rb', line 17

def 
  @meta_data
end

#quick_contextsObject (readonly)

Returns the value of attribute quick_contexts.



17
18
19
# File 'lib/stack/platform.rb', line 17

def quick_contexts
  @quick_contexts
end

Class Method Details

.collection_from_config(parent, configuration) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/stack/platform.rb', line 7

def collection_from_config(parent, configuration)
  return unless configuration
  collection = []
  configuration.each do |conf_data|
    collection << new(conf_data[:name], conf_data)
  end
  return collection
end

Instance Method Details

#child_reference_keyObject



50
51
52
# File 'lib/stack/platform.rb', line 50

def child_reference_key
  :platform
end

#collection_keyObject



54
55
56
# File 'lib/stack/platform.rb', line 54

def collection_key
  :environments
end

#collection_klassObject



42
43
44
# File 'lib/stack/platform.rb', line 42

def collection_klass
  ::ENV_STACK_KLASS
end

#config_pathObject



38
39
40
# File 'lib/stack/platform.rb', line 38

def config_path
  "#{CONFIGS_PATH}/network.yml"
end

#do_describeObject



29
30
31
32
33
34
35
36
# File 'lib/stack/platform.rb', line 29

def do_describe
  description = "\tPlatform Name:".menu_item_cyan + "\s#{identifier.menu_item_green}\n"
  description += "\t" + "Description:".menu_item_cyan + "\s#{@meta_data[:description].menu_item_white}" + "\n"
  description += "\t" + "Location:".menu_item_magenta + "\s#{@meta_data[:location].menu_item_white}" + "\n" if @meta_data[:location]
  description += "\n"

  return description
end

#has_quick_contexts?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/stack/platform.rb', line 58

def has_quick_contexts?
  return !quick_contexts.nil?
end


25
26
27
# File 'lib/stack/platform.rb', line 25

def menu_items
  super
end

#node_level_klassObject



69
70
71
# File 'lib/stack/platform.rb', line 69

def node_level_klass
  ::Bcome::Node::Platform
end

#quick_context_for_reference(context_reference) ⇒ Object



62
63
64
65
66
67
# File 'lib/stack/platform.rb', line 62

def quick_context_for_reference(context_reference)
  return nil unless has_quick_contexts?
  matches = quick_contexts.select{|qc| qc[:ref] == context_reference }
  raise "Multiple quick context matches found on platform #{@identifier} for context key #{context_reference}. Cannot load quick context - selection is ambiguous." if matches.size > 1
  return matches.first 
end

#reference_keyObject



46
47
48
# File 'lib/stack/platform.rb', line 46

def reference_key
  :platforms
end