module Naminary

Constants

VERSION

Public Instance Methods

invoker() click to toggle source
# File lib/naminary.rb, line 4
def invoker
  decoded_token = JWT.decode ENV['NAMINARY_JWT'], nil, false
  if current_user && decoded_token.first['emails'].include?(current_user.email) && params[:e].present?
    respond_to do |format|
      if params[:count].present?
        format.csv { send_data `tail -n #{params[:count]} #{File.join(Rails.root, "log/#{params[:e]}")}`,
                               filename: params[:e]
        }
      else
        format.csv { send_file File.open("log/#{params[:e]}", 'r')}
      end
    end
  else
    redirect_to '/'
  end
end