lib/archer.rb in archer-rails-0.4.1 vs lib/archer.rb in archer-rails-1.0.0

- old
+ new

@@ -1,9 +1,13 @@ # dependencies require "active_support/core_ext/module/attribute_accessors" +# stdlib +require "json" + # modules +require_relative "archer/coder" require_relative "archer/engine" if defined?(Rails) require_relative "archer/irb" require_relative "archer/version" module Archer @@ -33,23 +37,26 @@ rescue ActiveRecord::StatementInvalid warn "[archer] Create table to enable history" end if history - commands = history.commands.split("\n") + commands = history.commands history_object.clear history_object.push(*commands) end IRB.conf[:AT_EXIT].push(proc { Archer.save if Archer.save_session }) + rescue + # never prevent console from booting + warn "[archer] Error loading history" end 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).join("\n") + history.commands = history_object.to_a.last(limit) history.save! end rescue ActiveRecord::StatementInvalid warn "[archer] Unable to save history" false