1
0
Fork 0
mirror of https://github.com/vbatts/persistent-shell-history.git synced 2024-11-21 23:25:40 +00:00

fixing encoding issues for newer ruby

This commit is contained in:
Vincent Batts 2013-12-11 15:43:57 -05:00
parent 5583bc8405
commit 106aead462

View file

@ -1,4 +1,3 @@
require 'digest/md5' require 'digest/md5'
require 'gdbm' require 'gdbm'
require 'yaml' require 'yaml'
@ -7,6 +6,11 @@ require 'persistent-shell-history/abstract-history-store'
require 'persistent-shell-history/history' require 'persistent-shell-history/history'
require 'persistent-shell-history/command' require 'persistent-shell-history/command'
if RUBY_VERSION >= "1.9" # assuming you're running Ruby ~1.9
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
end
module Persistent module Persistent
module Shell module Shell
class BinaryHistoryStore < AbstractHistoryStore class BinaryHistoryStore < AbstractHistoryStore
@ -51,7 +55,7 @@ module Persistent
# display a formatted time commend # display a formatted time commend
def fmt(cmd); " %s %s" % [Time.at(cmd[:time]).strftime(@options[:time_format]), cmd[:cmd]]; end def fmt(cmd); " %s %s" % [Time.at(cmd[:time]).strftime(@options[:time_format]), cmd[:cmd]]; end
def find(pat) def find(pat)
return values.select {|v| return values.select {|v|
v if v[:cmd] =~ /#{pat}/ v if v[:cmd] =~ /#{pat}/
@ -61,7 +65,7 @@ module Persistent
} }
}.flatten }.flatten
end end
def load(filename = @options[:file]) def load(filename = @options[:file])
open(filename) do |f| open(filename) do |f|
f.each_line do |line| f.each_line do |line|