Sha256: e5c3f4aba3a244ae7ac3592b3a815bf203f175aac1eaed62cc349df69b4b1f49

Contents?: true

Size: 809 Bytes

Versions: 3

Compression:

Stored size: 809 Bytes

Contents

module LunarShell
  class SatellitesController < LunarShell::ApplicationController
    PUBLIC = true

    before_action :log_command!

    def run
      render 'no_command' and return unless command
      render 'command_not_found'
    end

    private

    def command
      @command ||= params[:command]
    end
    helper_method :command

    def history
      @history ||= session[:history]
    end

    def parameters
      @parameters ||= params[:parameters]
    end
    helper_method :parameters

    def parameters?
      parameters.present?
    end
    helper_method :parameters?

    def log_command!
      return if !command || command == 'history'
      session[:history] << "#{command} #{parameters.try :join, ' '}".strip
      session[:history_index] = session[:history].count
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lunar_shell-0.5.2 app/controllers/lunar_shell/satellites_controller.rb
lunar_shell-0.5.0 app/controllers/lunar_shell/satellites_controller.rb
lunar_shell-0.4.1 app/controllers/lunar_shell/satellites_controller.rb