Created
December 4, 2010 14:46
-
-
Save no6v/728232 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/plugins/defaults/stdout.rb b/lib/plugins/defaults/stdout.rb | |
index 53f61d1..2a0fb18 100644 | |
--- a/lib/plugins/defaults/stdout.rb | |
+++ b/lib/plugins/defaults/stdout.rb | |
@@ -28,7 +28,7 @@ config.plugins.stdout.set_default(:time_format_not_today, '%y/%m/%d %H:%M') | |
config.plugins.stdout.set_default(:enable_pager, false) | |
config.plugins.stdout.set_default(:pager, 'less -R -f +G') | |
config.plugins.stdout.set_default(:window_height, 50) | |
-config.plugins.stdout.set_default(:typable_ids, ('aa'..'zz').to_a) | |
+config.plugins.stdout.set_default(:typable_ids, ('aa'..'zz').cycle) | |
config.plugins.stdout.set_default(:typable_id_prefix, '$') | |
config.plugins.stdout.set_default(:show_reply_chain, true) | |
config.plugins.stdout.set_default(:indent_format, %q("#{' ' * (indent - 1)} → ")) | |
@@ -39,23 +39,17 @@ config.plugins.stdout.set_default( | |
module Termtter | |
class TypableIdGenerator | |
def initialize(ids) | |
- if not ids.kind_of?(Array) | |
- raise ArgumentError, 'ids should be an Array' | |
- elsif ids.empty? | |
- raise ArgumentError, 'ids should not be empty' | |
- end | |
@ids = ids | |
@table = {} | |
@rtable = {} | |
end | |
def next(data) | |
- id = @ids.shift | |
- @ids.push id | |
- @rtable.delete(@table[id]) | |
- @table[id] = data | |
- @rtable[data] = id | |
- id | |
+ @ids.next.tap do |id| | |
+ @rtable.delete(@table[id]) | |
+ @table[id] = data | |
+ @rtable[data] = id | |
+ end | |
end | |
def get(id) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment