Sha256: a444fc77a27222f232e1baa842b9dbab4df1ded669276be47305b8541fda589f

Contents?: true

Size: 1.32 KB

Versions: 24

Compression:

Stored size: 1.32 KB

Contents

# Author::    Eric Crane  (mailto:eric.crane@mac.com)
# Copyright:: Copyright (c) 2019 Eric Crane.  All rights reserved.
#
# Set the current context pointer.
# Alternatively if no value is provided, just show the context.
#

module Gloo
  module Verbs
    class Context < Gloo::Core::Verb

      KEYWORD = 'context'.freeze
      KEYWORD_SHORT = '@'.freeze

      #
      # Run the verb.
      #
      def run
        set_context if @tokens.token_count > 1
        show_context
      end

      #
      # Show the current context.
      #
      def show_context
        @engine.log.show "Context:  #{@engine.heap.context}"
      end

      #
      # Get the Verb's keyword.
      #
      def self.keyword
        return KEYWORD
      end

      #
      # Get the Verb's keyword shortcut.
      #
      def self.keyword_shortcut
        return KEYWORD_SHORT
      end

      # ---------------------------------------------------------------------
      #    Private functions
      # ---------------------------------------------------------------------

      private

      #
      # Set the context to the given path.
      #
      def set_context
        path = @tokens.second
        @engine.heap.context.set_to path
        @engine.heap.it.set_to path
        @engine.log.debug "Context set to #{@engine.heap.context}"
      end

    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
gloo-3.7.0 lib/gloo/verbs/context.rb
gloo-3.6.2 lib/gloo/verbs/context.rb
gloo-3.6.1 lib/gloo/verbs/context.rb
gloo-3.6.0 lib/gloo/verbs/context.rb
gloo-3.5.0 lib/gloo/verbs/context.rb
gloo-3.4.1 lib/gloo/verbs/context.rb
gloo-3.4.0 lib/gloo/verbs/context.rb
gloo-3.3.0 lib/gloo/verbs/context.rb
gloo-3.2.0 lib/gloo/verbs/context.rb
gloo-3.1.1 lib/gloo/verbs/context.rb
gloo-3.1.0 lib/gloo/verbs/context.rb
gloo-3.0.1 lib/gloo/verbs/context.rb
gloo-3.0.0 lib/gloo/verbs/context.rb
gloo-2.5.0 lib/gloo/verbs/context.rb
gloo-2.4.3 lib/gloo/verbs/context.rb
gloo-2.4.2 lib/gloo/verbs/context.rb
gloo-2.4.1 lib/gloo/verbs/context.rb
gloo-2.4.0 lib/gloo/verbs/context.rb
gloo-2.3.1 lib/gloo/verbs/context.rb
gloo-2.2.0 lib/gloo/verbs/context.rb