lib/ayadn/workers.rb in ayadn-1.0.4 vs lib/ayadn/workers.rb in ayadn-1.0.5
- old
+ new
@@ -274,12 +274,10 @@
users_hash[item['id']] = [item['username'], item['name'], item['you_follow'], item['follows_you']]
end
users_hash
end
- private
-
def colorize_text(text, mentions)
handles = Array.new
mentions.each {|username| handles << "@#{username}"}
words = Array.new
sentences = Array.new
@@ -288,11 +286,18 @@
text.scan(/^.+[\r\n]*/) do |sentence|
sentence.split(' ').each do |word|
if word =~ /#\w+/
words << word.gsub(/#([A-Za-z0-9_]{1,255})(?![\w+])/, '#\1'.color(hashtag_color))
elsif word =~ /@\w+/
- if handles.include?(word) || word =~ /@\w+[:]/
+ splitted = word.split(/[:\-;,?!'&`^=+<>*%()]/) if word =~ /[:\-;,?!'&`^=+<>*%()]/
+ if splitted
+ splitted.each {|d| @str = d if d =~ /@\w+/}
+ @str = word if @str.nil?
+ else
+ @str = word
+ end
+ if handles.include?(@str.downcase)
words << word.gsub(/@([A-Za-z0-9_]{1,20})(?![\w+])/, '@\1'.color(mention_color))
else
words << word
end
else
@@ -302,9 +307,11 @@
sentences << words.join(' ')
words = Array.new
end
sentences.join("\n")
end
+
+ private
def init_table
Terminal::Table.new do |t|
t.style = { :width => Settings.options[:formats][:table][:width] }
end