module Archer
Constants
- VERSION
Public Class Methods
clear()
click to toggle source
# File lib/archer.rb, line 24 def self.clear quietly do Archer::History.where(user: user).delete_all end Readline::HISTORY.clear if defined?(Readline) Reline::HISTORY.clear if defined?(Reline) true end
history_object()
click to toggle source
private TODO use IRB.CurrentContext.io.class::HISTORY
# File lib/archer.rb, line 61 def self.history_object reline? ? Reline::HISTORY : Readline::HISTORY end
quietly() { || ... }
click to toggle source
private
# File lib/archer.rb, line 73 def self.quietly ActiveRecord::Base.logger.silence do yield end end
reline?()
click to toggle source
private
# File lib/archer.rb, line 66 def self.reline? IRB.CurrentContext.io.is_a?(IRB::ReidlineInputMethod) rescue false end
save()
click to toggle source
# File lib/archer.rb, line 49 def self.save quietly do history = Archer::History.where(user: user).first_or_initialize history.commands = history_object.to_a.last(limit).join("\n") history.save! end rescue ActiveRecord::StatementInvalid warn "[archer] Unable to save history" end
start()
click to toggle source
# File lib/archer.rb, line 33 def self.start history = nil begin quietly do history = Archer::History.find_by(user: user) end rescue ActiveRecord::StatementInvalid warn "[archer] Create table to enable history" end if history commands = history.commands.split("\n") history_object.push(*commands) end end