Skip to content

Instantly share code, notes, and snippets.

@jugyo
Last active December 13, 2015 19:19
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 jugyo/4961969 to your computer and use it in GitHub Desktop.
Save jugyo/4961969 to your computer and use it in GitHub Desktop.
earthquake.gem plugin to show english tweets only
# Configuration
# -------------
#
# Earthquake.config[:english] = {
# ignore: /jugyo|yukihiro_matz/,
# highlight: /ruby|rails|sublime|git|twitter/i
# }
#
Earthquake.init do
_ = config[:english] ||= {}
output_filter do |item|
next if _[:disable]
next unless item["text"] && item["_stream"]
if /[一-龠]+|[ぁ-ん]+|[ァ-ヴー]+|[a-zA-Z0-9]+/ !~ item["text"] ||
(_[:ignore] && (_[:ignore] =~ item["user"]["screen_name"] || _[:ignore] =~ item["text"]))
if _[:highlight]
words = item["text"].scan(_[:highlight])
unless words.empty?
item["_highlights"] ||= []
item["_highlights"] += words
end
end
true
else
false
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment