Minor readability cleanups and TODO addition

This commit is contained in:
Eric Budd 2018-03-31 21:11:18 -04:00
parent f741e157c7
commit a37f1f7d03
2 changed files with 10 additions and 5 deletions

View File

@ -24,6 +24,7 @@
# Features:
* Message deletion
* Message editing
* Allow shelling out to editor for message editing?
* Gracefully handle bad message files
* Add read-only mode if user doesn't want/can't have message file
* Add user muting (~/.iris.muted)

14
iris.rb
View File

@ -39,7 +39,10 @@ class String
return self if r.match(self).nil?
newstr = split.first + $&.color_token + split.last
return (newstr + COLOR_RESET).gsub(/\|KOPEN\|/, '{').gsub(/\|KCLOSE\|/, '}') if r.match(newstr).nil?
if r.match(newstr).nil?
return (newstr + COLOR_RESET).gsub(/\|KOPEN\|/, '{').gsub(/\|KCLOSE\|/, '}')
end
newstr.colorize
end
@ -54,12 +57,13 @@ class String
end
def wrapped(width = Display::WIDTH)
self.gsub(/.{1,#{width}}(?:\s|\Z|\-)/){($& + 5.chr).gsub(/\n\005/,"\n").gsub(/\005/,"\n")}
self.gsub(/.{1,#{width}}(?:\s|\Z|\-)/) {
($& + 5.chr).gsub(/\n\005/,"\n").gsub(/\005/,"\n")
}
end
def pluralize(count)
return self if count == 1
self + 's'
count == 1 ? self : self + 's'
end
end
@ -84,7 +88,7 @@ class Corpus
@@corpus = Config.find_files.map { |filepath| IrisFile.load_messages(filepath) }.flatten.sort_by(&:timestamp)
@@topics = @@corpus.select{ |m| m.parent == nil }
@@my_corpus = IrisFile.load_messages.sort_by(&:timestamp)
@@my_reads = IrisFile.load_reads
@@my_reads = IrisFile.load_reads
@@all_hash_to_index = @@corpus.reduce({}) { |agg, msg| agg[msg.hash] = @@corpus.index(msg); agg }
@@all_parent_hash_to_index = @@corpus.reduce({}) do |agg, msg|
agg[msg.parent] ||= []