Module: Archer
- Defined in:
- lib/archer.rb,
lib/archer/irb.rb,
lib/archer/coder.rb,
lib/archer/engine.rb,
lib/archer/history.rb,
lib/archer/version.rb,
lib/generators/archer/install_generator.rb
Defined Under Namespace
Modules: Coder, Generators, Irb
Classes: Engine, History
Constant Summary
collapse
- VERSION =
"1.1.0"
Class Method Summary
collapse
Class Method Details
.clear ⇒ Object
66
67
68
69
70
71
72
|
# File 'lib/archer.rb', line 66
def clear
quietly do
Archer::History.where(user: user).delete_all
end
history_object.clear if history_object
true
end
|
.save ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/archer.rb', line 53
def save
return false unless history_object
quietly do
history = Archer::History.where(user: user).first_or_initialize
history.commands = history_object.to_a.last(limit)
history.save!
end
rescue ActiveRecord::StatementInvalid
warn "[archer] Unable to save history"
false
end
|
.start ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/archer.rb', line 26
def start
if !history_object
warn "[archer] Skipping history"
return
end
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
history_object.clear
history_object.push(*commands)
end
IRB.conf[:AT_EXIT].push(proc { Archer.save if Archer.save_session })
rescue
warn "[archer] Error loading history"
end
|