Skip to content

Instantly share code, notes, and snippets.

@siyo
Created October 20, 2011 17:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save siyo/1301720 to your computer and use it in GitHub Desktop.
Save siyo/1301720 to your computer and use it in GitHub Desktop.
複数行のtweetも綺麗に出力したいとき用earthquake.gem plugin (Earthquake.config[:raw_text] = true 時)
# -*- coding: utf-8 -*-
#
# ~/.earthquake/config
#
# Earthquake.config[:raw_text] = true
#
Earthquake.init do
output_filter do |item|
next unless Earthquake.config[:raw_text] && item && item["user"]
n = item["user"]["screen_name"].size + 8
n += item["_mark"].to_i if item["_mark"]
n += if item["retweeted_status"]
item["retweeted_status"]["user"]["screen_name"].size + 6
else
0
end
txt = if item["retweeted_status"] && item["truncated"]
item["retweeted_status"]["text"]
else
item["text"]
end
txt.gsub!("\n","%s%*s" % ["\n",n,""])
true
end
end
@siyo
Copy link
Author

siyo commented Oct 20, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment