class Bcome::Bootup
Attributes
arguments[R]
Public Class Methods
set_and_do(params, spawn_into_console = true)
click to toggle source
# File lib/objects/bootup.rb, line 5 def self.set_and_do(params, spawn_into_console = true) instance.set(params, spawn_into_console) instance.do end
traverse(breadcrumbs = nil, _spawn_into_console = false)
click to toggle source
# File lib/objects/bootup.rb, line 10 def self.traverse(breadcrumbs = nil, _spawn_into_console = false) spawn_into_console = false ::Bcome::Bootup.set_and_do({ breadcrumbs: breadcrumbs }, spawn_into_console) end
Public Instance Methods
close_ssh_connections()
click to toggle source
# File lib/objects/bootup.rb, line 70 def close_ssh_connections return unless estate_loaded? estate.close_ssh_connections end
crumbs()
click to toggle source
# File lib/objects/bootup.rb, line 80 def crumbs parser.crumbs end
do()
click to toggle source
# File lib/objects/bootup.rb, line 25 def do context = crumbs.empty? ? init_context(estate) : traverse(estate) context end
estate()
click to toggle source
# File lib/objects/bootup.rb, line 62 def estate @estate ||= ::Bcome::Node::Factory.instance.init_tree end
estate_loaded?()
click to toggle source
# File lib/objects/bootup.rb, line 66 def estate_loaded? !@estate.nil? end
init_context(context)
click to toggle source
# File lib/objects/bootup.rb, line 30 def init_context(context) if @spawn_into_console ::Bcome::Workspace.instance.set(context: context, show_welcome: true) else context end end
parser()
click to toggle source
# File lib/objects/bootup.rb, line 76 def parser ::Bcome::Parser::BreadCrumb.new(@breadcrumbs) end
set(params, spawn_into_console = false)
click to toggle source
# File lib/objects/bootup.rb, line 19 def set(params, spawn_into_console = false) @breadcrumbs = params[:breadcrumbs] @arguments = params[:arguments] @spawn_into_console = spawn_into_console end
traverse(_starting_context)
click to toggle source
# File lib/objects/bootup.rb, line 38 def traverse(_starting_context) starting_context = estate crumbs.each_with_index do |crumb, _index| # Some contexts' resources are loaded dynamically and do not come from the estate config. As we're traversing, we'll need to load # them if necessary starting_context.load_nodes if starting_context.inventory? && !starting_context.nodes_loaded? # Attempt to load our next context resource next_context = starting_context.resources.active.first if crumb == 'first' next_context ||= starting_context.resource_for_identifier(crumb) # Our current breadcrumb is not a node, and so we'll attempt to invoke a method call on the previous # e.g. given resource:foo, then invoke 'foo' on 'resource' unless next_context puts "\n" # clean any trailing loading bars starting_context.invoke(crumb, @arguments) return end starting_context = next_context end # Set our workspace to our last context - we're not invoking a method call and so we're entering a console session init_context(starting_context) end
Private Instance Methods
teardown!()
click to toggle source
# File lib/objects/bootup.rb, line 86 def teardown! @estate = nil end